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

Re: Distinguishing trivial and non-trivial merge commits

From
Jonathan Nieder <jrnieder@gmail.com>
Date
May 2, 2010, 20:29 UTC
Message-ID
<20100502202943.GB16746@progeny.tock>
In-Reply-To
<19421.54064.178345.489772@winooski.ccs.neu.edu>
Eli Barzilay wrote:
> On May  2, Jonathan Nieder wrote:
Show 7 quoted lines
>> Note that most conflicts will not show up here: if the merge result
>> matches either parent, then git diff --cc and friends will not
>> consider it interesting at all.
>
> Isn't that a good definition of a trivial commit?  I'm not talking
> about the whole commit -- just any file that is not identical to one
> of its parents.
[...]
> For my purpose, I basically just want
> to know whether there was manual tweaking involved in the merge.

diff --name-only follows exactly the example heuristic you described. It still does not catch all manual merge resolutions[1].

Sometimes two branches introduce different changes to completely separate parts of a file. This is not a conflict, and diff --cc will correctly report the merge as trivial (whereas diff --name-only does not pay enough attention to do the same).

On the other hand, sometimes two branches introduce conflicting changes, but the correct resolution for each conflict hunk is to pick one as winner. Though simple, this can be error-prone, because rejecting one change from branch A might end up breaking another change that was accepted from the same branch. diff --cc examines only the selected revision and its parents and for all it knows, this is just another trivial merge.

>  git show --pretty=format:"" --name-only "$r" | grep -q "."
>    --> test if it's trivial
I would have expected
	git show --name-only --exit-code --quiet "$r"

to take care of this, but apparently it always exits zero. Probably no one had tried it before.

> (My script generally "compensates" for git being fast by running a ton
> of them for each email...)
:)
Jonathan
[1] http://thread.gmane.org/gmane.comp.version-control.git/89415
Previous: Eli Barzilay
Message 8 of 8 in “Distinguishing trivial and non-trivial merge commits”
  1. Eli BarzilayApr 30, 2010
  2. Jonathan NiederMay 2, 2010
  3. Eli BarzilayMay 2, 2010
  4. Jakub NarebskiMay 2, 2010
  5. Eli BarzilayMay 2, 2010
  6. Junio C HamanoMay 2, 2010
  7. Eli BarzilayMay 2, 2010
  8. Jonathan NiederMay 2, 2010

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.