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>
This commit is contained in:
Junio C Hamano 2008-01-05 12:18:43 -08:00
Родитель a6d97d49e2
Коммит 418fa3a5c9
1 изменённых файлов: 3 добавлений и 19 удалений

Просмотреть файл

@ -209,25 +209,9 @@ ORIG_GIT_INDEX_FILE="$GIT_INDEX_FILE"
GIT_WORK_TREE=. GIT_WORK_TREE=.
export GIT_DIR GIT_WORK_TREE export GIT_DIR GIT_WORK_TREE
# These refs should be updated if their heads were rewritten # The refs should be updated if their heads were rewritten
git rev-parse --no-flags --revs-only --symbolic-full-name "$@" |
git rev-parse --revs-only --symbolic "$@" | sed -e '/^^/d' >"$tempdir"/heads
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
test -s "$tempdir"/heads || test -s "$tempdir"/heads ||
die "Which ref do you want to rewrite?" die "Which ref do you want to rewrite?"