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
Elijah Newren <newren@gmail.com>
Date
Feb 24, 2021, 04:24 UTC
Message-ID
<CABPp-BFa3CnOHMg4t99xMHWif8kMZJFcmHtLSNxZgAPaw1Cd=Q@mail.gmail.com>
In-Reply-To
<YDQ27qbbblPfLCpU@coredump.intra.peff.net>

On Mon, Feb 22, 2021 at 3:03 PM Jeff King <peff@peff.net> wrote: [...snip...]

Show 16 quoted lines
>
> 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!).
>
> 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.
Are you referring to something like this (in the git.git repository)?

$ git show --oneline --remerge-diff 42342b3ee6 42342b3ee6 Merge branch 'ab/mailmap'

diff --git a/t/t4203-mailmap.sh b/t/t4203-mailmap.sh
index 1bce961e07..6fb18a34b0 100755
--- a/t/t4203-mailmap.sh
+++ b/t/t4203-mailmap.sh
@@ -257,16 +257,8 @@ test_expect_success 'No mailmap files, but configured' '

 test_expect_success 'setup mailmap blob tests' '
        git checkout -b map &&
-<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< 60ecad090d (Merge branch 'ps/fetch-atomic')
        test_when_finished "git checkout main" &&
-       cat >just-bugs <<- EOF &&
-|||||||||||||||||||||||||||||||| 72c4083ddf
-       test_when_finished "git checkout master" &&
-       cat >just-bugs <<- EOF &&
-================================
-       test_when_finished "git checkout master" &&
        cat >just-bugs <<-\EOF &&
->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4e168333a8 (shortlog: remove
unused(?) "repo-abbrev" feature)
        Blob Guy <bugs@company.xx>
        EOF
        cat >both <<-EOF &&


I agree that representing the conflict done in a merge is more
difficult than it sounds, but if you mean what I think you mean then I
disagree with the "nobody has done it yet" half of your statement.
:-)

That said, I haven't attempted to tie this into format-patch in any
way, and have absolutely no plans to.  (And --remerge-diff hasn't been
submitted upstream, because it depends on ort, and that still needs
reviews...)
Previous: Junio C HamanoNext: Jeff King
Message 9 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.