mirror of
https://github.com/git/git
synced 2024-08-28 12:09:19 +00:00
Merge branch 'rs/format-patch-pathspec-fix' into maint
"git format-patch <args> -- <pathspec>" lost the pathspec when showing the second and subsequent commits, which has been corrected. source: <c36896a1-6247-123b-4fa3-b7eb24af1897@web.de> * rs/format-patch-pathspec-fix: 2.36 format-patch regression fix
This commit is contained in:
commit
676cead455
|
@ -1896,6 +1896,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||||
rev.diff = 1;
|
rev.diff = 1;
|
||||||
rev.max_parents = 1;
|
rev.max_parents = 1;
|
||||||
rev.diffopt.flags.recursive = 1;
|
rev.diffopt.flags.recursive = 1;
|
||||||
|
rev.diffopt.no_free = 1;
|
||||||
rev.subject_prefix = fmt_patch_subject_prefix;
|
rev.subject_prefix = fmt_patch_subject_prefix;
|
||||||
memset(&s_r_opt, 0, sizeof(s_r_opt));
|
memset(&s_r_opt, 0, sizeof(s_r_opt));
|
||||||
s_r_opt.def = "HEAD";
|
s_r_opt.def = "HEAD";
|
||||||
|
@ -2021,13 +2022,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
if (use_stdout) {
|
if (use_stdout) {
|
||||||
setup_pager();
|
setup_pager();
|
||||||
} else if (rev.diffopt.close_file) {
|
} else if (!rev.diffopt.close_file) {
|
||||||
/*
|
|
||||||
* The diff code parsed --output; it has already opened the
|
|
||||||
* file, but we must instruct it not to close after each diff.
|
|
||||||
*/
|
|
||||||
rev.diffopt.no_free = 1;
|
|
||||||
} else {
|
|
||||||
int saved;
|
int saved;
|
||||||
|
|
||||||
if (!output_directory)
|
if (!output_directory)
|
||||||
|
|
|
@ -926,11 +926,40 @@ test_expect_success 'format-patch --numstat should produce a patch' '
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'format-patch -- <path>' '
|
test_expect_success 'format-patch -- <path>' '
|
||||||
git format-patch main..side -- file 2>error &&
|
rm -f *.patch &&
|
||||||
! grep "Use .--" error
|
git checkout -b pathspec main &&
|
||||||
|
|
||||||
|
echo file_a 1 >file_a &&
|
||||||
|
echo file_b 1 >file_b &&
|
||||||
|
git add file_a file_b &&
|
||||||
|
git commit -m pathspec_initial &&
|
||||||
|
|
||||||
|
echo file_a 2 >>file_a &&
|
||||||
|
git add file_a &&
|
||||||
|
git commit -m pathspec_a &&
|
||||||
|
|
||||||
|
echo file_b 2 >>file_b &&
|
||||||
|
git add file_b &&
|
||||||
|
git commit -m pathspec_b &&
|
||||||
|
|
||||||
|
echo file_a 3 >>file_a &&
|
||||||
|
echo file_b 3 >>file_b &&
|
||||||
|
git add file_a file_b &&
|
||||||
|
git commit -m pathspec_ab &&
|
||||||
|
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
0001-pathspec_initial.patch
|
||||||
|
0002-pathspec_a.patch
|
||||||
|
0003-pathspec_ab.patch
|
||||||
|
EOF
|
||||||
|
|
||||||
|
git format-patch main..pathspec -- file_a >output &&
|
||||||
|
test_cmp expect output &&
|
||||||
|
! grep file_b *.patch
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
|
test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
|
||||||
|
git checkout side &&
|
||||||
git format-patch --ignore-if-in-upstream HEAD
|
git format-patch --ignore-if-in-upstream HEAD
|
||||||
'
|
'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue