1. Stefan Saasen
  2. git

Commits

David Kastrup  committed b2bc9a3

git-sh-setup.sh: make GIT_DIR absolute

Quite a few of the scripts are rather careless about using GIT_DIR
while changing directories.

Some try their hands (with different likelihood of success) in making
GIT_DIR absolute.

This patch lets git-sh-setup.sh cater for absolute directories (in a
way that should work reliably also with non-Unix path names) and
removes the respective kludges in git-filter-branch.sh and
git-instaweb.sh.

Signed-off-by: David Kastrup <dak@gnu.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

  • Participants
  • Parent commits 0476786
  • Branches master

Comments (0)

Files changed (3)

File git-filter-branch.sh

View file
  • Ignore whitespace
 	esac
 done < "$tempdir"/backup-refs
 
-case "$GIT_DIR" in
-/*)
-	;;
-*)
-	GIT_DIR="$(pwd)/../../$GIT_DIR"
-	;;
-esac
 export GIT_DIR GIT_WORK_TREE=.
 
 # These refs should be updated if their heads were rewritten

File git-instaweb.sh

View file
  • Ignore whitespace
 
 . git-sh-setup
 
-case "$GIT_DIR" in
-/*)
-	fqgitdir="$GIT_DIR" ;;
-*)
-	fqgitdir="$PWD/$GIT_DIR" ;;
-esac
-
+fqgitdir="$GIT_DIR"
 local="`git config --bool --get instaweb.local`"
 httpd="`git config --get instaweb.httpd`"
 browser="`git config --get instaweb.browser`"

File git-sh-setup.sh

View file
  • Ignore whitespace
 		exit $exit
 	}
 else
-	GIT_DIR=$(git rev-parse --git-dir) || exit
+	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"
+    exit 1
+}
+
 : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}