mirror of
https://github.com/git/git.git
synced 2026-02-27 18:29:43 +00:00
Merge branch 'ps/odb-for-each-object' into ps/odb-sources
* ps/odb-for-each-object:
odb: drop unused `for_each_{loose,packed}_object()` functions
reachable: convert to use `odb_for_each_object()`
builtin/pack-objects: use `packfile_store_for_each_object()`
odb: introduce mtime fields for object info requests
treewide: drop uses of `for_each_{loose,packed}_object()`
treewide: enumerate promisor objects via `odb_for_each_object()`
builtin/fsck: refactor to use `odb_for_each_object()`
odb: introduce `odb_for_each_object()`
packfile: introduce function to iterate through objects
packfile: extract function to iterate through objects of a store
object-file: introduce function to iterate through objects
object-file: extract function to read object info from path
odb: fix flags parameter to be unsigned
odb: rename `FOR_EACH_OBJECT_*` flags
This commit is contained in:
@@ -1479,24 +1479,16 @@ static int write_graph_chunk_bloom_data(struct hashfile *f,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_packed_commits(const struct object_id *oid,
|
||||
struct packed_git *pack,
|
||||
uint32_t pos,
|
||||
void *data)
|
||||
static int add_packed_commits_oi(const struct object_id *oid,
|
||||
struct object_info *oi,
|
||||
void *data)
|
||||
{
|
||||
struct write_commit_graph_context *ctx = (struct write_commit_graph_context*)data;
|
||||
enum object_type type;
|
||||
off_t offset = nth_packed_object_offset(pack, pos);
|
||||
struct object_info oi = OBJECT_INFO_INIT;
|
||||
|
||||
if (ctx->progress)
|
||||
display_progress(ctx->progress, ++ctx->progress_done);
|
||||
|
||||
oi.typep = &type;
|
||||
if (packed_object_info(pack, offset, &oi) < 0)
|
||||
die(_("unable to get type of object %s"), oid_to_hex(oid));
|
||||
|
||||
if (type != OBJ_COMMIT)
|
||||
if (*oi->typep != OBJ_COMMIT)
|
||||
return 0;
|
||||
|
||||
oid_array_append(&ctx->oids, oid);
|
||||
@@ -1505,6 +1497,22 @@ static int add_packed_commits(const struct object_id *oid,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int add_packed_commits(const struct object_id *oid,
|
||||
struct packed_git *pack,
|
||||
uint32_t pos,
|
||||
void *data)
|
||||
{
|
||||
enum object_type type;
|
||||
off_t offset = nth_packed_object_offset(pack, pos);
|
||||
struct object_info oi = OBJECT_INFO_INIT;
|
||||
|
||||
oi.typep = &type;
|
||||
if (packed_object_info(pack, offset, &oi) < 0)
|
||||
die(_("unable to get type of object %s"), oid_to_hex(oid));
|
||||
|
||||
return add_packed_commits_oi(oid, &oi, data);
|
||||
}
|
||||
|
||||
static void add_missing_parents(struct write_commit_graph_context *ctx, struct commit *commit)
|
||||
{
|
||||
struct commit_list *parent;
|
||||
@@ -1927,7 +1935,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
|
||||
goto cleanup;
|
||||
}
|
||||
for_each_object_in_pack(p, add_packed_commits, ctx,
|
||||
FOR_EACH_OBJECT_PACK_ORDER);
|
||||
ODB_FOR_EACH_OBJECT_PACK_ORDER);
|
||||
close_pack(p);
|
||||
free(p);
|
||||
}
|
||||
@@ -1959,13 +1967,23 @@ static int fill_oids_from_commits(struct write_commit_graph_context *ctx,
|
||||
|
||||
static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)
|
||||
{
|
||||
struct odb_source *source;
|
||||
enum object_type type;
|
||||
struct object_info oi = {
|
||||
.typep = &type,
|
||||
};
|
||||
|
||||
if (ctx->report_progress)
|
||||
ctx->progress = start_delayed_progress(
|
||||
ctx->r,
|
||||
_("Finding commits for commit graph among packed objects"),
|
||||
ctx->approx_nr_objects);
|
||||
for_each_packed_object(ctx->r, add_packed_commits, ctx,
|
||||
FOR_EACH_OBJECT_PACK_ORDER);
|
||||
|
||||
odb_prepare_alternates(ctx->r->objects);
|
||||
for (source = ctx->r->objects->sources; source; source = source->next)
|
||||
packfile_store_for_each_object(source->packfiles, &oi, add_packed_commits_oi,
|
||||
ctx, ODB_FOR_EACH_OBJECT_PACK_ORDER);
|
||||
|
||||
if (ctx->progress_done < ctx->approx_nr_objects)
|
||||
display_progress(ctx->progress, ctx->approx_nr_objects);
|
||||
stop_progress(&ctx->progress);
|
||||
|
||||
Reference in New Issue
Block a user