git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Marius Bakke <marius@devup.no>
Cc: git@vger.kernel.org
Subject: Re: RFC: Merge hints
Date: Fri, 14 Feb 2020 01:44:28 -0500	[thread overview]
Message-ID: <20200214064428.GE605125@coredump.intra.peff.net> (raw)
In-Reply-To: <87pnexmcjr.fsf@devup.no>

On Sun, Feb 02, 2020 at 12:52:24PM +0100, Marius Bakke wrote:

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

To some degree, the git-rerere command does this.

It doesn't let you do the kind of pattern transformations you suggested,
but it does let you resolve a _particular_ conflict once, and then
repeat it again. So it's useful if you're going to find the same
conflict multiple times (e.g., merging to multiple long-running
branches) or if you want to communicate resolutions to somebody (you can
share your merge result, and they can use rerere-train to seed their own
database).

But it sounds like you're more interested in the pattern ones, where you
don't see the _same_ conflict over and over, but rather just similar
ones (your example where one side changes the signature of foo(), but
the other side keeps adding new callers).

In my experience you can't really solve that in an automated way (you
have to decide in each case what should go into the new parameter!). But
assuming you could, it seems like this could all be done outside of Git
itself.

For example:

> 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

Once Git sees the conflicted state, you should be able to mark up those
conflicts using an external tool. You operate on the file with conflict
markers from your working tree, or you can access the original base,
"theirs" and "ours" content in stages 1, 2, and 3 of the index. So if
you have a smart tool which understands merging and understands the
syntax of your files, it could apply those transforms.

That's more or less how git-mergetool works (feeding those three files
to whatever custom tool you like). I don't have a good knowledge of what
tools are out there that might support something like this, though (I
typically just look at the conflicts manually in an editor).

-Peff

      reply	other threads:[~2020-02-14  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-02 11:52 RFC: Merge hints Marius Bakke
2020-02-14  6:44 ` Jeff King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200214064428.GE605125@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=marius@devup.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).