Commit 5bf42916378b49f2790b4da91cb056cd9e08f686

John Wiegley 2011-02-07T00:11:00

Further correction to tree entry sorting (for git fsck)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
diff --git a/src/tree.c b/src/tree.c
index d71cd37..bf1cdfa 100644
--- a/src/tree.c
+++ b/src/tree.c
@@ -50,10 +50,10 @@ static int cache_name_compare(const char *name1, int len1, int isdir1,
 	if (cmp)
 		return cmp;
 	if (len1 < len2)
-		return ((isdir1 == isdir2) ? -1 :
+		return ((!isdir1 && !isdir2) ? -1 :
                         (isdir1 ? '/' - name2[len1] : name2[len1] - '/'));
 	if (len1 > len2)
-		return ((isdir1 == isdir2) ? 1 :
+		return ((!isdir1 && !isdir2) ? 1 :
                         (isdir2 ? name1[len2] - '/' : '/' - name1[len2]));
 	return 0;
 }