fsck: disallow demoting grave fsck errors to warnings
[gitweb.git] / sha1_file.c
index ccc6dac54b570d7174175242ba2d535d4006ab1c..50384754e50d5f45f4a15304a11a4974cc1c063e 100644 (file)
@@ -707,8 +707,8 @@ static void mmap_limit_check(size_t length)
                    (uintmax_t)length, (uintmax_t)limit);
 }
 
-void *xmmap(void *start, size_t length,
-       int prot, int flags, int fd, off_t offset)
+void *xmmap_gently(void *start, size_t length,
+                 int prot, int flags, int fd, off_t offset)
 {
        void *ret;
 
@@ -719,12 +719,19 @@ void *xmmap(void *start, size_t length,
                        return NULL;
                release_pack_memory(length);
                ret = mmap(start, length, prot, flags, fd, offset);
-               if (ret == MAP_FAILED)
-                       die_errno("Out of memory? mmap failed");
        }
        return ret;
 }
 
+void *xmmap(void *start, size_t length,
+       int prot, int flags, int fd, off_t offset)
+{
+       void *ret = xmmap_gently(start, length, prot, flags, fd, offset);
+       if (ret == MAP_FAILED)
+               die_errno("mmap failed");
+       return ret;
+}
+
 void close_pack_windows(struct packed_git *p)
 {
        while (p->windows) {
@@ -3286,7 +3293,7 @@ static int index_core(unsigned char *sha1, int fd, size_t size,
        int ret;
 
        if (!size) {
-               ret = index_mem(sha1, NULL, size, type, path, flags);
+               ret = index_mem(sha1, "", size, type, path, flags);
        } else if (size <= SMALL_FILE_SIZE) {
                char *buf = xmalloc(size);
                if (size == read_in_full(fd, buf, size))