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

libgit2 breaks when merging a submodule change into a branch where that submodule has been deleted

Open bpeabody opened this issue 8 years ago • 3 comments

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.

bpeabody avatar Nov 30 '17 22:11 bpeabody

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.

novalis avatar Dec 04 '17 21:12 novalis

https://github.com/libgit2/libgit2/pull/4429

novalis avatar Dec 11 '17 15:12 novalis

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.

novalis avatar Jan 05 '18 02:01 novalis