{"thread":{"id":"9487","subject":"[PATCH] git-sh-setup.sh: make GIT_DIR absolute","startedAt":"2007-08-11T13:36:28Z","lastAt":"2007-08-11T13:36:28Z","messageCount":1,"participants":["David Kastrup"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50481","messageId":"85r6maurab.fsf@lola.goethe.zz","threadId":"9487","inReplyTo":null,"subject":"[PATCH] git-sh-setup.sh: make GIT_DIR absolute","fromName":"David Kastrup","fromEmail":"dak@gnu.org","sentAt":"2007-08-11T13:36:28Z","receivedAt":"2007-08-11T13:36:28Z","isPatch":true,"sender":{"key":"dak@gnu.org","avatar":"https://avatars.githubusercontent.com/u/52141349?v=4"},"body":"Quite a few of the scripts are rather careless about using GIT_DIR\nwhile changing directories.\n\nSome try their hands (with different likelihood of success) in making\nGIT_DIR absolute.\n\nThis patch lets git-sh-setup.sh cater for absolute directories (in a\nway that should work reliably also with non-Unix path names) and\nremoves the respective kludges in git-filter-branch.sh and\ngit-instaweb.sh.\n\nSigned-off-by: David Kastrup <dak@gnu.org>\n---\n git-filter-branch.sh |    7 -------\n git-instaweb.sh      |    8 +-------\n git-sh-setup.sh      |   12 +++++++++++-\n 3 files changed, 12 insertions(+), 15 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex b5fa449..c42e451 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -170,13 +170,6 @@ do\n \tesac\n done < \"$tempdir\"/backup-refs\n \n-case \"$GIT_DIR\" in\n-/*)\n-\t;;\n-*)\n-\tGIT_DIR=\"$(pwd)/../../$GIT_DIR\"\n-\t;;\n-esac\n export GIT_DIR GIT_WORK_TREE=.\n \n # These refs should be updated if their heads were rewritten\ndiff --git a/git-instaweb.sh b/git-instaweb.sh\nindex cbc7418..b79c6b6 100755\n--- a/git-instaweb.sh\n+++ b/git-instaweb.sh\n@@ -8,13 +8,7 @@ USAGE='[--start] [--stop] [--restart]\n \n . git-sh-setup\n \n-case \"$GIT_DIR\" in\n-/*)\n-\tfqgitdir=\"$GIT_DIR\" ;;\n-*)\n-\tfqgitdir=\"$PWD/$GIT_DIR\" ;;\n-esac\n-\n+fqgitdir=\"$GIT_DIR\"\n local=\"`git config --bool --get instaweb.local`\"\n httpd=\"`git config --get instaweb.httpd`\"\n browser=\"`git config --get instaweb.browser`\"\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 8cbd153..185c5c6 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -116,6 +116,16 @@ then\n \t\texit $exit\n \t}\n else\n-\tGIT_DIR=$(git rev-parse --git-dir) || exit\n+\tGIT_DIR=$(git rev-parse --git-dir) || {\n+\t    exit=$?\n+\t    echo >&2 \"Failed to find a valid git directory.\"\n+\t    exit $exit\n+\t}\n fi\n+\n+test -n \"$GIT_DIR\" && GIT_DIR=$(cd \"$GIT_DIR\" && pwd) || {\n+    echo >&2 \"Unable to determine absolute path of git directory\"\n+    exit 1\n+}\n+\n : ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n-- \n1.5.3.rc2.187.g9a1d2-dirty\n"}]}