1479
return 0;
1480
}
1481
1482
+static int add_packed_commits_oi(const struct object_id *oid,
1483
+ struct object_info *oi,
1484
+ void *data)
1485
+{
1486
+ struct write_commit_graph_context *ctx = (struct write_commit_graph_context*)data;
1487
+
1488
+ if (ctx->progress)
1489
+ display_progress(ctx->progress, ++ctx->progress_done);
1490
+
1491
+ if (*oi->typep != OBJ_COMMIT)
1492
+ return 0;
1493
+
1494
+ oid_array_append(&ctx->oids, oid);
1495
+ set_commit_pos(ctx->r, oid);
1496
+
1497
+ return 0;
1498
+}
1499
+
1500
static int add_packed_commits(const struct object_id *oid,
1501
struct packed_git *pack,
1502
uint32_t pos,
1503
void *data)
1504
{
1487
- struct write_commit_graph_context *ctx = (struct write_commit_graph_context*)data;
1505
enum object_type type;
1506
off_t offset = nth_packed_object_offset(pack, pos);
1507
struct object_info oi = OBJECT_INFO_INIT;
1508
1492
- if (ctx->progress)
1493
- display_progress(ctx->progress, ++ctx->progress_done);
1494
-
1509
oi.typep = &type;
1510
if (packed_object_info(pack, offset, &oi) < 0)
1511
die(_("unable to get type of object %s"), oid_to_hex(oid));
1512
1499
- if (type != OBJ_COMMIT)
1500
- return 0;
1501
-
1502
- oid_array_append(&ctx->oids, oid);
1503
- set_commit_pos(ctx->r, oid);
1504
-
1505
- return 0;
1513
+ return add_packed_commits_oi(oid, &oi, data);
1514
}
1515
1516
static void add_missing_parents(struct write_commit_graph_context *ctx, struct commit *commit)
1967
1968
static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)
1969
{
1970
+ struct odb_source *source;
1971
+ enum object_type type;
1972
+ struct object_info oi = {
1973
+ .typep = &type,
1974
+ };
1975
+
1976
if (ctx->report_progress)
1977
ctx->progress = start_delayed_progress(
1978
ctx->r,
1979
_("Finding commits for commit graph among packed objects"),
1980
ctx->approx_nr_objects);
1967
- for_each_packed_object(ctx->r, add_packed_commits, ctx,
1968
- ODB_FOR_EACH_OBJECT_PACK_ORDER);
1981
+
1982
+ odb_prepare_alternates(ctx->r->objects);
1983
+ for (source = ctx->r->objects->sources; source; source = source->next)
1984
+ packfile_store_for_each_object(source->packfiles, &oi, add_packed_commits_oi,
1985
+ ctx, ODB_FOR_EACH_OBJECT_PACK_ORDER);
1986
+
1987
if (ctx->progress_done < ctx->approx_nr_objects)
1988
display_progress(ctx->progress, ctx->approx_nr_objects);
1989
stop_progress(&ctx->progress);