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

RFC: Merge hints

From
MBMarius Bakke <marius@devup.no>
Date
Feb 2, 2020, 11:52 UTC
Message-ID
<87pnexmcjr.fsf@devup.no>
Hi,

It would be convenient if git had a facility for adding "merge hints", both for automatic conflict resolution, as well as giving clues to persons inheriting or merging a branch.

The main use case here is aiding long-running branches. Imagine a feature branch where all uses of FOO_STR is replaced with STR. For various reasons this branch cannot be merged to master, yet it needs to be kept up to date, and new uses of FOO_STR keeps getting added.

If you are lucky, your compiler will complain that FOO_STR is undefined when running whatever tests you have after a merge. But perhaps the new code is for a different platform and not reached during a test run. A diligent developer might also run 'git grep FOO_STR' *if* they know about the change. Fixing these trivial problems is boring and manual.

A more tricky case is where...
  def foo(a,b)
has become
  def foo(a,b,c)

...and c is a required positional argument. Any new uses of 'foo' will need to be adjusted during a merge. This function can be multi line and not easily greppable.

The diligent developer is in no shortage of tools: "git log -G foo ..master" will reveal any potential problems, even before the merge. Yet, they still have to 1) know about the change; and 2) fix up the uses manually.

It seems to me that git could offer better tools to deal with this. Perhaps a ".mergehints", where you could provide a regular expression either for automatic merge resolution, or just have git complain loudly when a given pattern is merged (say, introduce conflict markers even though there were no "real" conflicts). I.e.:

[hint1] files = *.c pattern = FOO_STR transform = s/FOO_STR/STR

[hint2] files = *.py pattern = 'foo(' conflict = true

Thoughts? Are there other tools at the diligent developers disposal that can aid with these kinds of problems?

Next: Jeff King
Message 1 of 2 in “RFC: Merge hints”
  1. Marius BakkeFeb 2, 2020
  2. Jeff KingFeb 14, 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.