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

Re: Request for adding a simple mechanism to exclude files from Git merge operation

From
Chris Torek <chris.torek@gmail.com>
Date
Jun 23, 2020, 22:57 UTC
Message-ID
<CAPx1Gvc6X5zgHXfnaKD+sBM=P1ve4raR5tJzTaZnwwTugBva_A@mail.gmail.com>
In-Reply-To
<CABPp-BFwNnD-zZvHjCAvvmzy1wTT3yy-smK5nCtQ937apaNmkQ@mail.gmail.com>

I'm going to snip a lot here as I'm not really replying to one specific proposal or another. I just want to add some background:

On Tue, Jun 23, 2020 at 2:48 PM Elijah Newren <newren@gmail.com> wrote:
> Once you record the information for which files it applies to, then
> you want it to happen whenever the merge machinery fires, right?

This is, of course, already the case for merge drivers defined and used in .gitattributes entries (though note that they don't apply to some merge *strategies*, e.g., `-s ours` completely ignores them).

Show 6 quoted lines
> The problems I was raising were not with the resulting end-state tree
> that users can construct or what happens with those trees once
> constructed.  My problems were with expected automatic behavior from
> the merge machinery coupled with incomplete specifications that
> sounded to me like a pile of corner cases and bugs that I'd have to
> field while trying to maintain the merge machinery logic.

This is already a bit of a problem with merge drivers in .gitattributes. In particular, suppose we're doing a standard merge of commits H (HEAD) and T (theirs) with respect to B (base). If the file is named "foo" and there is a merge driver defined for "foo", this merge driver is completely ignored *unless* all three copies of foo differ! And of course there are rename issues if a file's name was foo but isn't now or vice versa.

I do think it might be reasonable to be able to mark a merge driver as "always use this, even if two or even all three inputs are the same".

> Oh, and I have a problem with "branch specific" files from the email
> you were responding to.  I think those are a code smell.  But my
> primary concern was the expectations of some new automatic behavior
> out of the merge machinery and how/if it gets configured.

They're not only smelly :-) ... they don't even really mean anything. In particular, merge works not on *branches* but on *commits*. If we're merging commits H and T with base B, we may not be on any branch at all (detached HEAD) and there could be anywhere from zero to arbitrarily many branch names pointing at or containing each of the three commits. But of course it's common to have one branch name for each of H and T, and that's where most people who want this are coming from.

In any case, the merge driver stuff is useful to some people sometimes. It might be a little more useful if you could force `git merge` to use it even if only "their side" of the merge has changed the file since the merge base.

Chris
Previous: Elijah NewrenNext: Sergey Organov
Message 11 of 16 in “Request for adding a simple mechanism to exclude files from Git merge operation”
  1. Tiran MeltserJun 20, 2020
  2. Philip OakleyJun 21, 2020
  3. Tiran MeltserJun 22, 2020
  4. brian m. carlsonJun 22, 2020
  5. Sergey OrganovJun 23, 2020
  6. Philip OakleyJun 23, 2020
  7. Sergey OrganovJun 23, 2020
  8. Elijah NewrenJun 23, 2020
  9. Sergey OrganovJun 23, 2020
  10. Elijah NewrenJun 23, 2020
  11. Chris TorekJun 23, 2020
  12. Sergey OrganovJun 24, 2020
  13. Junio C HamanoJun 23, 2020
  14. Sergey OrganovJun 24, 2020
  15. Junio C HamanoJun 24, 2020
  16. Sergey OrganovJun 25, 2020

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.