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

Re: mergetool: what to do about deleting precious files?

From
Philip Oakley <philipoakley@iee.org>
Date
May 30, 2017, 23:04 UTC
Message-ID
<E0D5AC60DB0F48DEBF865597910D9531@PhilipOakley>
In-Reply-To
<xmqq1sr7f9nb.fsf@gitster.mtv.corp.google.com>
From: "Junio C Hamano" <gitster@pobox.com>
Thanks for the replies. Let's see if I've got it...
Show 14 quoted lines
> "Philip Oakley" <philipoakley@iee.org> writes:
>
>> If I now understand correctly, the merge process flow is:
>>
>> * canonicalise content (eol, smudge-clean, $id, renormalise, etc)
>> * diff the content (internal, or GIT_EXTERNAL_DIFF)
>> * apply the diff
>> * if conflicts, only then use merge-driver/tool
>>
>> Would that be a correct interpretation?
>
> Not quite.  There are a lot more going on before any of those steps:
>
> * Find the common ancestor commit (which could be many).

IIUC Git selects one of them, rather than all if there are many (which then may not be the optimum)

Show 7 quoted lines
>
> * Walk the three trees (the common ancestor's, ours and theirs) in
>   parallel, noticing what happened to each path.  Depending on what
>   happened to the path in each branch, the merge may or may not
>   "conflict" (e.g. when both sides added exactly the same contents
>   to the same path, they are not counted as conflicting.  when we
>   removed while they modified, they show as conflicting).

I'm assuming here that this is the sha-oid comparison, and then checking the tree/blob names that match them. (the top tree not having a name). So here "conflict free" is that the sha-oids match.

Also, I thnk this is saying that added or removed trees or blobs are in some sense are 'conflict free' (though still subject to rename/move detection etc). An added file/blob would be conflict free for merging into it's tree, yes?

IIUC, the comparison is therefore using the in-repo sha-oids; unless --renormalise was given which will do a smudge-clean washing cycle and recomute fresh canonical sha-oids for the comparison (rather than doing it later).

>
> * For paths that are conflicting, feed the canonicalized content of
>   the versions from common, ours and theirs to the file-level merge
>   driver.

So this is where any .gitattibutes settings come in, or is the merge driver after the diff step? (which could also be a user diff?)

Show 17 quoted lines
>        The builtin file-level merge driver takes two xdiff (one
>   between ancestor and ours, the other between ancestore and
>   theirs) and reconciles them to produce the result.  But that is
>   irrelevant in the context of "custom merge driver"; the builtin
>   one is skipped altogether and the custom contents merge driver
>   the user specified via the attributes is used instead.
>
> Notice that the second step above has no customization knobs.  Any
> path the second step deems not to conflict is "merged cleanly"
> without even triggering the "oops, ours and theirs did conflicting
> changes, to the content; let's see how the final content should look
> like" (aka the third step).  This is *not* because "Git knows the
> best"; it is merely that nobody felt the need for a mechanism to
> allow customizing the second step.
>
> And that is why I said you need a new customization mechanism if you
> want to affect the outcome of the scenario that started this thread.

Ok, I think I can see how I was confused between the "tree merge" (oid conflict detection) and the more usual (to users) "file merge" (line by line, etc.). I wasn't sure where to find that as someone relatively new to Git.

Thanks for the explanations. -- Philip

--- This email has been checked for viruses by AVG. http://www.avg.com

Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 8 in “mergetool: what to do about deleting precious files?”
  1. Philip OakleyMay 27, 2017
  2. Junio C HamanoMay 28, 2017
  3. Philip OakleyMay 28, 2017
  4. Junio C HamanoMay 28, 2017
  5. Philip OakleyMay 29, 2017
  6. Junio C HamanoMay 30, 2017
  7. Philip OakleyMay 30, 2017
  8. Junio C HamanoMay 31, 2017

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.