Merge branch 'yk/filter-branch-non-committish-refs'

when refs that do not point at committish are given, "git
filter-branch" gave a misleading error messages.  This has been
corrected.

* yk/filter-branch-non-committish-refs:
  filter-branch: fix errors caused by refs that point at non-committish
This commit is contained in:
Junio C Hamano 2018-04-10 16:28:23 +09:00
Родитель e8cb62f190 f78ab355e7
Коммит 9aa3a4c406
2 изменённых файлов: 26 добавлений и 2 удалений

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

@ -251,8 +251,18 @@ done < "$tempdir"/backup-refs
# The 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 --no-flags --revs-only --symbolic-full-name \
--default HEAD "$@" > "$tempdir"/raw-heads || exit --default HEAD "$@" > "$tempdir"/raw-refs || exit
sed -e '/^^/d' "$tempdir"/raw-heads >"$tempdir"/heads while read ref
do
case "$ref" in ^?*) continue ;; esac
if git rev-parse --verify "$ref"^0 >/dev/null 2>&1
then
echo "$ref"
else
warn "WARNING: not rewriting '$ref' (not a committish)"
fi
done >"$tempdir"/heads <"$tempdir"/raw-refs
test -s "$tempdir"/heads || test -s "$tempdir"/heads ||
die "You must specify a ref to rewrite." die "You must specify a ref to rewrite."

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

@ -470,4 +470,18 @@ test_expect_success 'tree-filter deals with object name vs pathname ambiguity' '
git show HEAD:$ambiguous git show HEAD:$ambiguous
' '
test_expect_success 'rewrite repository including refs that point at non-commit object' '
test_when_finished "git reset --hard original" &&
tree=$(git rev-parse HEAD^{tree}) &&
test_when_finished "git replace -d $tree" &&
echo A >new &&
git add new &&
new_tree=$(git write-tree) &&
git replace $tree $new_tree &&
git tag -a -m "tag to a tree" treetag $new_tree &&
git reset --hard HEAD &&
git filter-branch -f -- --all >filter-output 2>&1 &&
! fgrep fatal filter-output
'
test_done test_done