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

Re: git and appending merge commits

From
Junio C Hamano <gitster@pobox.com>
Date
May 26, 2008, 04:59 UTC
Message-ID
<7vej7pek3z.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<483A300E.6090104@zombino.com>
Adam Majer <adamm@zombino.com> writes:
> Is current output by design?

Yes, it is _very much_ by design and it not "messed up" at all. Look at the output of URL you quoted and notice that you are asking for condensed combined diff ("diff --cc").

For a merge commit with N parents, you can define "a diff for the resulting merge commit" in various ways:

 * You could have a set of diffs between each parent to the merge result.
   You can get this with "git diff-tree -p -m $commit".
 * You could say the first parent is special, and define it as the diff
   between its first parent and the merge result.  You can get this by
   asking "git diff $commit^1 $commit".
 * You can say what non-trivial changes the merge itself did.  This is the
   combined merge and what "git show $commit" (and "git log -p") gives.
Depending on what you want, you can ask these various forms of diffs.

When you are reviewing the changes series of commits introduced to the history (iow, "git log -p"), a single diff between parent and the merge result is not so interesting, primarily because each individual change from commits on each side branch is (or should be) much easier to read and understand, but if a merge needed to do something non-trivial to resolve conficts, you would want to know about it, and that is the reason why --cc format is the default.

In a combined diff, unlike the single column to show "+/-/ " at the beginning for one-parent diff, each parent gets one column. And in a condensed combined diff, a hunk whose result is inherited solely from one parent (iow, a trivial conflict resolution) is removed from the output, so that only a non-trivial conflict resolution that leaves result that is different from all parents are shown.

Previous: Shawn O. PearceNext: Adam Majer
Message 3 of 4 in “git and appending merge commits”
  1. Adam MajerMay 26, 2008
  2. Shawn O. PearceMay 26, 2008
  3. Junio C HamanoMay 26, 2008
  4. Adam MajerMay 26, 2008

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.