[PATCH] git-sh-setup.sh: make GIT_DIR absolute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 git-filter-branch.sh |    7 -------
 git-instaweb.sh      |    8 +-------
 git-sh-setup.sh      |   12 +++++++++++-
 3 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index b5fa449..c42e451 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -170,13 +170,6 @@ do
 	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
diff --git a/git-instaweb.sh b/git-instaweb.sh
index cbc7418..b79c6b6 100755
--- a/git-instaweb.sh
+++ b/git-instaweb.sh
@@ -8,13 +8,7 @@ USAGE='[--start] [--stop] [--restart]
 
 . 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`"
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 8cbd153..185c5c6 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -116,6 +116,16 @@ then
 		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"}
-- 
1.5.3.rc2.187.g9a1d2-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux