summaryrefslogtreecommitdiff
path: root/t/t3206-range-diff.sh
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2019-11-20 21:18:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-11-21 00:29:52 (GMT)
commit5b583e6a09dc2095160a4489502577a5a20b400e (patch)
tree43cca1da42f258d31e0ebbd842087171df5acc38 /t/t3206-range-diff.sh
parentbd361918868284c06a438b832dbc95e11266fd5b (diff)
downloadgit-5b583e6a09dc2095160a4489502577a5a20b400e.zip
git-5b583e6a09dc2095160a4489502577a5a20b400e.tar.gz
git-5b583e6a09dc2095160a4489502577a5a20b400e.tar.bz2
format-patch: pass notes configuration to range-diff
Since format-patch accepts `--[no-]notes`, one would expect the range-diff generated to also respect the setting. Unfortunately, the range-diff we currently generate only uses the default option (which always outputs default notes, even when notes are not being used elsewhere). Pass the notes configuration to range-diff so that it can honor it. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3206-range-diff.sh')
-rwxr-xr-xt/t3206-range-diff.sh101
1 files changed, 100 insertions, 1 deletions
diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
index 521b4a8..ec2b456 100755
--- a/t/t3206-range-diff.sh
+++ b/t/t3206-range-diff.sh
@@ -576,7 +576,7 @@ test_expect_success 'range-diff with multiple --notes' '
test_cmp expect actual
'
-test_expect_success 'format-patch --range-diff compares notes by default' '
+test_expect_success 'format-patch --range-diff does not compare notes by default' '
git notes add -m "topic note" topic &&
git notes add -m "unmodified note" unmodified &&
test_when_finished git notes remove topic unmodified &&
@@ -588,6 +588,40 @@ test_expect_success 'format-patch --range-diff compares notes by default' '
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
+ grep "= 4: .* s/12/B" 0000-* &&
+ ! grep "Notes" 0000-* &&
+ ! grep "note" 0000-*
+'
+
+test_expect_success 'format-patch --range-diff with --no-notes' '
+ git notes add -m "topic note" topic &&
+ git notes add -m "unmodified note" unmodified &&
+ test_when_finished git notes remove topic unmodified &&
+ git format-patch --no-notes --cover-letter --range-diff=$prev \
+ master..unmodified >actual &&
+ test_when_finished "rm 000?-*" &&
+ test_line_count = 5 actual &&
+ test_i18ngrep "^Range-diff:$" 0000-* &&
+ grep "= 1: .* s/5/A" 0000-* &&
+ grep "= 2: .* s/4/A" 0000-* &&
+ grep "= 3: .* s/11/B" 0000-* &&
+ grep "= 4: .* s/12/B" 0000-* &&
+ ! grep "Notes" 0000-* &&
+ ! grep "note" 0000-*
+'
+
+test_expect_success 'format-patch --range-diff with --notes' '
+ git notes add -m "topic note" topic &&
+ git notes add -m "unmodified note" unmodified &&
+ test_when_finished git notes remove topic unmodified &&
+ git format-patch --notes --cover-letter --range-diff=$prev \
+ master..unmodified >actual &&
+ test_when_finished "rm 000?-*" &&
+ test_line_count = 5 actual &&
+ test_i18ngrep "^Range-diff:$" 0000-* &&
+ grep "= 1: .* s/5/A" 0000-* &&
+ grep "= 2: .* s/4/A" 0000-* &&
+ grep "= 3: .* s/11/B" 0000-* &&
grep "! 4: .* s/12/B" 0000-* &&
sed s/Z/\ /g >expect <<-EOF &&
@@ Commit message
@@ -604,4 +638,69 @@ test_expect_success 'format-patch --range-diff compares notes by default' '
test_cmp expect actual
'
+test_expect_success 'format-patch --range-diff with --notes' '
+ git notes add -m "topic note" topic &&
+ git notes add -m "unmodified note" unmodified &&
+ test_when_finished git notes remove topic unmodified &&
+ test_config format.notes true &&
+ git format-patch --cover-letter --range-diff=$prev \
+ master..unmodified >actual &&
+ test_when_finished "rm 000?-*" &&
+ test_line_count = 5 actual &&
+ test_i18ngrep "^Range-diff:$" 0000-* &&
+ grep "= 1: .* s/5/A" 0000-* &&
+ grep "= 2: .* s/4/A" 0000-* &&
+ grep "= 3: .* s/11/B" 0000-* &&
+ grep "! 4: .* s/12/B" 0000-* &&
+ sed s/Z/\ /g >expect <<-EOF &&
+ @@ Commit message
+ Z
+ Z
+ Z ## Notes ##
+ - topic note
+ + unmodified note
+ Z
+ Z ## file ##
+ Z@@ file: A
+ EOF
+ sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'format-patch --range-diff with multiple notes' '
+ git notes --ref=note1 add -m "topic note1" topic &&
+ git notes --ref=note1 add -m "unmodified note1" unmodified &&
+ test_when_finished git notes --ref=note1 remove topic unmodified &&
+ git notes --ref=note2 add -m "topic note2" topic &&
+ git notes --ref=note2 add -m "unmodified note2" unmodified &&
+ test_when_finished git notes --ref=note2 remove topic unmodified &&
+ git format-patch --notes=note1 --notes=note2 --cover-letter --range-diff=$prev \
+ master..unmodified >actual &&
+ test_when_finished "rm 000?-*" &&
+ test_line_count = 5 actual &&
+ test_i18ngrep "^Range-diff:$" 0000-* &&
+ grep "= 1: .* s/5/A" 0000-* &&
+ grep "= 2: .* s/4/A" 0000-* &&
+ grep "= 3: .* s/11/B" 0000-* &&
+ grep "! 4: .* s/12/B" 0000-* &&
+ sed s/Z/\ /g >expect <<-EOF &&
+ @@ Commit message
+ Z
+ Z
+ Z ## Notes (note1) ##
+ - topic note1
+ + unmodified note1
+ Z
+ Z
+ Z ## Notes (note2) ##
+ - topic note2
+ + unmodified note2
+ Z
+ Z ## file ##
+ Z@@ file: A
+ EOF
+ sed "/@@ Commit message/,/@@ file: A/!d" 0000-* >actual &&
+ test_cmp expect actual
+'
+
test_done