Fix RevWalk.getMergedInto() ignores annotated tags
If an annotated tag refers to a commit, we should not ignore it.
Change-Id: I77504f93636e9e984540e7d8535ef301adce6a80
Signed-off-by: kylezhao <kylezhao@tencent.com>
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergedIntoTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergedIntoTest.java
index 2f16aa4..2754bd3 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergedIntoTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/revwalk/RevWalkMergedIntoTest.java
@@ -99,7 +99,7 @@
createBranch(commit(commit(a)), b);
createBranch(commit(commit(i)), c);
- assertTrue( rw.isMergedIntoAny(a, getRefs()));
+ assertTrue(rw.isMergedIntoAny(a, getRefs()));
}
@Test
@@ -125,4 +125,23 @@
assertTrue(rw.isMergedIntoAll(a, getRefs()));
}
+
+ @Test
+ public void testMergeIntoAnnotatedTag() throws Exception {
+ /*
+ * a
+ * |
+ * b
+ * / \
+ * c v1 (annotated tag)
+ */
+ String c = "refs/heads/c";
+ String v1 = "refs/tags/v1";
+ final RevCommit a = commit();
+ final RevCommit b = commit(a);
+ createBranch(commit(b), c);
+ createBranch(tag("v1", b), v1);
+
+ assertTrue(rw.isMergedIntoAll(a, getRefs()));
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
index d2ab4a1..6e29438 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/RevWalk.java
@@ -541,7 +541,7 @@
return result;
}
monitor.update(1);
- RevObject o = parseAny(r.getObjectId());
+ RevObject o = peel(parseAny(r.getObjectId()));
if (!(o instanceof RevCommit)) {
continue;
}