{"thread":{"id":"19912","subject":"[JGIT PATCH] Fix sort order in GitIndex and mark it as deprecated","startedAt":"2009-06-23T21:45:23Z","lastAt":"2009-06-23T21:45:23Z","messageCount":1,"participants":["Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"116837","messageId":"1245793523-28787-1-git-send-email-robin.rosenberg@dewire.com","threadId":"19912","inReplyTo":null,"subject":"[JGIT PATCH] Fix sort order in GitIndex and mark it as deprecated","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@dewire.com","sentAt":"2009-06-23T21:45:23Z","receivedAt":"2009-06-23T21:45:23Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"We were using signed comparisons for ordering entries here which is so\nterribly wrong and sometimes breaks when using non-ascii characters.\n\nDue to other mechanisms this went undetected when committing from JGit,\nbecause the order in trees were usually corrected, but updating the index\nfrom JGit (using GitIndex) and committing from e.g. C Git breaks.\n\nSigned-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>\n---\n .../src/org/spearce/jgit/lib/GitIndex.java         |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\nThis put GitIndex even higher on the kill list, but as always doing\nhalf fixes saves time in the short run.\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java\nindex 21b495a..2ac8ebb 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java\n@@ -60,6 +60,7 @@\n import java.util.Stack;\n import java.util.TreeMap;\n \n+import org.spearce.jgit.dircache.DirCache;\n import org.spearce.jgit.errors.CorruptObjectException;\n import org.spearce.jgit.errors.NotSupportedException;\n import org.spearce.jgit.util.FS;\n@@ -85,6 +86,8 @@\n  *\n  * An index can also contain a tree cache which we ignore for now. We drop the\n  * tree cache when writing the index.\n+ * \n+ * @deprecated Use {@link DirCache} instead.\n  */\n public class GitIndex {\n \n@@ -110,7 +113,7 @@\n \tprivate Map<byte[], Entry> entries = new TreeMap<byte[], Entry>(new Comparator<byte[]>() {\n \t\tpublic int compare(byte[] o1, byte[] o2) {\n \t\t\tfor (int i = 0; i < o1.length && i < o2.length; ++i) {\n-\t\t\t\tint c = o1[i] - o2[i];\n+\t\t\t\tint c = (o1[i] & 0xff) - (o2[i] & 0xff);\n \t\t\t\tif (c != 0)\n \t\t\t\t\treturn c;\n \t\t\t}\n-- \n1.6.3.2.199.g7340d\n"}]}