Re: Automatically re-running commands during an interactive rebase or post commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 29, 2023 at 12:48 PM Phillip Wood <phillip.wood123@xxxxxxxxx> wrote:
> On 29/05/2023 20:08, Paul Jolly wrote:
[...]
> > I have a custom merge strategy working, insofar as I've written a
> > script that is being called. The script simply wraps "git merge-ort"
> > as you suggest.
> >
> > But I can't seem to work out how to actually run 'git merge-ort'! I've
> > tried 'git merge -s "$@"' in my wrapper script, but doing so my custom
> > strategy behaves differently to if I use no strategy, which seems to
> > suggest I'm doing something wrong.

Don't call `git merge` from your custom merge strategy.  That's just
asking for trouble; we should probably modify the code to throw huge
errors if people attempt that.

Use lower-level primitives, such as `git merge-tree`, `git
merge-file`, `git read-tree`, `git update-index`, `git merge-index`,
`git merge-one-file`, etc.  Bias towards the first two of those.

> > Do you have any suggestions/pointers?
>
> Sorry, I'd assumed there was a merge-ort command in the same way as
> there is a merge-recursive command but it does not exist. I think the
> best you can do is run "git merge-recursive" rather than "git merge-ort"
> in your script. I've cc'd Elijah in case he has a better suggestion.

In short, I'd say use `git merge-tree` instead of `git
merge-recursive`, but the long story about the latter command is:

First of all, we _currently_ have a bunch of executables & scripts,
one per merge strategy:
  * git-merge-octopus
  * git-merge-resolve
  * git-merge-recursive
  * git-merge-ours
But, in this set, git-merge-recursive is builtin and isn't called as
an external program, so that's not a reason I think it should exist,
and we certainly shouldn't add another for `ort` based on this
rationale.  (The others may also be replaced with builtins; there were
even patches in that direction, though they weren't followed up on.)

Second of all, we've had multiple ways to expose users to "doing a merge":
  * git-merge
  * git-merge-recursive
  * git-merge-tree
The first is the one most users are familiar with, `git merge`.  So,
about the others...  Traditionally, git-merge-tree was a virtually
useless implementation that fell way short of the good idea to 'make a
merge without touching the worktree or index'.  In contrast,
git-merge-recursive was in between git-merge-tree and git-merge in
terms of how low level it was.  It still required updating the working
tree and index, which limited what could be built on top of it, but
unlike git-merge-tree it at least provided useful functionality in
that it could do-all-parts-of-the-merge-except-commit-and-update-branch.
While not optimal, that was enough that git-merge-recursive got used
in some places (such as one of the rebase backends once upon a time).
Nowadays, though, git-merge-tree is the correct low-level primitive --
it can do a merge without updating branches, creating a commit, or
updating the worktree or index.  That means that git-merge-recursive
isn't really useful from this angle either; everything can be built on
top of something a little lower level.

The two angles above were the reasons that git-merge-recursive
existed, but neither is useful nowadays, so git-merge-recursive is
basically a historical relic (which we are keeping for backward
compatibility purposes, not for any intrinsic value I can see).  I
don't want to add another useless historical relic, in the form of
`git-merge-ort`.

But there's a third reason to not provide `git-merge-ort` as well: The
plan has always been to use `ort` as a drop-in replacement for
`recursive` and make _all_ calls within the code unconditionally
translate requests for `recursive` to call the `ort` code instead.  I
just haven't gotten around to finishing those plans yet.  (In fact,
there are only two places in the code that still call the recursive
backend by default -- git-merge-recursive and git-am, both of which
I've been meaning to fix up).  So, making a `git-merge-ort` would make
it really weird in the future in that we'd have both
`git-merge-recursive` and `git-merge-ort` calling the same thing.

Anyway, if you want a low-level do-a-merge thing, use `git merge-tree`.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux