git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git format-patch lost the last part when branch merge

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 22, 2021, 23:25 UTC
Message-ID
<xmqqzgzv65y6.fsf@gitster.g>
In-Reply-To
<YDQ27qbbblPfLCpU@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 14 quoted lines
> 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
> output!).

Yes, a first-parent diff is something you could call "a simple diff that can be applied to represent a merge", and it is consistent with the expectations of those who are used to do a squash (pseudo-)merge.

I agree with you that it does not make sense to apply such a patch as a patch, of course. In addition to be redundant, it would be an equivalent of doing a squash (psuedo-)merge, and loses the "up to this point the side branch has been merged, so future merges won't have to look beyond this point in the past" (sort of going back to the prehistoric subversion days that did not keep track of which changes have been merged).

Previous: Jeff KingNext: Elijah Newren
Message 8 of 10 in “git format-patch lost the last part when branch merge”
  1. Wang YuguiFeb 22, 2021
  2. Jeff KingFeb 22, 2021
  3. docs/format-patch: mention handling of mergesJeff King, Feb 22, 2021
  4. Junio C HamanoFeb 22, 2021
  5. Jeff KingFeb 22, 2021
  6. Junio C HamanoFeb 23, 2021
  7. Jeff KingFeb 23, 2021
  8. Junio C HamanoFeb 22, 2021
  9. Elijah NewrenFeb 24, 2021
  10. Jeff KingFeb 24, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.