Commit 91ba9f45 authored by Russ Cox's avatar Russ Cox

Revert "cmd/dist: improve isGitRepo to handle git "worktree"s"

This reverts commit ab096d58.

Change-Id: Icf366aa43acc41b4f8474edae0297e554368bf14
Reviewed-on: https://go-review.googlesource.com/18321Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent 7f0b4a87
......@@ -322,12 +322,18 @@ func findgoversion() string {
// isGitRepo reports whether the working directory is inside a Git repository.
func isGitRepo() bool {
// NB: simply checking the exit code of `git rev-parse --git-dir` would
// suffice here, but that requires deviating from the infrastructure
// provided by `run`.
gitDir := chomp(run(goroot, 0, "git", "rev-parse", "--git-dir"))
fi, err := os.Stat(gitDir)
return err == nil && fi.IsDir()
p := ".git"
for {
fi, err := os.Stat(p)
if os.IsNotExist(err) {
p = filepath.Join("..", p)
continue
}
if err != nil || !fi.IsDir() {
return false
}
return true
}
}
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment