From 91ba9f45c25a0a6b2695b3391d53d31763228dc2 Mon Sep 17 00:00:00 2001
From: Russ Cox <rsc@golang.org>
Date: Wed, 6 Jan 2016 17:39:34 +0000
Subject: [PATCH] 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 <rsc@golang.org>
---
 src/cmd/dist/build.go | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go
index 85cf3f91364..634c52c3b0f 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
+	}
 }
 
 /*
-- 
GitLab