repo: workaround for git returning no path when inside a .git dir

Michael Muré created

Change summary

repository/git.go | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Detailed changes

repository/git.go 🔗

@@ -79,7 +79,9 @@ func NewGitRepo(path string, witnesser func(repo *GitRepo) error) (*GitRepo, err
 	// Check the repo and retrieve the root path
 	stdout, err := repo.runGitCommand("rev-parse", "--show-toplevel")
 
-	if err != nil {
+	// for some reason, "git rev-parse --show-toplevel" return nothing
+	// and no error when inside a ".git" dir
+	if err != nil || stdout == "" {
 		return nil, ErrNotARepo
 	}