merge operations (e.g., cherry-pick) behave badly when conflicting submodule adds/removals
TL;DR: we need to make sure we show correct information in git meta status that guides the user to the right resolution steps in the case of conflicts involving submodule additions and removals, e.g.:
- added both sides but with different shas
- removed on one side but changes on the other
Project: https://github.com/twosigma/git-meta/projects/6
e.g.:
$ write-repos -o 'a=B:Ca-1;Cb-1;Ba=a;Bb=b|x=S:C2-1 s=Sa:a;C3-1 s=Sa:b;Bmaster=2;Bfoo=3'
$ cd x
x$ git meta rebase foo
First, rewinding head to replay your work on top of it...
Applying 'message'
Conflicting entries for submodule s
x$ git st
HEAD detached at f95c3bf
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both added: s
no changes added to commit (use "git add" and/or "git commit -a")
x$ git meta status
On detached head f95c3b.
A rebase is in progress.
(after resolving conflicts mark the corrected paths
with 'git meta add', then run "git meta rebase --continue")
(use "git meta rebase --abort" to check out the original branch)
nothing to commit, working tree clean
x$ git checkout --ours s
x$ git st
HEAD detached at f95c3bf
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both added: s
no changes added to commit (use "git add" and/or "git commit -a")
x$ git add s
error: unable to index file s
fatal: updating files failed
- I think there is either a problem in the way libgit2 renders conflicts (not our flaky test related to this) or I am not using their API correctly. In the former case, we might consider shelling out to Git.
- We need to make sure status shows conflicting submodule entries.
OK, I'm not sure what to do here, but I think we're doing the right thing -- to the extent that there's a right thing to do. If you run plain git rebase foo instead of git meta rebase foo, you get the exact same behavior.
Additionally, we've seen users in this state get a libgit2 error: Error: cannot create a tree from a not fully merged index. We need to make sure that we diagnose this situation and emit a better error.