]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-pack-objects.c
Merge branch 'maint-1.6.1' into maint
[git.git] / builtin-pack-objects.c
index b616994f4587b9a3d0133b7d6694020743ea0a4d..8ca46c8deb09a4c7d32947033eab804b108e0a34 100644 (file)
@@ -78,7 +78,7 @@ static int progress = 1;
 static int window = 10;
 static uint32_t pack_size_limit, pack_size_limit_cfg;
 static int depth = 50;
-static int delta_search_threads = 1;
+static int delta_search_threads;
 static int pack_to_stdout;
 static int num_preferred_base;
 static struct progress *progress_state;
@@ -488,9 +488,8 @@ static void write_pack_file(void)
                } else {
                        char tmpname[PATH_MAX];
                        int fd;
-                       snprintf(tmpname, sizeof(tmpname),
-                                "%s/pack/tmp_pack_XXXXXX", get_object_directory());
-                       fd = xmkstemp(tmpname);
+                       fd = odb_mkstemp(tmpname, sizeof(tmpname),
+                                        "pack/tmp_pack_XXXXXX");
                        pack_tmp_name = xstrdup(tmpname);
                        f = sha1fd(fd, pack_tmp_name);
                }
@@ -1294,7 +1293,7 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
                max_size = trg_entry->delta_size;
                ref_depth = trg->depth;
        }
-       max_size = max_size * (max_depth - src->depth) /
+       max_size = (uint64_t)max_size * (max_depth - src->depth) /
                                                (max_depth - ref_depth + 1);
        if (max_size == 0)
                return 0;
@@ -1612,11 +1611,18 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
                find_deltas(list, &list_size, window, depth, processed);
                return;
        }
+       if (progress > pack_to_stdout)
+               fprintf(stderr, "Delta compression using %d threads.\n",
+                               delta_search_threads);
 
        /* Partition the work amongst work threads. */
        for (i = 0; i < delta_search_threads; i++) {
                unsigned sub_size = list_size / (delta_search_threads - i);
 
+               /* don't use too small segments or no deltas will be found */
+               if (sub_size < 2*window && i+1 < delta_search_threads)
+                       sub_size = 0;
+
                p[i].window = window;
                p[i].depth = depth;
                p[i].processed = processed;