From: Laurent Arnoud <laurent@spkdev.net>
To: git@vger.kernel.org
Subject: [PATCH] format-patch: generate valid patch with diff.noprefix config
Date: Tue, 2 Jun 2020 22:49:24 +0200 [thread overview]
Message-ID: <20200602204924.GA1853335@spk-laptop> (raw)
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
next reply other threads:[~2020-06-02 20:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 20:49 Laurent Arnoud [this message]
2020-06-02 21:12 ` [PATCH] format-patch: generate valid patch with diff.noprefix config 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200602204924.GA1853335@spk-laptop \
--to=laurent@spkdev.net \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).