Browse Source

Merge "Use w1 for hashCode of AbbreviatedObjectId"

stable-4.9
Terry Parker 8 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
8c6a9a286e
  1. 16
      org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/AbbreviatedObjectIdTest.java
  2. 2
      org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java

16
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/AbbreviatedObjectIdTest.java

@ -86,7 +86,6 @@ public class AbbreviatedObjectIdTest {
final ObjectId f = i.toObjectId(); final ObjectId f = i.toObjectId();
assertNotNull(f); assertNotNull(f);
assertEquals(ObjectId.fromString(s), f); assertEquals(ObjectId.fromString(s), f);
assertEquals(f.hashCode(), i.hashCode());
} }
@Test @Test
@ -101,7 +100,6 @@ public class AbbreviatedObjectIdTest {
final ObjectId f = i.toObjectId(); final ObjectId f = i.toObjectId();
assertNotNull(f); assertNotNull(f);
assertEquals(ObjectId.fromString(s), f); assertEquals(ObjectId.fromString(s), f);
assertEquals(f.hashCode(), i.hashCode());
} }
@Test @Test
@ -215,7 +213,7 @@ public class AbbreviatedObjectIdTest {
} }
@Test @Test
public void testEquals_Short() { public void testEquals_Short8() {
final String s = "7b6e8067"; final String s = "7b6e8067";
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(s); final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(s);
final AbbreviatedObjectId b = AbbreviatedObjectId.fromString(s); final AbbreviatedObjectId b = AbbreviatedObjectId.fromString(s);
@ -225,6 +223,18 @@ public class AbbreviatedObjectIdTest {
assertEquals(a, b); assertEquals(a, b);
} }
@Test
public void testEquals_Short4() {
final String s = "7b6e";
final AbbreviatedObjectId a = AbbreviatedObjectId.fromString(s);
final AbbreviatedObjectId b = AbbreviatedObjectId.fromString(s);
assertNotSame(a, b);
assertTrue(a.hashCode() != 0);
assertTrue(a.hashCode() == b.hashCode());
assertEquals(b, a);
assertEquals(a, b);
}
@Test @Test
public void testEquals_Full() { public void testEquals_Full() {
final String s = "7b6e8067ec96acef9a4184b43210d583b6d2f99a"; final String s = "7b6e8067ec96acef9a4184b43210d583b6d2f99a";

2
org.eclipse.jgit/src/org/eclipse/jgit/lib/AbbreviatedObjectId.java

@ -336,7 +336,7 @@ public final class AbbreviatedObjectId implements Serializable {
@Override @Override
public int hashCode() { public int hashCode() {
return w2; return w1;
} }
@Override @Override

Loading…
Cancel
Save