533
for prev in topic main..topic
534
do
535
test_expect_success "format-patch --range-diff=$prev" '
536
+ test_when_finished "rm -f 000?-*" &&
537
git format-patch --cover-letter --range-diff=$prev \
538
main..unmodified >actual &&
538
- test_when_finished "rm 000?-*" &&
539
test_line_count = 5 actual &&
540
test_grep "^Range-diff:$" 0000-* &&
541
grep "= 1: .* s/5/A" 0000-* &&
560
'
561
562
test_expect_success 'format-patch --range-diff as commentary' '
563
+ test_when_finished "rm -f 0001-*" &&
564
git format-patch --range-diff=HEAD~1 HEAD~1 >actual &&
564
- test_when_finished "rm 0001-*" &&
565
test_line_count = 1 actual &&
566
test_grep "^Range-diff:$" 0001-* &&
567
grep "> 1: .* new message" 0001-*
568
'
569
570
test_expect_success 'format-patch --range-diff reroll-count with a non-integer' '
571
+ test_when_finished "rm -f v2.9-0001-*" &&
572
git format-patch --range-diff=HEAD~1 -v2.9 HEAD~1 >actual &&
572
- test_when_finished "rm v2.9-0001-*" &&
573
test_line_count = 1 actual &&
574
test_grep "^Range-diff:$" v2.9-0001-* &&
575
grep "> 1: .* new message" v2.9-0001-*
576
'
577
578
test_expect_success 'format-patch --range-diff reroll-count with a integer' '
579
+ test_when_finished "rm -f v2-0001-*" &&
580
git format-patch --range-diff=HEAD~1 -v2 HEAD~1 >actual &&
580
- test_when_finished "rm v2-0001-*" &&
581
test_line_count = 1 actual &&
582
test_grep "^Range-diff ..* v1:$" v2-0001-* &&
583
grep "> 1: .* new message" v2-0001-*
584
'
585
586
test_expect_success 'format-patch --range-diff with v0' '
587
+ test_when_finished "rm -f v0-0001-*" &&
588
git format-patch --range-diff=HEAD~1 -v0 HEAD~1 >actual &&
588
- test_when_finished "rm v0-0001-*" &&
589
test_line_count = 1 actual &&
590
test_grep "^Range-diff:$" v0-0001-* &&
591
grep "> 1: .* new message" v0-0001-*
606
'
607
608
test_expect_success 'range-diff compares notes by default' '
609
+ test_when_finished "git notes remove topic unmodified || :" &&
610
git notes add -m "topic note" topic &&
611
git notes add -m "unmodified note" unmodified &&
611
- test_when_finished git notes remove topic unmodified &&
612
git range-diff --no-color main..topic main..unmodified \
613
>actual &&
614
sed s/Z/\ /g >expect <<-EOF &&
630
'
631
632
test_expect_success 'range-diff with --no-notes' '
633
+ test_when_finished "git notes remove topic unmodified || :" &&
634
git notes add -m "topic note" topic &&
635
git notes add -m "unmodified note" unmodified &&
635
- test_when_finished git notes remove topic unmodified &&
636
git range-diff --no-color --no-notes main..topic main..unmodified \
637
>actual &&
638
cat >expect <<-EOF &&
645
'
646
647
test_expect_success 'range-diff with multiple --notes' '
648
+ test_when_finished "git notes --ref=note1 remove topic unmodified || :" &&
649
git notes --ref=note1 add -m "topic note1" topic &&
650
git notes --ref=note1 add -m "unmodified note1" unmodified &&
650
- test_when_finished git notes --ref=note1 remove topic unmodified &&
651
+ test_when_finished "git notes --ref=note2 remove topic unmodified || :" &&
652
git notes --ref=note2 add -m "topic note2" topic &&
653
git notes --ref=note2 add -m "unmodified note2" unmodified &&
653
- test_when_finished git notes --ref=note2 remove topic unmodified &&
654
git range-diff --no-color --notes=note1 --notes=note2 main..topic main..unmodified \
655
>actual &&
656
sed s/Z/\ /g >expect <<-EOF &&
678
679
# `range-diff` should act like `log` with regards to notes
680
test_expect_success 'range-diff with --notes=custom does not show default notes' '
681
+ test_when_finished "git notes remove topic unmodified || :" &&
682
git notes add -m "topic note" topic &&
683
git notes add -m "unmodified note" unmodified &&
684
+ test_when_finished "git notes --ref=custom remove topic unmodified || :" &&
685
git notes --ref=custom add -m "topic note" topic &&
686
git notes --ref=custom add -m "unmodified note" unmodified &&
685
- test_when_finished git notes remove topic unmodified &&
686
- test_when_finished git notes --ref=custom remove topic unmodified &&
687
git range-diff --notes=custom main..topic main..unmodified \
688
>actual &&
689
! grep "## Notes ##" actual &&
691
'
692
693
test_expect_success 'format-patch --range-diff does not compare notes by default' '
694
+ test_when_finished "git notes remove topic unmodified || :" &&
695
git notes add -m "topic note" topic &&
696
git notes add -m "unmodified note" unmodified &&
696
- test_when_finished git notes remove topic unmodified &&
697
+ test_when_finished "rm -f 000?-*" &&
698
git format-patch --cover-letter --range-diff=$prev \
699
main..unmodified >actual &&
699
- test_when_finished "rm 000?-*" &&
700
test_line_count = 5 actual &&
701
test_grep "^Range-diff:$" 0000-* &&
702
grep "= 1: .* s/5/A" 0000-* &&
708
'
709
710
test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' '
711
+ test_when_finished "git notes remove topic unmodified || :" &&
712
git notes add -m "topic note" topic &&
712
- git notes --ref=custom add -m "topic note (custom)" topic &&
713
git notes add -m "unmodified note" unmodified &&
714
+ test_when_finished "git notes --ref=custom remove topic unmodified || :" &&
715
+ git notes --ref=custom add -m "topic note (custom)" topic &&
716
git notes --ref=custom add -m "unmodified note (custom)" unmodified &&
715
- test_when_finished git notes remove topic unmodified &&
716
- test_when_finished git notes --ref=custom remove topic unmodified &&
717
+ test_when_finished "rm -f 000?-*" &&
718
git format-patch --notes=custom --cover-letter --range-diff=$prev \
719
main..unmodified >actual &&
719
- test_when_finished "rm 000?-*" &&
720
grep "## Notes (custom) ##" 0000-* &&
721
! grep "## Notes ##" 0000-*
722
'
723
724
test_expect_success 'format-patch --range-diff with --no-notes' '
725
+ test_when_finished "git notes remove topic unmodified || :" &&
726
git notes add -m "topic note" topic &&
727
git notes add -m "unmodified note" unmodified &&
727
- test_when_finished git notes remove topic unmodified &&
728
+ test_when_finished "rm -f 000?-*" &&
729
git format-patch --no-notes --cover-letter --range-diff=$prev \
730
main..unmodified >actual &&
730
- test_when_finished "rm 000?-*" &&
731
test_line_count = 5 actual &&
732
test_grep "^Range-diff:$" 0000-* &&
733
grep "= 1: .* s/5/A" 0000-* &&
739
'
740
741
test_expect_success 'format-patch --range-diff with --notes' '
742
+ test_when_finished "git notes remove topic unmodified || :" &&
743
git notes add -m "topic note" topic &&
744
git notes add -m "unmodified note" unmodified &&
744
- test_when_finished git notes remove topic unmodified &&
745
+ test_when_finished "rm -f 000?-*" &&
746
git format-patch --notes --cover-letter --range-diff=$prev \
747
main..unmodified >actual &&
747
- test_when_finished "rm 000?-*" &&
748
test_line_count = 5 actual &&
749
test_grep "^Range-diff:$" 0000-* &&
750
grep "= 1: .* s/5/A" 0000-* &&
767
'
768
769
test_expect_success 'format-patch --range-diff with format.notes config' '
770
+ test_when_finished "git notes remove topic unmodified || :" &&
771
git notes add -m "topic note" topic &&
772
git notes add -m "unmodified note" unmodified &&
772
- test_when_finished git notes remove topic unmodified &&
773
test_config format.notes true &&
774
+ test_when_finished "rm -f 000?-*" &&
775
git format-patch --cover-letter --range-diff=$prev \
776
main..unmodified >actual &&
776
- test_when_finished "rm 000?-*" &&
777
test_line_count = 5 actual &&
778
test_grep "^Range-diff:$" 0000-* &&
779
grep "= 1: .* s/5/A" 0000-* &&
796
'
797
798
test_expect_success 'format-patch --range-diff with multiple notes' '
799
+ test_when_finished "git notes --ref=note1 remove topic unmodified || :" &&
800
git notes --ref=note1 add -m "topic note1" topic &&
801
git notes --ref=note1 add -m "unmodified note1" unmodified &&
801
- test_when_finished git notes --ref=note1 remove topic unmodified &&
802
+ test_when_finished "git notes --ref=note2 remove topic unmodified || :" &&
803
git notes --ref=note2 add -m "topic note2" topic &&
804
git notes --ref=note2 add -m "unmodified note2" unmodified &&
804
- test_when_finished git notes --ref=note2 remove topic unmodified &&
805
+ test_when_finished "rm -f 000?-*" &&
806
git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \
807
main..unmodified >actual &&
807
- test_when_finished "rm 000?-*" &&
808
test_line_count = 5 actual &&
809
test_grep "^Range-diff:$" 0000-* &&
810
grep "= 1: .* s/5/A" 0000-* &&