Git fork

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

+33 -9
+2 -7
builtin/log.c
··· 1896 1896 rev.diff = 1; 1897 1897 rev.max_parents = 1; 1898 1898 rev.diffopt.flags.recursive = 1; 1899 + rev.diffopt.no_free = 1; 1899 1900 rev.subject_prefix = fmt_patch_subject_prefix; 1900 1901 memset(&s_r_opt, 0, sizeof(s_r_opt)); 1901 1902 s_r_opt.def = "HEAD"; ··· 2021 2022 2022 2023 if (use_stdout) { 2023 2024 setup_pager(); 2024 - } else if (rev.diffopt.close_file) { 2025 - /* 2026 - * The diff code parsed --output; it has already opened the 2027 - * file, but we must instruct it not to close after each diff. 2028 - */ 2029 - rev.diffopt.no_free = 1; 2030 - } else { 2025 + } else if (!rev.diffopt.close_file) { 2031 2026 int saved; 2032 2027 2033 2028 if (!output_directory)
+31 -2
t/t4014-format-patch.sh
··· 926 926 ' 927 927 928 928 test_expect_success 'format-patch -- <path>' ' 929 - git format-patch main..side -- file 2>error && 930 - ! grep "Use .--" error 929 + rm -f *.patch && 930 + git checkout -b pathspec main && 931 + 932 + echo file_a 1 >file_a && 933 + echo file_b 1 >file_b && 934 + git add file_a file_b && 935 + git commit -m pathspec_initial && 936 + 937 + echo file_a 2 >>file_a && 938 + git add file_a && 939 + git commit -m pathspec_a && 940 + 941 + echo file_b 2 >>file_b && 942 + git add file_b && 943 + git commit -m pathspec_b && 944 + 945 + echo file_a 3 >>file_a && 946 + echo file_b 3 >>file_b && 947 + git add file_a file_b && 948 + git commit -m pathspec_ab && 949 + 950 + cat >expect <<-\EOF && 951 + 0001-pathspec_initial.patch 952 + 0002-pathspec_a.patch 953 + 0003-pathspec_ab.patch 954 + EOF 955 + 956 + git format-patch main..pathspec -- file_a >output && 957 + test_cmp expect output && 958 + ! grep file_b *.patch 931 959 ' 932 960 933 961 test_expect_success 'format-patch --ignore-if-in-upstream HEAD' ' 962 + git checkout side && 934 963 git format-patch --ignore-if-in-upstream HEAD 935 964 ' 936 965