git-meta
git-meta copied to clipboard
libgit2 breaks when merging a submodule change into a branch where that submodule has been deleted
x.zip Using the attached zip or this:
$ write-repos -o 'a=B:Ca-1;Ba=a|x=U:C3-2 s;C5-4 foo=bar;C4-2 s=Sa:a;Bmaster=3;Bfoo=5'
Do the following to reproduce:
$ cd x
$ git meta merge -m foo foo
Error: object not found - no match for id (64ba9179dc7865187060226f21f4f7642ac783a1)
The relevant lines are:
const mergeIndex = yield SubmoduleUtil.cacheSubmodules(repo, () => {
return NodeGit.Merge.commits(repo, head, commit, null);
});
const checkoutOpts = {
checkoutStrategy: NodeGit.Checkout.STRATEGY.FORCE
};
yield SubmoduleUtil.cacheSubmodules(repo, () => {
return NodeGit.Checkout.index(repo, mergeIndex, checkoutOpts);
});
And it is the attempt to checkout the merge index where it dies.
I can now repro this in libgit2. It's not clear what the right thing to do here is -- what git does is somewhat wrong.
https://github.com/libgit2/libgit2/pull/4429
Fixed upstream -- we just need to get nodegit to upgrade, which I suppose they eventually will. I think they work off of libgit2 releases, and there hasn't been once since this fix went in.