From: Russ Cox Date: Wed, 6 Jan 2016 17:39:34 +0000 (+0000) Subject: Revert "cmd/dist: improve isGitRepo to handle git "worktree"s" X-Git-Tag: go1.6beta2~129 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=91ba9f45c25a0a6b2695b3391d53d31763228dc2;p=gostls13.git Revert "cmd/dist: improve isGitRepo to handle git "worktree"s" This reverts commit ab096d587f9bb5dcdf895511ee6d213aade7e30f. Change-Id: Icf366aa43acc41b4f8474edae0297e554368bf14 Reviewed-on: https://go-review.googlesource.com/18321 Reviewed-by: Russ Cox --- diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index 85cf3f9136..634c52c3b0 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -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 + } } /*