rearrange delta search progress reporting
This is to help threadification of the delta search code, with a bonus consistency check. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nicolas Pitre committed
Sep 6, 2007 at 02:13 UTC
e334977dfad575cd8ac1a9e5f8e73fe4d018cec0
1 file changed
+14
-9
builtin-pack-objects.c
+14
-9
@@ -1438,17 +1438,15 @@ static unsigned long free_unpacked(struct unpacked *n)
1438
}
1439
1440
static void find_deltas(struct object_entry **list, unsigned list_size,
1441
- unsigned nr_deltas, int window, int depth)
1441
+ int window, int depth, unsigned *processed)
1442
{
1443
- uint32_t i = list_size, idx = 0, count = 0, processed = 0;
1443
+ uint32_t i = list_size, idx = 0, count = 0;
1444
unsigned int array_size = window * sizeof(struct unpacked);
1445
struct unpacked *array;
1446
unsigned long mem_usage = 0;
1447
1448
array = xmalloc(array_size);
1449
memset(array, 0, array_size);
1450
- if (progress)
1451
- start_progress(&progress_state, "Deltifying %u objects...", "", nr_deltas);
1450
1451
do {
1452
struct object_entry *entry = list[--i];
@@ -1472,8 +1470,9 @@ static void find_deltas(struct object_entry **list, unsigned list_size,
1470
if (entry->preferred_base)
1471
goto next;
1472
1473
+ (*processed)++;
1474
if (progress)
1476
- display_progress(&progress_state, ++processed);
1475
+ display_progress(&progress_state, *processed);
1476
1477
/*
1478
* If the current object is at pack edge, take the depth the
@@ -1536,9 +1535,6 @@ static void find_deltas(struct object_entry **list, unsigned list_size,
1535
idx = 0;
1536
} while (i > 0);
1537
1539
- if (progress)
1540
- stop_progress(&progress_state);
1541
-
1538
for (i = 0; i < window; ++i) {
1539
free_delta_index(array[i].index);
1540
free(array[i].data);
@@ -1581,8 +1577,17 @@ static void prepare_pack(int window, int depth)
1577
}
1578
1579
if (nr_deltas) {
1580
+ unsigned nr_done = 0;
1581
+ if (progress)
1582
+ start_progress(&progress_state,
1583
+ "Deltifying %u objects...", "",
1584
+ nr_deltas);
1585
qsort(delta_list, n, sizeof(*delta_list), type_size_sort);
1585
- find_deltas(delta_list, n, nr_deltas, window+1, depth);
1586
+ find_deltas(delta_list, n, window+1, depth, &nr_done);
1587
+ if (progress)
1588
+ stop_progress(&progress_state);
1589
+ if (nr_done != nr_deltas)
1590
+ die("inconsistency with delta count");
1591
}
1592
free(delta_list);
1593
}