From: Dominique Martinet <asmadeus@codewreck.org>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
"René Scharfe" <l.s.r@web.de>,
"Dominique Martinet" <asmadeus@codewreck.org>,
"Julien Moutinho" <julm@sourcephile.fr>
Subject: [RFC PATCH] builtin/format-patch: print a warning for skipped merge commits?
Date: Wed, 31 Dec 2025 12:42:17 +0900 [thread overview]
Message-ID: <20251231034217.2498648-1-asmadeus@codewreck.org> (raw)
Git format-patch historically silently ignores merge commits, because
a merge commit simply cannot be fully described by a simple patch.
This can be surprising for users, especially when coupled with newer
merge-heavy workflows such as encouraged by jj: trying to generate a
patch from a jj commit that was a git merge with "content" will not
generate anything, without any message.
This RFC patch illustrates how we could easily print a warning, but
perhaps the warning would only make sense if no other commit has been
formatted?
I don't think it hurts all that much to print all the time but I can see
it being annoying in some use-cases, so it'd likely deserve a config
knob if we inconditionally print that...
Also perhaps pretty-printing the merge commit a bit better like printing
the subject...
Please let me know what you think would make sense here and I'll send a
more proper patch (tests..)
Thanks!
Reported-by: Julien Moutinho <julm@sourcephile.fr>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
builtin/log.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/builtin/log.c b/builtin/log.c
index d4cf9c59c81a..b21274461cd3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -2044,7 +2044,6 @@ int cmd_format_patch(int argc,
rev.expand_tabs_in_log_default = 0;
rev.verbose_header = 1;
rev.diff = 1;
- rev.max_parents = 1;
rev.diffopt.flags.recursive = 1;
rev.diffopt.no_free = 1;
memset(&s_r_opt, 0, sizeof(s_r_opt));
@@ -2274,6 +2273,11 @@ int cmd_format_patch(int argc,
die(_("revision walk setup failed"));
rev.boundary = 1;
while ((commit = get_revision(&rev)) != NULL) {
+ if (commit->parents->next) {
+ warning(_("skipped merge commit %s"),
+ oid_to_hex(&commit->object.oid));
+ continue;
+ }
if (commit->object.flags & BOUNDARY) {
boundary_count++;
origin = (boundary_count == 1) ? commit : NULL;
--
2.52.0
next reply other threads:[~2025-12-31 3:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-31 3:42 Dominique Martinet [this message]
2025-12-31 5:12 ` [RFC PATCH] builtin/format-patch: print a warning for skipped merge commits? Junio C Hamano
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=20251231034217.2498648-1-asmadeus@codewreck.org \
--to=asmadeus@codewreck.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=julm@sourcephile.fr \
--cc=l.s.r@web.de \
/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).