summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorSuhas Karanth <sudo.suhas@gmail.com>2019-05-03 12:32:57 +0530
committerJesse Duffield <jessedduffield@gmail.com>2019-05-06 21:37:42 +1000
commite09aac645035146805a3af0389e1f27fe13599b9 (patch)
tree80871ae138c916e3696c3e991ac394c2ab82fe02 /pkg/commands
parentb505c295d2d89caa47521554e435142980b9c036 (diff)
Improve directory check for .git
Return error if the .git exists but is not a directory. This provides a slightly better failure message for git repo with submodules in case the '.git' is a file which provides the reference to the parent's .git folder with the submodule inside.
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index 265d6553e..64f3cd4b1 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -27,8 +27,11 @@ func navigateToRepoRootDirectory(stat func(string) (os.FileInfo, error), chdir f
for {
f, err := stat(".git")
- if err == nil && f.IsDir() {
- return nil
+ if err == nil {
+ if f.IsDir() {
+ return nil
+ }
+ return errors.New("expected .git to be a directory")
}
if !os.IsNotExist(err) {