Browse Source

Fix ResolveMerger issue with submodule conflict

ResolveMerger throws a MissingObjectException when it encounters
a submodule conflict while merging. The reason is that it treats
the submodule link as a blob and tries to read its contents.

We solve the issue by detecting before content merge whether the
path to be merged is a submodule link, and skip the content
merge if it is.

Bug: 389238
Change-Id: I9a58dfc7716b28a21f5c04cf3a865091ae8dfe7e
Signed-off-by: Tommi Siivola <tommi.siivola@eficode.com>
stable-2.2
Tommi Siivola 12 years ago
parent
commit
0e56f34752
  1. 13
      org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

13
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

@ -538,6 +538,15 @@ public class ResolveMerger extends ThreeWayMerger {
if (isWorktreeDirty(work)) if (isWorktreeDirty(work))
return false; return false;
// Don't attempt to resolve submodule link conflicts
if (isGitLink(modeO) || isGitLink(modeT)) {
add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0);
add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0);
add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, 0, 0);
unmergedPaths.add(tw.getPathString());
return true;
}
MergeResult<RawText> result = contentMerge(base, ours, theirs); MergeResult<RawText> result = contentMerge(base, ours, theirs);
File of = writeMergedFile(result); File of = writeMergedFile(result);
updateIndex(base, ours, theirs, result, of); updateIndex(base, ours, theirs, result, of);
@ -770,6 +779,10 @@ public class ResolveMerger extends ThreeWayMerger {
return mode != 0 && !FileMode.TREE.equals(mode); return mode != 0 && !FileMode.TREE.equals(mode);
} }
private static boolean isGitLink(final int mode) {
return FileMode.GITLINK.equals(mode);
}
@Override @Override
public ObjectId getResultTreeId() { public ObjectId getResultTreeId() {
return (resultTree == null) ? null : resultTree.toObjectId(); return (resultTree == null) ? null : resultTree.toObjectId();

Loading…
Cancel
Save