diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-08-20 15:42:52 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-08-20 17:38:52 -0700 |
commit | cf9537c8ceeed05b2cc7f996009d9f2f18623782 (patch) | |
tree | 71a50373a8e09febca750ed89e837affd62f952f /org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java | |
parent | 746ebda381b10a3dffa0b2fd83c4e5dd8585844f (diff) | |
download | jgit-cf9537c8ceeed05b2cc7f996009d9f2f18623782.tar.gz jgit-cf9537c8ceeed05b2cc7f996009d9f2f18623782.zip |
Correct PersonIdent hashCode() and equals() to ignore milliseconds
Git doesn't store millisecond accuracy in person identity lines,
so a line that we create in Java and round-trip through a Git object
wouldn't compare as being equal. Truncate to seconds when comparing
values to ensure the same identity is equal.
Change-Id: Ie4ebde64061f52c612714e89ad34de8ac2694b07
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java index 0406684ea7..25acee046c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/PersonIdent.java @@ -268,7 +268,10 @@ public class PersonIdent { } public int hashCode() { - return getEmailAddress().hashCode() ^ (int) when; + int hc = getEmailAddress().hashCode(); + hc *= 31; + hc += (int) (when / 1000L); + return hc; } public boolean equals(final Object o) { @@ -276,7 +279,7 @@ public class PersonIdent { final PersonIdent p = (PersonIdent) o; return getName().equals(p.getName()) && getEmailAddress().equals(p.getEmailAddress()) - && when == p.when; + && when / 1000L == p.when / 1000L; } return false; } |