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

RFE: version-controlled merge rules

From
HAH. Peter Anvin <hpa@zytor.com>
Date
Dec 27, 2018, 20:16 UTC
Message-ID
<ad875f1e-54e1-e19f-cd65-95ab503c6de2@zytor.com>

Right now, merge rules can get selected in .gitattributes, which is version-controlled. However, there does not appear to be any way to *define* custom merge rules which is version controlled.

There are a lot of different files which can benefit from custom merge rules, especially ones that are in some ways cumulative or version/tree-dependent. For example, I use this rule to merge version files:

[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

(Incidentally: the need for an explicit temp file here is frustrating. It would be better if git could manage the temporary file. Overwriting %A directly truncates the file too early. See other email.)

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.)

	-hpa
Next: Jonathan Nieder
Message 1 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.