1367
return 1;
1368
}
1369
1370
-static int fill_included_packs_all(struct repository *r,
1371
- struct multi_pack_index *m,
1372
- unsigned char *include_pack)
1370
+static void fill_included_packs_all(struct repository *r,
1371
+ struct multi_pack_index *m,
1372
+ unsigned char *include_pack)
1373
{
1374
- uint32_t i, count = 0;
1374
+ uint32_t i;
1375
int pack_kept_objects = 0;
1376
1377
repo_config_get_bool(r, "repack.packkeptobjects", &pack_kept_objects);
1381
continue;
1382
1383
include_pack[i] = 1;
1384
- count++;
1384
}
1386
-
1387
- return count < 2;
1385
}
1386
1390
-static int fill_included_packs_batch(struct repository *r,
1391
- struct multi_pack_index *m,
1392
- unsigned char *include_pack,
1393
- size_t batch_size)
1387
+static void fill_included_packs_batch(struct repository *r,
1388
+ struct multi_pack_index *m,
1389
+ unsigned char *include_pack,
1390
+ size_t batch_size)
1391
{
1395
- uint32_t i, packs_to_repack;
1392
+ uint32_t i;
1393
size_t total_size;
1394
struct repack_info *pack_info;
1395
int pack_kept_objects = 0;
1415
QSORT(pack_info, m->num_packs, compare_by_mtime);
1416
1417
total_size = 0;
1421
- packs_to_repack = 0;
1418
for (i = 0; total_size < batch_size && i < m->num_packs; i++) {
1419
int pack_int_id = pack_info[i].pack_int_id;
1420
struct packed_git *p = m->packs[pack_int_id];
1430
if (expected_size >= batch_size)
1431
continue;
1432
1437
- packs_to_repack++;
1433
total_size += expected_size;
1434
include_pack[pack_int_id] = 1;
1435
}
1436
1437
free(pack_info);
1443
-
1444
- if (packs_to_repack < 2)
1445
- return 1;
1446
-
1447
- return 0;
1438
}
1439
1440
int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, unsigned flags)
1441
{
1442
int result = 0;
1453
- uint32_t i;
1443
+ uint32_t i, packs_to_repack = 0;
1444
unsigned char *include_pack;
1445
struct child_process cmd = CHILD_PROCESS_INIT;
1446
FILE *cmd_in;
1459
1460
CALLOC_ARRAY(include_pack, m->num_packs);
1461
1472
- if (batch_size) {
1473
- if (fill_included_packs_batch(r, m, include_pack, batch_size))
1474
- goto cleanup;
1475
- } else if (fill_included_packs_all(r, m, include_pack))
1462
+ if (batch_size)
1463
+ fill_included_packs_batch(r, m, include_pack, batch_size);
1464
+ else
1465
+ fill_included_packs_all(r, m, include_pack);
1466
+
1467
+ for (i = 0; i < m->num_packs; i++) {
1468
+ if (include_pack[i])
1469
+ packs_to_repack++;
1470
+ }
1471
+ if (packs_to_repack <= 1)
1472
goto cleanup;
1473
1474
repo_config_get_bool(r, "repack.usedeltabaseoffset", &delta_base_offset);