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: default avatarRuss Cox <rsc@golang.org>
parent 7f0b4a87
...@@ -322,12 +322,18 @@ func findgoversion() string { ...@@ -322,12 +322,18 @@ func findgoversion() string {
// isGitRepo reports whether the working directory is inside a Git repository. // isGitRepo reports whether the working directory is inside a Git repository.
func isGitRepo() bool { func isGitRepo() bool {
// NB: simply checking the exit code of `git rev-parse --git-dir` would p := ".git"
// suffice here, but that requires deviating from the infrastructure for {
// provided by `run`. fi, err := os.Stat(p)
gitDir := chomp(run(goroot, 0, "git", "rev-parse", "--git-dir")) if os.IsNotExist(err) {
fi, err := os.Stat(gitDir) p = filepath.Join("..", p)
return err == nil && fi.IsDir() 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