repo-config: trim white-space before comment
[gitweb.git] / pack-objects.c
index 09f4f2c944d95bb145823c0b07f4a7f302bcab1f..66043381317b118dd525d547479d81b75d6b89f8 100644 (file)
@@ -1032,12 +1032,6 @@ static int try_delta(struct unpacked *cur, struct unpacked *old, unsigned max_de
                max_depth -= cur_entry->delta_limit;
        }
 
-       size = cur_entry->size;
-       oldsize = old_entry->size;
-       sizediff = oldsize > size ? oldsize - size : size - oldsize;
-
-       if (size < 50)
-               return -1;
        if (old_entry->depth >= max_depth)
                return 0;
 
@@ -1048,11 +1042,14 @@ static int try_delta(struct unpacked *cur, struct unpacked *old, unsigned max_de
         * more space-efficient (deletes don't have to say _what_ they
         * delete).
         */
+       size = cur_entry->size;
        max_size = size / 2 - 20;
        if (cur_entry->delta)
                max_size = cur_entry->delta_size-1;
+       oldsize = old_entry->size;
+       sizediff = oldsize < size ? size - oldsize : 0;
        if (sizediff >= max_size)
-               return -1;
+               return 0;
        delta_buf = diff_delta(old->data, oldsize,
                               cur->data, size, &delta_size, max_size);
        if (!delta_buf)
@@ -1109,6 +1106,9 @@ static void find_deltas(struct object_entry **list, int window, int depth)
                         */
                        continue;
 
+               if (entry->size < 50)
+                       continue;
+
                free(n->data);
                n->entry = entry;
                n->data = read_sha1_file(entry->sha1, type, &size);
@@ -1231,7 +1231,7 @@ static void setup_progress_signal(void)
 int main(int argc, char **argv)
 {
        SHA_CTX ctx;
-       char line[PATH_MAX + 20];
+       char line[40 + 1 + PATH_MAX + 2];
        int window = 10, depth = 10, pack_to_stdout = 0;
        struct object_entry **list;
        int num_preferred_base = 0;