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

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

From
Junio C Hamano <gitster@pobox.com>
Date
May 28, 2017, 01:14 UTC
Message-ID
<xmqq37bpbx5t.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<8CEDDC40C7D24404976929CF3E7AF6FC@PhilipOakley>
"Philip Oakley" <philipoakley@iee.org> writes:
Show 18 quoted lines
> The git book [1] and a few blog posts [2] show how to preserve files which
> are in the current branch against changes that are on the branch being
> merged in.
>
> e.g. (from [2])
>
> echo '<filemane> merge=ours' >> .gitattributes && # commit
> git config --global merge.ours.driver true
>
> (test) $ git checkout demo
> (demo) $ git merge -
> # <filename> contents are not merged and the original retained.
>
>
>
> However what is not covered (at least in the documentation ) is the case
> where the file to be ignored is not present on the current branch, but is
> present on the branch to be merged in.

Hmph. Per-path 'ours' and 'theirs' kick in only after we decide to perform the content level three-way merge. I wonder what would (not "should", but "would with the current code") happen, with the same attribute setting, if the file being merged were not changed by ours but modified by the side branch? I suspect that we'd take the change made by the side branch.

> Normal expectations would be that in such a case the new file from the
> second parent branch would be added to the current branch.

So I do not think this is not limited to "new file". Anything that a tree-level three-way merge would resolve cleanly without having to consult the content-level three-way merge will complete without consulting the merge.ours.driver; per-file content-level three-way merge driver (which is what merge=<drivername> mechanism lets you specify via the attributes mechanism) is not something you would want to use for this kind of thing. It is purely for resolving the actual content-level conflicts.

Previous: Philip OakleyNext: Philip Oakley
Message 2 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.