summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--fsck-objects.c13
2 files changed, 17 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index b4741ff..334fe4e 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,8 @@ all:
# Define NO_EXPAT if you do not have expat installed. git-http-push is
# not built, and you cannot push using http:// and https:// transports.
#
+# Define NO_D_INO_IN_DIRENT if you don't have d_ino in your struct dirent.
+#
# Define NO_STRCASESTR if you don't have strcasestr.
#
# Define NO_SETENV if you don't have setenv in the C library.
@@ -234,6 +236,7 @@ ifeq ($(uname_S),SunOS)
ALL_CFLAGS += -D__EXTENSIONS__
endif
ifeq ($(uname_O),Cygwin)
+ NO_D_INO_IN_DIRENT = YesPlease
NO_STRCASESTR = YesPlease
NEEDS_LIBICONV = YesPlease
# There are conflicting reports about this.
@@ -334,6 +337,9 @@ ifdef NEEDS_NSL
LIBS += -lnsl
SIMPLE_LIB += -lnsl
endif
+ifdef NO_D_INO_IN_DIRENT
+ ALL_CFLAGS += -DNO_D_INO_IN_DIRENT
+endif
ifdef NO_STRCASESTR
COMPAT_CFLAGS += -DNO_STRCASESTR
COMPAT_OBJS += compat/strcasestr.o
diff --git a/fsck-objects.c b/fsck-objects.c
index 90e638e..9950be2 100644
--- a/fsck-objects.c
+++ b/fsck-objects.c
@@ -20,6 +20,13 @@ static int check_strict = 0;
static int keep_cache_objects = 0;
static unsigned char head_sha1[20];
+#if NO_D_INO_IN_DIRENT
+#define SORT_DIRENT 0
+#define DIRENT_SORT_HINT(de) 0
+#else
+#define SORT_DIRENT 1
+#define DIRENT_SORT_HINT(de) ((de)->d_ino)
+#endif
static void objreport(struct object *obj, const char *severity,
const char *err, va_list params)
@@ -307,7 +314,9 @@ static void fsck_sha1_list(void)
{
int i, nr = sha1_list.nr;
- qsort(sha1_list.entry, nr, sizeof(struct sha1_entry *), ino_compare);
+ if (SORT_DIRENT)
+ qsort(sha1_list.entry, nr,
+ sizeof(struct sha1_entry *), ino_compare);
for (i = 0; i < nr; i++) {
struct sha1_entry *entry = sha1_list.entry[i];
unsigned char *sha1 = entry->sha1;
@@ -361,7 +370,7 @@ static int fsck_dir(int i, char *path)
memcpy(name+2, de->d_name, len+1);
if (get_sha1_hex(name, sha1) < 0)
break;
- add_sha1_list(sha1, de->d_ino);
+ add_sha1_list(sha1, DIRENT_SORT_HINT(de));
continue;
}
fprintf(stderr, "bad sha1 file: %s/%s\n", path, de->d_name);