mirror of
https://github.com/git/git.git
synced 2026-04-10 00:40:14 +02:00
Merge branch 'dl/range-diff-with-notes'
"git range-diff" learned to take the "--notes=<ref>" and the "--no-notes" options to control the commit notes included in the log message that gets compared. * dl/range-diff-with-notes: format-patch: pass notes configuration to range-diff range-diff: pass through --notes to `git log` range-diff: output `## Notes ##` header t3206: range-diff compares logs with commit notes t3206: s/expected/expect/ t3206: disable parameter substitution in heredoc t3206: remove spaces after redirect operators pretty-options.txt: --notes accepts a ref instead of treeish rev-list-options.txt: remove reference to --show-notes argv-array: add space after `while`
This commit is contained in:
@@ -8,8 +8,8 @@ test_description='range-diff tests'
|
||||
# harm than good. We need some real history.
|
||||
|
||||
test_expect_success 'setup' '
|
||||
git fast-import < "$TEST_DIRECTORY"/t3206/history.export &&
|
||||
test_oid_cache <<-EOF
|
||||
git fast-import <"$TEST_DIRECTORY"/t3206/history.export &&
|
||||
test_oid_cache <<-\EOF
|
||||
# topic
|
||||
t1 sha1:4de457d
|
||||
t2 sha1:fccce22
|
||||
@@ -121,88 +121,88 @@ test_expect_success 'setup' '
|
||||
test_expect_success 'simple A..B A..C (unmodified)' '
|
||||
git range-diff --no-color master..topic master..unmodified \
|
||||
>actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
|
||||
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
|
||||
4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'simple B...C (unmodified)' '
|
||||
git range-diff --no-color topic...unmodified >actual &&
|
||||
# same "expected" as above
|
||||
test_cmp expected actual
|
||||
# same "expect" as above
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'simple A B C (unmodified)' '
|
||||
git range-diff --no-color master topic unmodified >actual &&
|
||||
# same "expected" as above
|
||||
test_cmp expected actual
|
||||
# same "expect" as above
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'trivial reordering' '
|
||||
git range-diff --no-color master topic reordered >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid r1) s/5/A/
|
||||
3: $(test_oid t3) = 2: $(test_oid r2) s/11/B/
|
||||
4: $(test_oid t4) = 3: $(test_oid r3) s/12/B/
|
||||
2: $(test_oid t2) = 4: $(test_oid r4) s/4/A/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'removed a commit' '
|
||||
git range-diff --no-color master topic removed >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid d1) s/5/A/
|
||||
2: $(test_oid t2) < -: $(test_oid __) s/4/A/
|
||||
3: $(test_oid t3) = 2: $(test_oid d2) s/11/B/
|
||||
4: $(test_oid t4) = 3: $(test_oid d3) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'added a commit' '
|
||||
git range-diff --no-color master topic added >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid a1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid a2) s/4/A/
|
||||
-: $(test_oid __) > 3: $(test_oid a3) s/6/A/
|
||||
3: $(test_oid t3) = 4: $(test_oid a4) s/11/B/
|
||||
4: $(test_oid t4) = 5: $(test_oid a5) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'new base, A B C' '
|
||||
git range-diff --no-color master topic rebased >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid b1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid b2) s/4/A/
|
||||
3: $(test_oid t3) = 3: $(test_oid b3) s/11/B/
|
||||
4: $(test_oid t4) = 4: $(test_oid b4) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'new base, B...C' '
|
||||
# this syntax includes the commits from master!
|
||||
git range-diff --no-color topic...rebased >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
-: $(test_oid __) > 1: $(test_oid b5) unrelated
|
||||
1: $(test_oid t1) = 2: $(test_oid b1) s/5/A/
|
||||
2: $(test_oid t2) = 3: $(test_oid b2) s/4/A/
|
||||
3: $(test_oid t3) = 4: $(test_oid b3) s/11/B/
|
||||
4: $(test_oid t4) = 5: $(test_oid b4) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'changed commit' '
|
||||
git range-diff --no-color topic...changed >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
|
||||
3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
|
||||
@@ -226,23 +226,23 @@ test_expect_success 'changed commit' '
|
||||
+B
|
||||
13
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'changed commit with --no-patch diff option' '
|
||||
git range-diff --no-color --no-patch topic...changed >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
|
||||
3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
|
||||
4: $(test_oid t4) ! 4: $(test_oid c4) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'changed commit with --stat diff option' '
|
||||
git range-diff --no-color --stat topic...changed >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
|
||||
a => b | 0
|
||||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
@@ -256,12 +256,12 @@ test_expect_success 'changed commit with --stat diff option' '
|
||||
a => b | 0
|
||||
1 file changed, 0 insertions(+), 0 deletions(-)
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'changed commit with sm config' '
|
||||
git range-diff --no-color --submodule=log topic...changed >actual &&
|
||||
cat >expected <<-EOF &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid c1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid c2) s/4/A/
|
||||
3: $(test_oid t3) ! 3: $(test_oid c3) s/11/B/
|
||||
@@ -285,12 +285,12 @@ test_expect_success 'changed commit with sm config' '
|
||||
+B
|
||||
13
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'renamed file' '
|
||||
git range-diff --no-color --submodule=log topic...renamed-file >actual &&
|
||||
sed s/Z/\ /g >expected <<-EOF &&
|
||||
sed s/Z/\ /g >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid n1) s/5/A/
|
||||
2: $(test_oid t2) ! 2: $(test_oid n2) s/4/A/
|
||||
@@ Metadata
|
||||
@@ -330,12 +330,12 @@ test_expect_success 'renamed file' '
|
||||
Z 10
|
||||
Z B
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'file with mode only change' '
|
||||
git range-diff --no-color --submodule=log topic...mode-only-change >actual &&
|
||||
sed s/Z/\ /g >expected <<-EOF &&
|
||||
sed s/Z/\ /g >expect <<-EOF &&
|
||||
1: fccce22 ! 1: 4d39cb3 s/4/A/
|
||||
@@ Metadata
|
||||
ZAuthor: Thomas Rast <trast@inf.ethz.ch>
|
||||
@@ -370,12 +370,12 @@ test_expect_success 'file with mode only change' '
|
||||
+ ## other-file (mode change 100644 => 100755) ##
|
||||
3: a63e992 = 3: 4c1e0f5 s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'file added and later removed' '
|
||||
git range-diff --no-color --submodule=log topic...added-removed >actual &&
|
||||
sed s/Z/\ /g >expected <<-EOF &&
|
||||
sed s/Z/\ /g >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid s1) s/5/A/
|
||||
2: $(test_oid t2) ! 2: $(test_oid s2) s/4/A/
|
||||
@@ Metadata
|
||||
@@ -411,7 +411,7 @@ test_expect_success 'file added and later removed' '
|
||||
+ ## new-file (deleted) ##
|
||||
4: $(test_oid t4) = 4: $(test_oid s4) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'no commits on one side' '
|
||||
@@ -421,7 +421,7 @@ test_expect_success 'no commits on one side' '
|
||||
|
||||
test_expect_success 'changed message' '
|
||||
git range-diff --no-color topic...changed-message >actual &&
|
||||
sed s/Z/\ /g >expected <<-EOF &&
|
||||
sed s/Z/\ /g >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid m1) s/5/A/
|
||||
2: $(test_oid t2) ! 2: $(test_oid m2) s/4/A/
|
||||
@@ Metadata
|
||||
@@ -436,7 +436,7 @@ test_expect_success 'changed message' '
|
||||
3: $(test_oid t3) = 3: $(test_oid m3) s/11/B/
|
||||
4: $(test_oid t4) = 4: $(test_oid m4) s/12/B/
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'dual-coloring' '
|
||||
@@ -505,4 +505,202 @@ test_expect_success 'range-diff overrides diff.noprefix internally' '
|
||||
git -c diff.noprefix=true range-diff HEAD^...
|
||||
'
|
||||
|
||||
test_expect_success 'range-diff compares 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 &&
|
||||
git range-diff --no-color master..topic master..unmodified \
|
||||
>actual &&
|
||||
sed s/Z/\ /g >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
|
||||
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
|
||||
4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
|
||||
@@ Commit message
|
||||
Z
|
||||
Z
|
||||
Z ## Notes ##
|
||||
- topic note
|
||||
+ unmodified note
|
||||
Z
|
||||
Z ## file ##
|
||||
Z@@ file: A
|
||||
EOF
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success '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 range-diff --no-color --no-notes master..topic master..unmodified \
|
||||
>actual &&
|
||||
cat >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
|
||||
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
|
||||
4: $(test_oid t4) = 4: $(test_oid u4) s/12/B/
|
||||
EOF
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success '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 range-diff --no-color --notes=note1 --notes=note2 master..topic master..unmodified \
|
||||
>actual &&
|
||||
sed s/Z/\ /g >expect <<-EOF &&
|
||||
1: $(test_oid t1) = 1: $(test_oid u1) s/5/A/
|
||||
2: $(test_oid t2) = 2: $(test_oid u2) s/4/A/
|
||||
3: $(test_oid t3) = 3: $(test_oid u3) s/11/B/
|
||||
4: $(test_oid t4) ! 4: $(test_oid u4) s/12/B/
|
||||
@@ 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
|
||||
test_cmp expect 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 &&
|
||||
test_when_finished git notes remove topic unmodified &&
|
||||
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-* &&
|
||||
! 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
|
||||
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 --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
|
||||
|
||||
Reference in New Issue
Block a user