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>
Junio C Hamano committed
Jan 5, 2008 at 12:18 UTC
418fa3a5c9111e675d8fcd3271315c38cdb1f16b
1 file changed
+3
-19
git-filter-branch.sh
+3
-19
@@ -209,25 +209,9 @@ ORIG_GIT_INDEX_FILE="$GIT_INDEX_FILE"
209
GIT_WORK_TREE=.
210
export GIT_DIR GIT_WORK_TREE
211
212
-# These refs should be updated if their heads were rewritten
213
-
214
-git rev-parse --revs-only --symbolic "$@" |
215
-while read ref
216
-do
217
- # normalize ref
218
- case "$ref" in
219
- HEAD)
220
- ref="$(git symbolic-ref "$ref")"
221
- ;;
222
- refs/*)
223
- ;;
224
- *)
225
- ref="$(git for-each-ref --format='%(refname)' |
226
- grep /"$ref")"
227
- esac
228
-
229
- git check-ref-format "$ref" && echo "$ref"
230
-done > "$tempdir"/heads
212
+# The refs should be updated if their heads were rewritten
213
+git rev-parse --no-flags --revs-only --symbolic-full-name "$@" |
214
+sed -e '/^^/d' >"$tempdir"/heads
215
216
test -s "$tempdir"/heads ||
217
die "Which ref do you want to rewrite?"