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

Re: RFE: version-controlled merge rules

From
Duy Nguyen <pclouds@gmail.com>
Date
Dec 28, 2018, 16:03 UTC
Message-ID
<CACsJy8A0bP4e14m+zpr02MHCDEBdfpXHn-Vjw5cV4WtQVoKrNg@mail.gmail.com>
In-Reply-To
<95ca8579-4e12-1e46-8824-b1d19c6d9289@zytor.com>
On Fri, Dec 28, 2018 at 4:46 PM H. Peter Anvin <hpa@zytor.com> wrote:
Show 41 quoted lines
>
> On 12/27/18 3:55 PM, Jonathan Nieder wrote:
> > Hi,
> >
> > H. Peter Anvin wrote:
> >
> >> [merge "version"]
> >>         name = Version file merge driver
> >>         driver = sort -V -r %O %A %B | head -1 > %A.tmp.1 && mv -f %A.tmp.1 %A
> > [...]
> >> However, I can't even put this in .gitattributes, because doing so would break
> >> any user who *doesn't* have the previous rule defined locally. Even worse, if
> >> this rule needs to change, propagating it to all new users has to be done
> >> manually... never mind if it needs to vary by branch!
> >>
> >> The simplest way to address this would presumably be to let the
> >> repository/working directory contain a .gitconfig file that can contain rules
> >> like that.  (Allowing it to be in the repository proper is probably a
> >> requirement for merges to be handled correctly on bare repositories; I'm not
> >> sure how .gitattributes is handled for that.)
> >
> > The main issue I see is that this would make it a little *too* easy to
> > run arbitrary code on the user's machine.  Build systems often already
> > lead to that, but users are more familiar with the risks for build
> > than for version control.
> >
> > See [1] for some related discussion.
> >
> > That said, using the include.path feature (see git-config(1)), it's
> > possible to do something similar:
> >
> >       [include]
> >               path = ../.gitconfig
> >
> > Thanks and hope that helps,
> > Jonathan
> >
>
> That would be great, except that it doesn't work if the worktree isn't in
> "..".  This is one of many cases where it would be great to have environment
> variable interpolation.

It's been discussed, see [1] and others in the same thread. The feeling I got was it seemed good idea, but we're just not sure about the exact syntax and some corner cases, and most importantly nobody has stepped up to implement it.

[1] https://public-inbox.org/git/20181109101918.GC7410@sigill.intra.peff.net/
-- 
Duy
Previous: H. Peter AnvinNext: Junio C Hamano
Message 4 of 7 in “RFE: version-controlled merge rules”
  1. H. Peter AnvinDec 27, 2018
  2. Jonathan NiederDec 27, 2018
  3. H. Peter AnvinDec 28, 2018
  4. Duy NguyenDec 28, 2018
  5. Junio C HamanoDec 28, 2018
  6. hpa@zytor.comDec 29, 2018
  7. Ævar Arnfjörð BjarmasonDec 28, 2018

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.