Code

Merge branch 'jc/diff' into next
[git.git] / pack-objects.c
index 526c090c619530a5fa61bc7530dee5002bab0ea1..566a2a2349871d05378b1b8de27d315b7451f89c 100644 (file)
@@ -10,7 +10,6 @@
 #include "tree-walk.h"
 #include <sys/time.h>
 #include <signal.h>
-#include <stdint.h>
 
 static const char pack_usage[] = "git-pack-objects [-q] [--no-reuse-delta] [--non-empty] [--local] [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list";
 
@@ -157,7 +156,7 @@ static void prepare_pack_revindex(struct pack_revindex *rix)
 
        rix->revindex = xmalloc(sizeof(unsigned long) * (num_ent + 1));
        for (i = 0; i < num_ent; i++) {
-               uint32_t hl = *((uint32_t *)(index + 24 * i));
+               unsigned int hl = *((unsigned int *)(index + 24 * i));
                rix->revindex[i] = ntohl(hl);
        }
        /* This knows the pack format -- the 20-byte trailer
@@ -1105,17 +1104,14 @@ static void find_deltas(struct object_entry **list, int window, int depth)
 
                if (entry->size < 50)
                        continue;
-               if (n->index)
-                       free_delta_index(n->index);
+               free_delta_index(n->index);
+               n->index = NULL;
                free(n->data);
                n->entry = entry;
                n->data = read_sha1_file(entry->sha1, type, &size);
                if (size != entry->size)
                        die("object %s inconsistent object length (%lu vs %lu)",
                            sha1_to_hex(entry->sha1), size, entry->size);
-               n->index = create_delta_index(n->data, size);
-               if (!n->index)
-                       die("out of memory");
 
                j = window;
                while (--j > 0) {
@@ -1135,6 +1131,11 @@ static void find_deltas(struct object_entry **list, int window, int depth)
                 */
                if (entry->delta && depth <= entry->depth)
                        continue;
+
+               n->index = create_delta_index(n->data, size);
+               if (!n->index)
+                       die("out of memory");
+
                idx++;
                if (idx >= window)
                        idx = 0;
@@ -1144,8 +1145,7 @@ static void find_deltas(struct object_entry **list, int window, int depth)
                fputc('\n', stderr);
 
        for (i = 0; i < window; ++i) {
-               if (array[i].index)
-                       free_delta_index(array[i].index);
+               free_delta_index(array[i].index);
                free(array[i].data);
        }
        free(array);