@matheusbsbs / matheus-bagliano / commits / b2bc9a3098
Fork 0

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>

David Kastrup committed Aug 11, 2007 at 15:36 UTC b2bc9a30981ace8c18d1a73b3e10153efc5c20f7
3 files changed +12 -15
git-filter-branch.sh
-7
@@ -170,13 +170,6 @@ do
170 esac
171 done < "$tempdir"/backup-refs
172
173 -case "$GIT_DIR" in
174 -/*)
175 - ;;
176 -*)
177 - GIT_DIR="$(pwd)/../../$GIT_DIR"
178 - ;;
179 -esac
173 export GIT_DIR GIT_WORK_TREE=.
174
175 # These refs should be updated if their heads were rewritten
git-instaweb.sh
+1 -7
@@ -8,13 +8,7 @@ USAGE='[--start] [--stop] [--restart]
8
9 . git-sh-setup
10
11 -case "$GIT_DIR" in
12 -/*)
13 - fqgitdir="$GIT_DIR" ;;
14 -*)
15 - fqgitdir="$PWD/$GIT_DIR" ;;
16 -esac
17 -
11 +fqgitdir="$GIT_DIR"
12 local="`git config --bool --get instaweb.local`"
13 httpd="`git config --get instaweb.httpd`"
14 browser="`git config --get instaweb.browser`"
git-sh-setup.sh
+11 -1
@@ -116,6 +116,16 @@ then
116 exit $exit
117 }
118 else
119 - GIT_DIR=$(git rev-parse --git-dir) || exit
119 + GIT_DIR=$(git rev-parse --git-dir) || {
120 + exit=$?
121 + echo >&2 "Failed to find a valid git directory."
122 + exit $exit
123 + }
124 fi
125 +
126 +test -n "$GIT_DIR" && GIT_DIR=$(cd "$GIT_DIR" && pwd) || {
127 + echo >&2 "Unable to determine absolute path of git directory"
128 + exit 1
129 +}
130 +
131 : ${GIT_OBJECT_DIRECTORY="$GIT_DIR/objects"}