Git development
 help / color / mirror / Atom feed
* [PATCH] git-filter-branch.sh: Fix broken setting of GIT_DIR
@ 2007-08-10 14:02 David Kastrup
  2007-08-10 16:21 ` [fixed PATCH] " David Kastrup
  0 siblings, 1 reply; 15+ messages in thread
From: David Kastrup @ 2007-08-10 14:02 UTC (permalink / raw)
  To: git

If filter-branch is entered with an unset GIT_DIR, things are rather
fragile.  The GIT_DIR variable setting then points to something like
$(pwd)/../.. which is neither guaranteed to be a git directory
(depends on where filter-branch is started), nor will it continue to
work once the temporary directory (for which the pwd is output) ceases
to exist.

So we just call git-name-rev in order to get the correct setting here
for exporting.

Signed-off-by: David Kastrup <dak@gnu.org>
---
 git-filter-branch.sh |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index b5fa449..6cd489e 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -170,14 +170,10 @@ do
 	esac
 done < "$tempdir"/backup-refs
 
-case "$GIT_DIR" in
-/*)
-	;;
-*)
-	GIT_DIR="$(pwd)/../../$GIT_DIR"
-	;;
-esac
-export GIT_DIR GIT_WORK_TREE=.
+GIT_DIR=$(cd ../..;git-name-rev --git-dir)
+GIT_WORK_TREE=.
+
+export GIT_DIR GIT_WORK_TREE
 
 # These refs should be updated if their heads were rewritten
 
-- 
1.5.3.rc4.43.gaf14

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-08-12 18:45 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-10 14:02 [PATCH] git-filter-branch.sh: Fix broken setting of GIT_DIR David Kastrup
2007-08-10 16:21 ` [fixed PATCH] " David Kastrup
2007-08-11 10:06   ` Junio C Hamano
2007-08-11 10:32     ` David Kastrup
2007-08-11 12:12       ` David Kastrup
2007-08-11 12:29         ` David Kastrup
2007-08-11 19:53           ` Junio C Hamano
2007-08-11 21:04             ` David Kastrup
2007-08-11 22:02             ` [PATCH] Add a test for git-commit being confused by relative GIT_DIR David Kastrup
2007-08-12  1:55               ` Junio C Hamano
2007-08-12  6:47                 ` David Kastrup
2007-08-12 17:05                   ` Junio C Hamano
2007-08-12 18:44                     ` David Kastrup
2007-08-11 12:51         ` [fixed PATCH] git-filter-branch.sh: Fix broken setting of GIT_DIR Steven Grimm
2007-08-11 20:10           ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox