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

Re: git merge no longer handles add/add

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 19, 2007, 19:25 UTC
Message-ID
<7vabpanilk.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<46a038f90711191033s4bc5ab50kd3e4f30d6b301e43@mail.gmail.com>
"Martin Langhoff" <martin.langhoff@gmail.com> writes:
Show 10 quoted lines
> On Nov 19, 2007 7:43 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> As far as the point of the merge is concerned, that's an add/add
>> of _different_ contents, and we have always left the conflict to
>> resolve for you since day one.  The only case we handle without
>> complaining is the accidental *clean* merge.  Both branches adds
>> the path *identically* compared to the common ancestor.
>
> Even if the 2 paths did have matching content at one point? In fact,
> the 2 files here get added with identicaly content and one of them is
> later modified...
A merge does not look at the history.

It _does_ look at the history to figure out what the common ancestors are, but after finding them out, the "file history" is not examined by following each step in the ancestry chain (that would have been the "blame merge").

Show 10 quoted lines
>> The very initial implementation of merge may have used the total
>> emptyness as the common ancestor for the merge, and later we
>> made it a bit more pleasant to resolve by computing the common
>> part of the file from the two branches to be used as a fake
>> ancestor contents.  But the fact we left the result as conflict
>> for you to validate hasn't changed and will not change.
>
> In this case, if you use the common part (100%) as the ancestor, then
> you get a _clean_ merge. The file is added on both sides identically,
> and then it changes on one side.

Exactly. We may keep conflict markers in the file left in the work tree to highlight which lines are unique to the side that added more (iow, one group of lines delimited by <<< === >>> is empty while the other is not) but this is currently treated as "fishy, needs human validation" to catch mismerges.

Previous: J. Bruce FieldsNext: Jakub Narebski
Message 6 of 8 in “git merge no longer handles add/add”
  1. Martin LanghoffNov 19, 2007
  2. Martin LanghoffNov 19, 2007
  3. Junio C HamanoNov 19, 2007
  4. Martin LanghoffNov 19, 2007
  5. J. Bruce FieldsNov 19, 2007
  6. Junio C HamanoNov 19, 2007
  7. Jakub NarebskiNov 19, 2007
  8. Johannes SchindelinNov 20, 2007

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.