Skip to content

Commit 9b19ada

Browse files
derrickstoleegitster
authored andcommitted
commit: force commit to parse from object database
In anticipation of verifying commit-graph file contents against the object database, create parse_commit_internal() to allow side-stepping the commit-graph file and parse directly from the object database. Due to the use of generation numbers, this method should not be called unless the intention is explicit in avoiding commits from the commit-graph file. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ee79705 commit 9b19ada

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

commit.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
418418
return 0;
419419
}
420420

421-
int parse_commit_gently(struct commit *item, int quiet_on_missing)
421+
int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph)
422422
{
423423
enum object_type type;
424424
void *buffer;
@@ -429,7 +429,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)
429429
return -1;
430430
if (item->object.parsed)
431431
return 0;
432-
if (parse_commit_in_graph(item))
432+
if (use_commit_graph && parse_commit_in_graph(item))
433433
return 0;
434434
buffer = read_object_file(&item->object.oid, &type, &size);
435435
if (!buffer)
@@ -441,6 +441,7 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)
441441
return error("Object %s not a commit",
442442
oid_to_hex(&item->object.oid));
443443
}
444+
444445
ret = parse_commit_buffer(item, buffer, size, 0);
445446
if (save_commit_buffer && !ret) {
446447
set_commit_buffer(item, buffer, size);
@@ -450,6 +451,11 @@ int parse_commit_gently(struct commit *item, int quiet_on_missing)
450451
return ret;
451452
}
452453

454+
int parse_commit_gently(struct commit *item, int quiet_on_missing)
455+
{
456+
return parse_commit_internal(item, quiet_on_missing, 1);
457+
}
458+
453459
void parse_commit_or_die(struct commit *item)
454460
{
455461
if (parse_commit(item))

commit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);
7777
struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);
7878

7979
int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size, int check_graph);
80+
int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph);
8081
int parse_commit_gently(struct commit *item, int quiet_on_missing);
8182
static inline int parse_commit(struct commit *item)
8283
{

0 commit comments

Comments
 (0)