git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] require_work_tree broken with NONGIT_OK

From
Gabriel Filion <lelutin@gmail.com>
Date
Feb 15, 2010, 03:51 UTC
Message-ID
<4B78C4D3.90407@gmail.com>

When sourcing git-sh-setup after having set NONGIT_OK, 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 a sentence when it is called outside of a git repository.
Relying on the return code is better.
---
 git-sh-setup.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index d56426d..8de2f03 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 >/dev/null 2>&1 ||
 	die "fatal: $0 cannot be used without a working tree."
 }
 -- 1.6.6
Next: Jeff King
Message 1 of 6 in “require_work_tree broken with NONGIT_OK”
  1. require_work_tree broken with NONGIT_OKGabriel Filion, Feb 15, 2010
  2. Jeff KingFeb 15, 2010
  3. Junio C HamanoFeb 15, 2010
  4. Gabriel FilionFeb 15, 2010
  5. Jeff KingFeb 15, 2010
  6. Gabriel FilionFeb 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.