threads / patch / 22686

v2Re: [PATCH v2] require_work_tree broken with NONGIT_OK

Subject: Re: [PATCH v2] require_work_tree broken with NONGIT_OK

## tl;dr

One message between Feb 17, 2010 and Feb 17, 2010. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Gabriel Filion· Feb 17, 2010, 04:18 UTC · lore

Sourcing git-sh-setup: After having set NONGIT_OK, when calling the function require_work_tree while outside of a git repository shows a syntax error. This is caused by the call to git rev-parse --is-inside-work-tree printing nothing when it is called outside of a git repository.

Quoting the call removes the syntax error and sending stderr to /dev/null removes duplicate error messages.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
---
 git-sh-setup.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to git-sh-setup.sh +1 −1
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index d56426d..5e22440 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -128,7 +128,7 @@ cd_to_toplevel () {
 }
  require_work_tree () {
-	test $(git rev-parse --is-inside-work-tree) = true ||
+	test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ||
 	die "fatal: $0 cannot be used without a working tree."
 }
 -- 1.6.6

← back to recent threads