From: Robin Rosenberg <robin.rosenberg@dewire.com>
To: git@vger.kernel.org
Cc: David Watson <dwatson@mimvista.com>,
Robin Rosenberg <robin.rosenberg@dewire.com>
Subject: [EGIT PATCH 06/10] Use the proper comparison algorithm
Date: Sun, 24 Feb 2008 00:50:39 +0100 [thread overview]
Message-ID: <1203810643-28819-7-git-send-email-robin.rosenberg@dewire.com> (raw)
In-Reply-To: <1203810643-28819-6-git-send-email-robin.rosenberg@dewire.com>
We must walk in Git sort order.
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
---
.../src/org/spearce/jgit/lib/IndexTreeWalker.java | 31 +------------------
1 files changed, 2 insertions(+), 29 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/IndexTreeWalker.java b/org.spearce.jgit/src/org/spearce/jgit/lib/IndexTreeWalker.java
index 93d5bb2..c17cea1 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/IndexTreeWalker.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/IndexTreeWalker.java
@@ -288,38 +288,11 @@ public class IndexTreeWalker {
}
static int compare(TreeEntry t, Entry i) {
- if (t.getFullName().equals(i.getName())) {
- if (t instanceof Tree)
- return 1;
- return 0;
- }
- return t.getFullName().compareTo(i.getName());
+ return Tree.compareNames(t.getFullNameUTF8(), i.getNameUTF8(), TreeEntry.lastChar(t), TreeEntry.lastChar(i));
}
static int compare(TreeEntry t1, TreeEntry t2) {
- if (t1.getName().equals(t2.getName())) {
- if (t1 instanceof Tree && t2 instanceof Tree)
- return 0;
- if (t1 instanceof Tree)
- return 1;
- if (t2 instanceof Tree)
- return -1;
- return 0;
- }
- return t1.getName().compareTo(t2.getName());
+ return Tree.compareNames(t1.getNameUTF8(), t2.getNameUTF8(), TreeEntry.lastChar(t1), TreeEntry.lastChar(t2));
}
- static int compare(byte[] name1, byte[] name2) {
- for (int i = 0; i < name1.length && i < name2.length; i++) {
- if (name1[i] < name2[i])
- return -1;
- if (name1[i] > name2[i])
- return 1;
- }
- if (name1.length < name2.length)
- return -1;
- if (name2.length < name1.length)
- return 1;
- return 0;
- }
}
--
1.5.4.2
next prev parent reply other threads:[~2008-02-23 23:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-23 23:50 [EGIT] Sort order from hell fixes, take 2 Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 01/10] Tighten IndexDiffTest to make it test better what it claims to test Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 02/10] Extend IndexDiffTest with more tests Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 03/10] WorkdirCheckout: more test for names that are close Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 04/10] Split a big test in ReadTreeTest into smaller tests Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 05/10] Fix git sort order compare bug Robin Rosenberg
2008-02-23 23:50 ` Robin Rosenberg [this message]
2008-02-23 23:50 ` [EGIT PATCH 07/10] GitIndex: Get access to raw name and file mode Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 08/10] TreeEntry: Accessors for full raw name and mode bits Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 09/10] Implement a Tree iterator Robin Rosenberg
2008-02-23 23:50 ` [EGIT PATCH 10/10] Rewritten IndexTreeWalker Robin Rosenberg
2008-03-03 14:17 ` [EGIT] Sort order from hell fixes, take 2 David Watson
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=1203810643-28819-7-git-send-email-robin.rosenberg@dewire.com \
--to=robin.rosenberg@dewire.com \
--cc=dwatson@mimvista.com \
--cc=git@vger.kernel.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).