summaryrefslogtreecommitdiff
path: root/git-filter-branch.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-01-05 20:18:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-01-07 02:41:43 (GMT)
commit418fa3a5c9111e675d8fcd3271315c38cdb1f16b (patch)
tree727d46641f1f967e19709c2a4988fee4b99d8297 /git-filter-branch.sh
parenta6d97d49e23382027efff8a8e90e69e0572620c6 (diff)
downloadgit-418fa3a5c9111e675d8fcd3271315c38cdb1f16b.zip
git-418fa3a5c9111e675d8fcd3271315c38cdb1f16b.tar.gz
git-418fa3a5c9111e675d8fcd3271315c38cdb1f16b.tar.bz2
filter-branch: work correctly with ambiguous refnames
'git-filter-branch branch' could fail producing the error: "Which ref do you want to rewrite?" if existed another branch or tag, which name was 'branch-something' or 'something/branch'. [jc: original report and fix were done between Dmitry Potapov and Dscho; I rewrote it using "rev-parse --symbolic-full-name"] Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-filter-branch.sh')
-rwxr-xr-xgit-filter-branch.sh22
1 files changed, 3 insertions, 19 deletions
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index ae29f47..ebf05ca 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -209,25 +209,9 @@ ORIG_GIT_INDEX_FILE="$GIT_INDEX_FILE"
GIT_WORK_TREE=.
export GIT_DIR GIT_WORK_TREE
-# These refs should be updated if their heads were rewritten
-
-git rev-parse --revs-only --symbolic "$@" |
-while read ref
-do
- # normalize ref
- case "$ref" in
- HEAD)
- ref="$(git symbolic-ref "$ref")"
- ;;
- refs/*)
- ;;
- *)
- ref="$(git for-each-ref --format='%(refname)' |
- grep /"$ref")"
- esac
-
- git check-ref-format "$ref" && echo "$ref"
-done > "$tempdir"/heads
+# The refs should be updated if their heads were rewritten
+git rev-parse --no-flags --revs-only --symbolic-full-name "$@" |
+sed -e '/^^/d' >"$tempdir"/heads
test -s "$tempdir"/heads ||
die "Which ref do you want to rewrite?"