From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: spearce@spearce.org
Cc: git@vger.kernel.org, Robin Rosenberg <robin.rosenberg@dewire.com>
Subject: [JGIT PATCH] Fix sort order in GitIndex and mark it as deprecated
Date: Tue, 23 Jun 2009 23:45:23 +0200 [thread overview]
Message-ID: <1245793523-28787-1-git-send-email-robin.rosenberg@dewire.com> (raw)
We were using signed comparisons for ordering entries here which is so
terribly wrong and sometimes breaks when using non-ascii characters.
Due to other mechanisms this went undetected when committing from JGit,
because the order in trees were usually corrected, but updating the index
from JGit (using GitIndex) and committing from e.g. C Git breaks.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/lib/GitIndex.java | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
This put GitIndex even higher on the kill list, but as always doing
half fixes saves time in the short run.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
index 21b495a..2ac8ebb 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/GitIndex.java
@@ -60,6 +60,7 @@
import java.util.Stack;
import java.util.TreeMap;
+import org.spearce.jgit.dircache.DirCache;
import org.spearce.jgit.errors.CorruptObjectException;
import org.spearce.jgit.errors.NotSupportedException;
import org.spearce.jgit.util.FS;
@@ -85,6 +86,8 @@
*
* An index can also contain a tree cache which we ignore for now. We drop the
* tree cache when writing the index.
+ *
+ * @deprecated Use {@link DirCache} instead.
*/
public class GitIndex {
@@ -110,7 +113,7 @@
private Map<byte[], Entry> entries = new TreeMap<byte[], Entry>(new Comparator<byte[]>() {
public int compare(byte[] o1, byte[] o2) {
for (int i = 0; i < o1.length && i < o2.length; ++i) {
- int c = o1[i] - o2[i];
+ int c = (o1[i] & 0xff) - (o2[i] & 0xff);
if (c != 0)
return c;
}
--
1.6.3.2.199.g7340d
reply other threads:[~2009-06-23 21:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1245793523-28787-1-git-send-email-robin.rosenberg@dewire.com \
--to=robin.rosenberg@dewire.com \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).