From e09aac645035146805a3af0389e1f27fe13599b9 Mon Sep 17 00:00:00 2001 From: Suhas Karanth Date: Fri, 3 May 2019 12:32:57 +0530 Subject: 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. --- pkg/commands/git.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pkg/commands') 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) { -- cgit v1.2.3