Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåvard Wall2018-10-17 13:34:51 +0000
committerHåvard Wall2018-11-09 07:54:44 +0000
commitf9de9175477577c6c7d0a22ebe5a1c9a1c299c1a (patch)
tree192bb166301eb535fee9b63dcd23d585306ecd93 /org.eclipse.jgit.test/tst
parent9b6d30f2c145243bfdb1708bef847538a0df640d (diff)
downloadjgit-f9de9175477577c6c7d0a22ebe5a1c9a1c299c1a.tar.gz
jgit-f9de9175477577c6c7d0a22ebe5a1c9a1c299c1a.tar.xz
jgit-f9de9175477577c6c7d0a22ebe5a1c9a1c299c1a.zip
Fix git-describe tie-breakers
Correct behaviour as git 1.7.1.1 is to resolve tie-breakers to choose the most recent tag. https://github.com/git/git/blob/master/Documentation/RelNotes/1.7.1.1.txt: * "git describe" did not tie-break tags that point at the same commit correctly; newer ones are preferred by paying attention to the tagger date now. Bug: 538610 Change-Id: Ib0b2a301997bb7f75935baf7005473f4de952a64 Signed-off-by: Håvard Wall <haavardw@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java55
1 files changed, 40 insertions, 15 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java
index 79da2da7ea..a2d8e89699 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/DescribeCommandTest.java
@@ -44,6 +44,7 @@ package org.eclipse.jgit.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.File;
@@ -134,24 +135,48 @@ public class DescribeCommandTest extends RepositoryTestCase {
public void testDescribeMultiMatch() throws Exception {
ObjectId c1 = modify("aaa");
tag("v1.0.0");
+ tick();
+ tag("v1.0.1");
+ tick();
+ tag("v1.1.0");
+ tick();
tag("v1.1.1");
ObjectId c2 = modify("bbb");
- // Ensure that if we're interested in any tags, we get the first match as per Git behaviour
- assertEquals("v1.0.0", describe(c1));
- assertEquals("v1.0.0-1-g3747db3", describe(c2));
-
- // Ensure that if we're only interested in one of multiple tags, we get the right match
- assertEquals("v1.0.0", describe(c1, "v1.0*"));
- assertEquals("v1.1.1", describe(c1, "v1.1*"));
- assertEquals("v1.0.0-1-g3747db3", describe(c2, "v1.0*"));
- assertEquals("v1.1.1-1-g3747db3", describe(c2, "v1.1*"));
-
- // Ensure that ordering of match precedence is preserved as per Git behaviour
- assertEquals("v1.0.0", describe(c1, "v1.0*", "v1.1*"));
- assertEquals("v1.1.1", describe(c1, "v1.1*", "v1.0*"));
- assertEquals("v1.0.0-1-g3747db3", describe(c2, "v1.0*", "v1.1*"));
- assertEquals("v1.1.1-1-g3747db3", describe(c2, "v1.1*", "v1.0*"));
+ // Ensure that if we're interested in any tags, we get the most recent tag
+ // as per Git behaviour since 1.7.1.1
+ if (useAnnotatedTags) {
+ assertEquals("v1.1.1", describe(c1));
+ assertEquals("v1.1.1-1-gb89dead", describe(c2));
+
+ // Ensure that if we're only interested in one of multiple tags, we get the right match
+ assertEquals("v1.0.1", describe(c1, "v1.0*"));
+ assertEquals("v1.1.1", describe(c1, "v1.1*"));
+ assertEquals("v1.0.1-1-gb89dead", describe(c2, "v1.0*"));
+ assertEquals("v1.1.1-1-gb89dead", describe(c2, "v1.1*"));
+
+ // Ensure that ordering of match precedence is preserved as per Git behaviour
+ assertEquals("v1.0.1", describe(c1, "v1.0*", "v1.1*"));
+ assertEquals("v1.1.1", describe(c1, "v1.1*", "v1.0*"));
+ assertEquals("v1.0.1-1-gb89dead", describe(c2, "v1.0*", "v1.1*"));
+ assertEquals("v1.1.1-1-gb89dead", describe(c2, "v1.1*", "v1.0*"));
+ } else {
+ // no timestamps so no guarantees on which tag is chosen
+ assertNotNull(describe(c1));
+ assertNotNull(describe(c2));
+
+ assertNotNull(describe(c1, "v1.0*"));
+ assertNotNull(describe(c1, "v1.1*"));
+ assertNotNull(describe(c2, "v1.0*"));
+ assertNotNull(describe(c2, "v1.1*"));
+
+ // Ensure that ordering of match precedence is preserved as per Git behaviour
+ assertNotNull(describe(c1, "v1.0*", "v1.1*"));
+ assertNotNull(describe(c1, "v1.1*", "v1.0*"));
+ assertNotNull(describe(c2, "v1.0*", "v1.1*"));
+ assertNotNull(describe(c2, "v1.1*", "v1.0*"));
+
+ }
}
/**

Back to the top