File tree Expand file tree Collapse file tree 2 files changed +33
-14
lines changed
Expand file tree Collapse file tree 2 files changed +33
-14
lines changed Original file line number Diff line number Diff line change @@ -492,14 +492,12 @@ then
492492 sha1=$( git rev-parse " $ref " ^0)
493493 test -f " $workdir " /../map/$sha1 && continue
494494 ancestor=$( git rev-list --simplify-merges -1 " $ref " " $@ " )
495- test " $ancestor " && echo $( map $ancestor ) >> " $workdir " /../map/$sha1
495+ test " $ancestor " && echo $( map $ancestor ) > " $workdir " /../map/$sha1
496496 done < " $tempdir " /heads
497497fi
498498
499499# Finally update the refs
500500
501- _x40=' [0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
502- _x40=" $_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40 "
503501echo
504502while read ref
505503do
519517 git update-ref -m " filter-branch: delete" -d " $ref " $sha1 ||
520518 die " Could not delete $ref "
521519 ;;
522- $_x40 )
520+ * )
523521 echo " Ref '$ref ' was rewritten"
524522 if ! git update-ref -m " filter-branch: rewrite" \
525523 " $ref " $rewritten $sha1 2> /dev/null; then
533531 fi
534532 fi
535533 ;;
536- * )
537- # NEEDSWORK: possibly add -Werror, making this an error
538- warn " WARNING: '$ref ' was rewritten into multiple commits:"
539- warn " $rewritten "
540- warn " WARNING: Ref '$ref ' points to the first one now."
541- rewritten=$( echo " $rewritten " | head -n 1)
542- git update-ref -m " filter-branch: rewrite to first" \
543- " $ref " $rewritten $sha1 ||
544- die " Could not rewrite $ref "
545- ;;
546534 esac
547535 git update-ref -m " filter-branch: backup" " $orig_namespace$ref " $sha1 ||
548536 exit
Original file line number Diff line number Diff line change @@ -506,4 +506,35 @@ test_expect_success 'rewrite repository including refs that point at non-commit
506506 ! fgrep fatal filter-output
507507'
508508
509+ test_expect_success ' filter-branch handles ref deletion' '
510+ git switch --orphan empty-commit &&
511+ git commit --allow-empty -m "empty commit" &&
512+ git tag empty &&
513+ git branch to-delete &&
514+ git filter-branch -f --prune-empty to-delete >out 2>&1 &&
515+ grep "to-delete.*was deleted" out &&
516+ test_must_fail git rev-parse --verify to-delete
517+ '
518+
519+ test_expect_success ' filter-branch handles ref rewrite' '
520+ git checkout empty &&
521+ test_commit to-drop &&
522+ git branch rewrite &&
523+ git filter-branch -f \
524+ --index-filter "git rm --ignore-unmatch --cached to-drop.t" \
525+ rewrite >out 2>&1 &&
526+ grep "rewrite.*was rewritten" out &&
527+ ! grep -i warning out &&
528+ git diff-tree empty rewrite
529+ '
530+
531+ test_expect_success ' filter-branch handles ancestor rewrite' '
532+ test_commit to-exclude &&
533+ git branch ancestor &&
534+ git filter-branch -f ancestor -- :^to-exclude.t >out 2>&1 &&
535+ grep "ancestor.*was rewritten" out &&
536+ ! grep -i warning out &&
537+ git diff-tree HEAD^ ancestor
538+ '
539+
509540test_done
You can’t perform that action at this time.
0 commit comments