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
492
492
sha1=$( git rev-parse " $ref " ^0)
493
493
test -f " $workdir " /../map/$sha1 && continue
494
494
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
496
496
done < " $tempdir " /heads
497
497
fi
498
498
499
499
# Finally update the refs
500
500
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 "
503
501
echo
504
502
while read ref
505
503
do
519
517
git update-ref -m " filter-branch: delete" -d " $ref " $sha1 ||
520
518
die " Could not delete $ref "
521
519
;;
522
- $_x40 )
520
+ * )
523
521
echo " Ref '$ref ' was rewritten"
524
522
if ! git update-ref -m " filter-branch: rewrite" \
525
523
" $ref " $rewritten $sha1 2> /dev/null; then
533
531
fi
534
532
fi
535
533
;;
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
- ;;
546
534
esac
547
535
git update-ref -m " filter-branch: backup" " $orig_namespace$ref " $sha1 ||
548
536
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
506
506
! fgrep fatal filter-output
507
507
'
508
508
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
+
509
540
test_done
You can’t perform that action at this time.
0 commit comments