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

[PATCH 1/5] Simplify setup of $GIT_DIR in git-sh-setup.sh

From
LHLars Hjemli <hjemli@gmail.com>
Date
Feb 18, 2008, 10:44 UTC
Message-ID
<1203331463-13857-2-git-send-email-hjemli@gmail.com>
In-Reply-To
<1203331463-13857-1-git-send-email-hjemli@gmail.com>

Using 'git rev-parse --git-dir' makes the code shorter and more future- proof.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
---
 git-sh-setup.sh |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f388275..a44b1c7 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -127,20 +127,14 @@ get_author_ident_from_commit () {
 # if we require to be in a git repository.
 if test -z "$NONGIT_OK"
 then
+	GIT_DIR=$(git rev-parse --git-dir) || exit
 	if [ -z "$SUBDIRECTORY_OK" ]
 	then
-		: ${GIT_DIR=.git}
 		test -z "$(git rev-parse --show-cdup)" || {
 			exit=$?
 			echo >&2 "You need to run this command from the toplevel of the working tree."
 			exit $exit
 		}
-	else
-		GIT_DIR=$(git rev-parse --git-dir) || {
-		    exit=$?
-		    echo >&2 "Failed to find a valid git directory."
-		    exit $exit
-		}
 	fi
 	test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
 		echo >&2 "Unable to determine absolute path of git directory"
-- 
1.5.4.1.188.g3ea1f5
Previous: Lars HjemliNext: Lars Hjemli
Message 2 of 18 in “Introduce the .gitfile”
  1. 0/5 Introduce the .gitfileLars Hjemli, Feb 18, 2008
  2. 1/5 Simplify setup of $GIT_DIR in git-sh-setup.shLars Hjemli, Feb 18, 2008
  3. 2/5 Add platform-independent .git "symlink"Lars Hjemli, Feb 18, 2008
  4. 3/5 Teach resolve_gitlink_ref() about the .git fileLars Hjemli, Feb 18, 2008
  5. 4/5 git-submodule: prepare for the .git-fileLars Hjemli, Feb 18, 2008
  6. 5/5 Teach GIT-VERSION-GEN about the .git fileLars Hjemli, Feb 18, 2008
  7. Johannes SchindelinFeb 18, 2008
  8. Lars HjemliFeb 18, 2008
  9. Jakub NarebskiFeb 18, 2008
  10. Johannes SchindelinFeb 18, 2008
  11. Lars HjemliFeb 18, 2008
  12. 2/5 Add platform-independent .git "symlink"Lars Hjemli, Feb 18, 2008
  13. Johannes SchindelinFeb 18, 2008
  14. Johannes SchindelinFeb 18, 2008
  15. Lars HjemliFeb 18, 2008
  16. Johannes SchindelinFeb 18, 2008
  17. Lars HjemliFeb 18, 2008
  18. Johannes SchindelinFeb 18, 2008

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.