]> source.dussan.org Git - jgit.git/commitdiff
Fix ResolveMerger issue with submodule conflict 23/7723/2
authorTommi Siivola <tommi.siivola@eficode.com>
Wed, 12 Sep 2012 05:19:30 +0000 (08:19 +0300)
committerTommi Siivola <tommi.siivola@eficode.com>
Wed, 12 Sep 2012 10:11:57 +0000 (13:11 +0300)
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>
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java

index 212938efe8b1ad000c8793db05572c8175b0bbd3..1782bb2ad3585f8ce15c9801fc8ef993adf5b16c 100644 (file)
@@ -538,6 +538,15 @@ public class ResolveMerger extends ThreeWayMerger {
                        if (isWorktreeDirty(work))
                                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);
                        File of = writeMergedFile(result);
                        updateIndex(base, ours, theirs, result, of);
@@ -770,6 +779,10 @@ public class ResolveMerger extends ThreeWayMerger {
                return mode != 0 && !FileMode.TREE.equals(mode);
        }
 
+       private static boolean isGitLink(final int mode) {
+               return FileMode.GITLINK.equals(mode);
+       }
+
        @Override
        public ObjectId getResultTreeId() {
                return (resultTree == null) ? null : resultTree.toObjectId();