Skip to content

Commit 9071453

Browse files
committed
Merge branch 'rj/format-patch-auto-cover-with-interdiff'
"git format-patch --interdiff" for multi-patch series learned to turn on cover letters automatically (unless told never to enable cover letter with "--no-cover-letter" and such). * rj/format-patch-auto-cover-with-interdiff: format-patch: assume --cover-letter for diff in multi-patch series t4014: cleanups in a few tests
2 parents 5f14d20 + f96c385 commit 9071453

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

builtin/log.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,6 +2382,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
23822382
if (cover_letter == -1) {
23832383
if (cfg.config_cover_letter == COVER_AUTO)
23842384
cover_letter = (total > 1);
2385+
else if ((idiff_prev.nr || rdiff_prev) && (total > 1))
2386+
cover_letter = (cfg.config_cover_letter != COVER_OFF);
23852387
else
23862388
cover_letter = (cfg.config_cover_letter == COVER_ON);
23872389
}

t/t3206-range-diff.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,20 @@ do
545545
'
546546
done
547547

548+
test_expect_success "--range-diff implies --cover-letter for multi-patch series" '
549+
test_when_finished "rm -f v2-000?-*" &&
550+
git format-patch -v2 --range-diff=topic main..unmodified &&
551+
test_grep "^Range-diff against v1:$" v2-0000-cover-letter.patch
552+
'
553+
554+
test_expect_success "explicit --no-cover-letter defeats implied --cover-letter" '
555+
test_when_finished "rm -f v2-000?-*" &&
556+
test_must_fail git format-patch --no-cover-letter \
557+
-v2 --range-diff=topic main..unmodified &&
558+
test_must_fail git -c format.coverLetter=no format-patch \
559+
-v2 --range-diff=topic main..unmodified
560+
'
561+
548562
test_expect_success 'format-patch --range-diff as commentary' '
549563
git format-patch --range-diff=HEAD~1 HEAD~1 >actual &&
550564
test_when_finished "rm 0001-*" &&

t/t4014-format-patch.sh

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,8 @@ test_expect_success 'format-patch --notes --signoff' '
820820
'
821821

822822
test_expect_success 'format-patch notes output control' '
823+
test_when_finished "git notes remove HEAD || :" &&
823824
git notes add -m "notes config message" HEAD &&
824-
test_when_finished git notes remove HEAD &&
825825
826826
git format-patch -1 --stdout >out &&
827827
! grep "notes config message" out &&
@@ -848,10 +848,10 @@ test_expect_success 'format-patch notes output control' '
848848
'
849849

850850
test_expect_success 'format-patch with multiple notes refs' '
851+
test_when_finished "git notes --ref note1 remove HEAD;
852+
git notes --ref note2 remove HEAD || :" &&
851853
git notes --ref note1 add -m "this is note 1" HEAD &&
852-
test_when_finished git notes --ref note1 remove HEAD &&
853854
git notes --ref note2 add -m "this is note 2" HEAD &&
854-
test_when_finished git notes --ref note2 remove HEAD &&
855855
856856
git format-patch -1 --stdout >out &&
857857
! grep "this is note 1" out &&
@@ -892,10 +892,10 @@ test_expect_success 'format-patch with multiple notes refs' '
892892
test_expect_success 'format-patch with multiple notes refs in config' '
893893
test_when_finished "test_unconfig format.notes" &&
894894
895+
test_when_finished "git notes --ref note1 remove HEAD;
896+
git notes --ref note2 remove HEAD || :" &&
895897
git notes --ref note1 add -m "this is note 1" HEAD &&
896-
test_when_finished git notes --ref note1 remove HEAD &&
897898
git notes --ref note2 add -m "this is note 2" HEAD &&
898-
test_when_finished git notes --ref note2 remove HEAD &&
899899
900900
git config format.notes note1 &&
901901
git format-patch -1 --stdout >out &&
@@ -2516,6 +2516,21 @@ test_expect_success 'range-diff: solo-patch' '
25162516
test_cmp expect actual
25172517
'
25182518

2519+
test_expect_success 'interdiff: multi-patch, implicit --cover-letter' '
2520+
test_when_finished "rm -f v23-0*.patch" &&
2521+
git format-patch --interdiff=boop~2 -2 -v23 &&
2522+
test_grep "^Interdiff against v22:$" v23-0000-cover-letter.patch &&
2523+
test_cmp expect actual
2524+
'
2525+
2526+
test_expect_success 'interdiff: explicit --no-cover-letter defeats implied --cover-letter' '
2527+
test_when_finished "rm -f v23-0*.patch" &&
2528+
test_must_fail git format-patch --no-cover-letter \
2529+
--interdiff=boop~2 -2 -v23 &&
2530+
test_must_fail git -c format.coverLetter=no format-patch \
2531+
--interdiff=boop~2 -2 -v23
2532+
'
2533+
25192534
test_expect_success 'format-patch does not respect diff.noprefix' '
25202535
git -c diff.noprefix format-patch -1 --stdout >actual &&
25212536
grep "^--- a/blorp" actual

0 commit comments

Comments
 (0)