Skip to content

Commit

Permalink
Improve directory check for .git
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sudo-suhas authored and jesseduffield committed May 6, 2019
1 parent b505c29 commit e09aac6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/commands/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e09aac6

Please sign in to comment.