git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] format-patch: generate valid patch with diff.noprefix config
@ 2020-06-02 20:49 Laurent Arnoud
  2020-06-02 21:12 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Laurent Arnoud @ 2020-06-02 20:49 UTC (permalink / raw)
  To: git

With diff.noprefix enabled the patch generated with format-patch does not
include prefix a/ and b/ so not applicable with `git am`.
Solution is to force a_prefix and b_prefix on diffopt.

Signed-off-by: Laurent Arnoud <laurent@spkdev.net>
---
 builtin/log.c           | 2 ++
 t/t4014-format-patch.sh | 8 ++++++++
 2 files changed, 10 insertions(+)

diff --git a/builtin/log.c b/builtin/log.c
index d104d5c688..ca63f8ceda 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1744,6 +1744,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	rev.diff = 1;
 	rev.max_parents = 1;
 	rev.diffopt.flags.recursive = 1;
+	rev.diffopt.a_prefix = "a/";
+	rev.diffopt.b_prefix = "b/";
 	rev.subject_prefix = fmt_patch_subject_prefix;
 	memset(&s_r_opt, 0, sizeof(s_r_opt));
 	s_r_opt.def = "HEAD";
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index db7e733af9..5d7930e106 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -1602,6 +1602,14 @@ test_expect_success 'format patch ignores color.ui' '
 	test_cmp expect actual
 '
 
+test_expect_success 'format patch ignores diff.noprefix' '
+	test_unconfig diff.noprefix &&
+	git format-patch --stdout -1 >expect &&
+	test_config diff.noprefix true &&
+	git format-patch --stdout -1 >actual &&
+	test_cmp expect actual
+'
+
 test_expect_success 'cover letter with invalid --cover-from-description and config' '
 	test_config branch.rebuild-1.description "config subject
 
-- 
2.27.0.rc2.129.g29f2dd231a

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-04 23:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 20:49 [PATCH] format-patch: generate valid patch with diff.noprefix config Laurent Arnoud
2020-06-02 21:12 ` Junio C Hamano
2020-06-02 21:33   ` Laurent Arnoud
2020-06-02 22:09   ` Junio C Hamano
2020-06-04 19:32     ` Laurent Arnoud
2020-06-04 20:18       ` Junio C Hamano
2020-06-04 23:26         ` Đoàn Trần Công Danh

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).