summaryrefslogtreecommitdiff
path: root/t/t3206-range-diff.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t3206-range-diff.sh')
-rwxr-xr-xt/t3206-range-diff.sh97
1 files changed, 84 insertions, 13 deletions
diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh
index d12e4e4..7b05bf3 100755
--- a/t/t3206-range-diff.sh
+++ b/t/t3206-range-diff.sh
@@ -33,6 +33,26 @@ test_expect_success 'setup' '
u3 sha256:736c4bc
u4 sha256:673e77d
+ # topic (abbrev=10)
+ t1_abbrev sha1:4de457d2c0
+ t2_abbrev sha1:fccce22f8c
+ t3_abbrev sha1:147e64ef53
+ t4_abbrev sha1:a63e992599
+ t1_abbrev sha256:b89f8b9092
+ t2_abbrev sha256:5f12aadf34
+ t3_abbrev sha256:ea8b273a6c
+ t4_abbrev sha256:14b73361fc
+
+ # unmodified (abbrev=10)
+ u1_abbrev sha1:35b9b25f76
+ u2_abbrev sha1:de345ab3de
+ u3_abbrev sha1:9af6654000
+ u4_abbrev sha1:2901f773f3
+ u1_abbrev sha256:e3731be242
+ u2_abbrev sha256:14fadf8cee
+ u3_abbrev sha256:736c4bcb44
+ u4_abbrev sha256:673e77d589
+
# reordered
r1 sha1:aca177a
r2 sha1:14ad629
@@ -153,6 +173,18 @@ test_expect_success 'simple A B C (unmodified)' '
test_cmp expect actual
'
+test_expect_success 'simple A..B A..C (unmodified) with --abbrev' '
+ git range-diff --no-color --abbrev=10 main..topic main..unmodified \
+ >actual &&
+ cat >expect <<-EOF &&
+ 1: $(test_oid t1_abbrev) = 1: $(test_oid u1_abbrev) s/5/A/
+ 2: $(test_oid t2_abbrev) = 2: $(test_oid u2_abbrev) s/4/A/
+ 3: $(test_oid t3_abbrev) = 3: $(test_oid u3_abbrev) s/11/B/
+ 4: $(test_oid t4_abbrev) = 4: $(test_oid u4_abbrev) s/12/B/
+ EOF
+ test_cmp expect actual
+'
+
test_expect_success 'A^! and A^-<n> (unmodified)' '
git range-diff --no-color topic^! unmodified^-1 >actual &&
cat >expect <<-EOF &&
@@ -162,8 +194,8 @@ test_expect_success 'A^! and A^-<n> (unmodified)' '
'
test_expect_success 'A^{/..} is not mistaken for a range' '
- test_must_fail git range-diff topic^.. topic^{/..} 2>error &&
- test_i18ngrep "not a commit range" error
+ test_must_fail git range-diff topic^.. topic^{/..} -- 2>error &&
+ test_grep "not a commit range" error
'
test_expect_success 'trivial reordering' '
@@ -505,7 +537,7 @@ do
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
- test_i18ngrep "^Range-diff:$" 0000-* &&
+ test_grep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
@@ -517,7 +549,7 @@ test_expect_success 'format-patch --range-diff as commentary' '
git format-patch --range-diff=HEAD~1 HEAD~1 >actual &&
test_when_finished "rm 0001-*" &&
test_line_count = 1 actual &&
- test_i18ngrep "^Range-diff:$" 0001-* &&
+ test_grep "^Range-diff:$" 0001-* &&
grep "> 1: .* new message" 0001-*
'
@@ -525,7 +557,7 @@ test_expect_success 'format-patch --range-diff reroll-count with a non-integer'
git format-patch --range-diff=HEAD~1 -v2.9 HEAD~1 >actual &&
test_when_finished "rm v2.9-0001-*" &&
test_line_count = 1 actual &&
- test_i18ngrep "^Range-diff:$" v2.9-0001-* &&
+ test_grep "^Range-diff:$" v2.9-0001-* &&
grep "> 1: .* new message" v2.9-0001-*
'
@@ -533,7 +565,7 @@ test_expect_success 'format-patch --range-diff reroll-count with a integer' '
git format-patch --range-diff=HEAD~1 -v2 HEAD~1 >actual &&
test_when_finished "rm v2-0001-*" &&
test_line_count = 1 actual &&
- test_i18ngrep "^Range-diff ..* v1:$" v2-0001-* &&
+ test_grep "^Range-diff ..* v1:$" v2-0001-* &&
grep "> 1: .* new message" v2-0001-*
'
@@ -541,7 +573,7 @@ test_expect_success 'format-patch --range-diff with v0' '
git format-patch --range-diff=HEAD~1 -v0 HEAD~1 >actual &&
test_when_finished "rm v0-0001-*" &&
test_line_count = 1 actual &&
- test_i18ngrep "^Range-diff:$" v0-0001-* &&
+ test_grep "^Range-diff:$" v0-0001-* &&
grep "> 1: .* new message" v0-0001-*
'
@@ -630,6 +662,20 @@ test_expect_success 'range-diff with multiple --notes' '
test_cmp expect actual
'
+# `range-diff` should act like `log` with regards to notes
+test_expect_success 'range-diff with --notes=custom does not show default notes' '
+ git notes add -m "topic note" topic &&
+ git notes add -m "unmodified note" unmodified &&
+ git notes --ref=custom add -m "topic note" topic &&
+ git notes --ref=custom add -m "unmodified note" unmodified &&
+ test_when_finished git notes remove topic unmodified &&
+ test_when_finished git notes --ref=custom remove topic unmodified &&
+ git range-diff --notes=custom main..topic main..unmodified \
+ >actual &&
+ ! grep "## Notes ##" actual &&
+ grep "## Notes (custom) ##" actual
+'
+
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 &&
@@ -638,7 +684,7 @@ test_expect_success 'format-patch --range-diff does not compare notes by default
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
- test_i18ngrep "^Range-diff:$" 0000-* &&
+ test_grep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
@@ -647,6 +693,20 @@ test_expect_success 'format-patch --range-diff does not compare notes by default
! grep "note" 0000-*
'
+test_expect_success 'format-patch --notes=custom --range-diff only compares custom notes' '
+ git notes add -m "topic note" topic &&
+ git notes --ref=custom add -m "topic note (custom)" topic &&
+ git notes add -m "unmodified note" unmodified &&
+ git notes --ref=custom add -m "unmodified note (custom)" unmodified &&
+ test_when_finished git notes remove topic unmodified &&
+ test_when_finished git notes --ref=custom remove topic unmodified &&
+ git format-patch --notes=custom --cover-letter --range-diff=$prev \
+ main..unmodified >actual &&
+ test_when_finished "rm 000?-*" &&
+ grep "## Notes (custom) ##" 0000-* &&
+ ! grep "## Notes ##" 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 &&
@@ -655,7 +715,7 @@ test_expect_success 'format-patch --range-diff with --no-notes' '
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
- test_i18ngrep "^Range-diff:$" 0000-* &&
+ test_grep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
@@ -672,7 +732,7 @@ test_expect_success 'format-patch --range-diff with --notes' '
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
- test_i18ngrep "^Range-diff:$" 0000-* &&
+ test_grep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
@@ -701,7 +761,7 @@ test_expect_success 'format-patch --range-diff with format.notes config' '
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
- test_i18ngrep "^Range-diff:$" 0000-* &&
+ test_grep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
@@ -732,7 +792,7 @@ test_expect_success 'format-patch --range-diff with multiple notes' '
main..unmodified >actual &&
test_when_finished "rm 000?-*" &&
test_line_count = 5 actual &&
- test_i18ngrep "^Range-diff:$" 0000-* &&
+ test_grep "^Range-diff:$" 0000-* &&
grep "= 1: .* s/5/A" 0000-* &&
grep "= 2: .* s/4/A" 0000-* &&
grep "= 3: .* s/11/B" 0000-* &&
@@ -772,6 +832,17 @@ test_expect_success '--left-only/--right-only' '
test_cmp expect actual
'
+test_expect_success 'ranges with pathspecs' '
+ git range-diff topic...mode-only-change -- other-file >actual &&
+ test_line_count = 2 actual &&
+ topic_oid=$(git rev-parse --short topic) &&
+ mode_change_oid=$(git rev-parse --short mode-only-change^) &&
+ file_change_oid=$(git rev-parse --short mode-only-change) &&
+ grep "$mode_change_oid" actual &&
+ ! grep "$file_change_oid" actual &&
+ ! grep "$topic_oid" actual
+'
+
test_expect_success 'submodule changes are shown irrespective of diff.submodule' '
git init sub-repo &&
test_commit -C sub-repo sub-first &&
@@ -782,7 +853,7 @@ test_expect_success 'submodule changes are shown irrespective of diff.submodule'
sub_oid3=$(git -C sub-repo rev-parse HEAD) &&
git checkout -b main-sub topic &&
- git submodule add ./sub-repo sub &&
+ git -c protocol.file.allow=always submodule add ./sub-repo sub &&
git -C sub checkout --detach sub-first &&
git commit -m "add sub" sub &&
sup_oid1=$(git rev-parse --short HEAD) &&