From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: [PATCH 4/4] filter-branch: fix variable export logic
Date: Tue, 13 May 2008 04:46:38 -0400 [thread overview]
Message-ID: <20080513084638.GD23799@sigill.intra.peff.net> (raw)
In-Reply-To: <20080513084338.GA23729@sigill.intra.peff.net>
filter-branch tries to restore "old" copies of some
environment variables by using the construct:
unset var
test -z "$old_var" || var="$old_var" && export var
However, by the short-circuit logic, we will always run
'export var'. On bash and dash, exporting an unset variable
has no effect. However, on some shells (such as FreeBSD's
/bin/sh), the shell exports the empty value.
This manifested itself in this case as git-filter-branch
setting GIT_INDEX_FILE to the empty string, which in turn
caused its call to git-read-tree to fail, leaving the
working tree pointing at the original HEAD instead of the
rewritten one.
To fix this, we change the short-circuit logic to better
match the intent:
test -z "$old_var" || { var="$old_var" && export var; }
Signed-off-by: Jeff King <peff@peff.net>
---
git-filter-branch.sh | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 333f6a8..0304dc5 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -435,11 +435,11 @@ rm -rf "$tempdir"
trap - 0
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE
-test -z "$ORIG_GIT_DIR" || GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR
-test -z "$ORIG_GIT_WORK_TREE" || GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
- export GIT_WORK_TREE
-test -z "$ORIG_GIT_INDEX_FILE" || GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
- export GIT_INDEX_FILE
+test -z "$ORIG_GIT_DIR" || { GIT_DIR="$ORIG_GIT_DIR" && export GIT_DIR; }
+test -z "$ORIG_GIT_WORK_TREE" || { GIT_WORK_TREE="$ORIG_GIT_WORK_TREE" &&
+ export GIT_WORK_TREE; }
+test -z "$ORIG_GIT_INDEX_FILE" || { GIT_INDEX_FILE="$ORIG_GIT_INDEX_FILE" &&
+ export GIT_INDEX_FILE; }
git read-tree -u -m HEAD
exit $ret
--
1.5.5.1.296.gf618c
next prev parent reply other threads:[~2008-05-13 8:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-13 8:43 [PATCH 0/4] freebsd portability fixes Jeff King
2008-05-13 8:44 ` [PATCH 1/4] fix bsd shell negation Jeff King
2008-05-14 2:27 ` Junio C Hamano
2008-05-14 4:01 ` Jeff King
2008-05-13 8:45 ` [PATCH 2/4] t5000: tar portability fix Jeff King
2008-05-13 8:45 ` [PATCH 3/4] clone: bsd shell " Jeff King
2008-05-13 8:46 ` Jeff King [this message]
2008-05-14 4:18 ` [PATCH 4/4] filter-branch: fix variable export logic Junio C Hamano
2008-05-14 4:57 ` Jeff King
2008-05-14 9:33 ` Paolo Bonzini
2008-05-13 9:04 ` [PATCH 0/4] freebsd portability fixes Jeff King
2008-05-13 20:39 ` Alex Riesen
2008-05-13 20:44 ` Alex Riesen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080513084638.GD23799@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).