git-imerge icon indicating copy to clipboard operation
git-imerge copied to clipboard

Skip incompatible merges

Open NZJenkins opened this issue 5 years ago • 1 comments
trafficstars

Suppose I have two commits that don't merge easily Is it possible to skip the difficult merge and continue merging elsewhere?

The complete merge might look like the diagram below

   A  B  C
X  .  .  ?
Y  #  *  ?
Z  ?  .  .

* = merge done manually
. = merge done automatically
# = conflict that is currently blocking progress
? = no merge recorded

Merging branch with commits A, B, C and branch with commits X, Y, Z

  • User skips A, Y
  • B, Y is manually merged via B, X
  • And merging continues

NZJenkins avatar Sep 30 '20 05:09 NZJenkins

That wouldn't be in the spirit of the incremental merge, so it would complicate the idea quite a bit:

  • In your example, you wouldn't have merge A-Y, so what would be the parents of B-Y? I suppose you could merge B and Y directly, but then what? Would you come back to A-Y later, or hope to avoid it altogether?

  • Normally, if A-Y is difficult to resolve, then merging B and Y directly to produce B-Y will be, too (though this might not be the case if, say, commit B reverts part or all of commit A).

  • What if, later, A-Z turns out to conflict? If you've never done A-Y, then what first parent would you use for the A-Z merge? And again, if A-Y is difficult to resolve, then going directly to A-Z probably will be, too.

There are cases when it would be more plausible to skip around. Say there are two blocking merges, like in the following diagram:

       0    5   9
       |    |   |
   0 - ********** - c
       **?..*.--+
       *.?.*.|#??
       *.?...|???
       *.?..-+???
   5 - *...|#????
       **?.|?????
       *.?.|?????
   8 - *---+?????
       |
     d

In this case, imerge might ask you to resolve merge 5-5, but you might not know how. Meanwhile, you might know how to resolve merge 7-2. There is no theoretical reason that you shouldn't be able to do those two merges in either order.

In fact, you could do it, too. But you'd have to set up the merge yourself, by checking out branch refs/heads/imerge/NAME, resetting it to refs/imerge/NAME/auto/7-1, then running git merge refs/imerge/NAME/auto/6-2, stage your changes, and then run git imerge recordorgit imerge continue`. It wouldn't be too hard to automate this setup step (though I don't have plans to work on it anytime soon).

mhagger avatar Oct 02 '20 13:10 mhagger