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
This commit is contained in:
Junio C Hamano 2024-06-20 15:45:12 -07:00
commit 9071453ef6
3 changed files with 36 additions and 5 deletions

View file

@ -2382,6 +2382,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (cover_letter == -1) {
if (cfg.config_cover_letter == COVER_AUTO)
cover_letter = (total > 1);
else if ((idiff_prev.nr || rdiff_prev) && (total > 1))
cover_letter = (cfg.config_cover_letter != COVER_OFF);
else
cover_letter = (cfg.config_cover_letter == COVER_ON);
}

View file

@ -545,6 +545,20 @@ do
'
done
test_expect_success "--range-diff implies --cover-letter for multi-patch series" '
test_when_finished "rm -f v2-000?-*" &&
git format-patch -v2 --range-diff=topic main..unmodified &&
test_grep "^Range-diff against v1:$" v2-0000-cover-letter.patch
'
test_expect_success "explicit --no-cover-letter defeats implied --cover-letter" '
test_when_finished "rm -f v2-000?-*" &&
test_must_fail git format-patch --no-cover-letter \
-v2 --range-diff=topic main..unmodified &&
test_must_fail git -c format.coverLetter=no format-patch \
-v2 --range-diff=topic main..unmodified
'
test_expect_success 'format-patch --range-diff as commentary' '
git format-patch --range-diff=HEAD~1 HEAD~1 >actual &&
test_when_finished "rm 0001-*" &&

View file

@ -820,8 +820,8 @@ test_expect_success 'format-patch --notes --signoff' '
'
test_expect_success 'format-patch notes output control' '
test_when_finished "git notes remove HEAD || :" &&
git notes add -m "notes config message" HEAD &&
test_when_finished git notes remove HEAD &&
git format-patch -1 --stdout >out &&
! grep "notes config message" out &&
@ -848,10 +848,10 @@ test_expect_success 'format-patch notes output control' '
'
test_expect_success 'format-patch with multiple notes refs' '
test_when_finished "git notes --ref note1 remove HEAD;
git notes --ref note2 remove HEAD || :" &&
git notes --ref note1 add -m "this is note 1" HEAD &&
test_when_finished git notes --ref note1 remove HEAD &&
git notes --ref note2 add -m "this is note 2" HEAD &&
test_when_finished git notes --ref note2 remove HEAD &&
git format-patch -1 --stdout >out &&
! grep "this is note 1" out &&
@ -892,10 +892,10 @@ test_expect_success 'format-patch with multiple notes refs' '
test_expect_success 'format-patch with multiple notes refs in config' '
test_when_finished "test_unconfig format.notes" &&
test_when_finished "git notes --ref note1 remove HEAD;
git notes --ref note2 remove HEAD || :" &&
git notes --ref note1 add -m "this is note 1" HEAD &&
test_when_finished git notes --ref note1 remove HEAD &&
git notes --ref note2 add -m "this is note 2" HEAD &&
test_when_finished git notes --ref note2 remove HEAD &&
git config format.notes note1 &&
git format-patch -1 --stdout >out &&
@ -2516,6 +2516,21 @@ test_expect_success 'range-diff: solo-patch' '
test_cmp expect actual
'
test_expect_success 'interdiff: multi-patch, implicit --cover-letter' '
test_when_finished "rm -f v23-0*.patch" &&
git format-patch --interdiff=boop~2 -2 -v23 &&
test_grep "^Interdiff against v22:$" v23-0000-cover-letter.patch &&
test_cmp expect actual
'
test_expect_success 'interdiff: explicit --no-cover-letter defeats implied --cover-letter' '
test_when_finished "rm -f v23-0*.patch" &&
test_must_fail git format-patch --no-cover-letter \
--interdiff=boop~2 -2 -v23 &&
test_must_fail git -c format.coverLetter=no format-patch \
--interdiff=boop~2 -2 -v23
'
test_expect_success 'format-patch does not respect diff.noprefix' '
git -c diff.noprefix format-patch -1 --stdout >actual &&
grep "^--- a/blorp" actual