mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <>
To: Wang Yugui <>
Subject: Re: git format-patch lost the last part when branch merge
Date: Mon, 22 Feb 2021 17:57:50 -0500	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Mon, Feb 22, 2021 at 09:16:21PM +0800, Wang Yugui wrote:

> git format-patch lost the last part when branch merge
> Here is an example.
> Merge tag 'for-5.12/block-2021-02-17' of git://
> 1, from the web interface,
> the last part 'diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c' can be confirmed.
> 2, but from ' commit | 582cd91f69de8e44857cb610ebca661dac8656b7 (patch)' of this web page,
> the last part 'diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c' is not in the patch file.
> 3, git format-patch 4f016a316f22.. fs/btrfs/ will not output 'diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c' too.

This is expected. Format-patch omits merge commits entirely, as they
can't be formatted as a simple diff that can be applied.

There are lots of ways to look at the diff of a merge. By default, `git
show` will show a combined diff, which omits hunks where one side was
taken verbatim, but otherwise shows what each side did.

The diff shown in the link above is a diff against the first-parent
(which you can also get locally with `git show --first-parent 582cd91`).
One _could_ apply that diff onto the first parent to achieve the same
tree as the merge plus all of the commits that got merged in. But it
wouldn't make any sense to apply that (aside from conflict resolution,
it would be redundant with all of the commits that format-patch just

You could imagine ways for format-patch to represent the conflict
resolution done in a merge, but it's not quite trivial, and nobody has
done it yet.

Depending on why you're using format-patch, the solution may be one of:

  - use "git log --cc" instead, which shows the merges using combined

  - use "git bundle" instead, which reproduces the whole history graph,
    including merges (though obviously you cannot then re-apply the
    commits onto a different history)


  reply	other threads:[~2021-02-22 23:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 13:16 git format-patch lost the last part when branch merge Wang Yugui
2021-02-22 22:57 ` Jeff King [this message]
2021-02-22 23:08   ` [PATCH] docs/format-patch: mention handling of merges Jeff King
2021-02-22 23:31     ` Junio C Hamano
2021-02-22 23:40       ` Jeff King
2021-02-23  1:24         ` Junio C Hamano
2021-02-23  1:48           ` Jeff King
2021-02-22 23:25   ` git format-patch lost the last part when branch merge Junio C Hamano
2021-02-24  4:24   ` Elijah Newren
2021-02-24  4:50     ` Jeff King

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:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* 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.
Code repositories for project(s) associated with this public inbox

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).