commit: allow parse_commit* to handle any repo
Just like the previous commit, parse_commit and friends are used a lot and are found in new patches, so we cannot change their signature easily. Re-introduce these function prefixed with 'repo_' that take a repository argument and keep the original as a shallow macro. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
d1a6902265
commit
9e5252abd1
18
commit.c
18
commit.c
@ -443,7 +443,10 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_commit_graph)
|
||||
int repo_parse_commit_internal(struct repository *r,
|
||||
struct commit *item,
|
||||
int quiet_on_missing,
|
||||
int use_commit_graph)
|
||||
{
|
||||
enum object_type type;
|
||||
void *buffer;
|
||||
@ -454,9 +457,9 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com
|
||||
return -1;
|
||||
if (item->object.parsed)
|
||||
return 0;
|
||||
if (use_commit_graph && parse_commit_in_graph(the_repository, item))
|
||||
if (use_commit_graph && parse_commit_in_graph(r, item))
|
||||
return 0;
|
||||
buffer = read_object_file(&item->object.oid, &type, &size);
|
||||
buffer = repo_read_object_file(r, &item->object.oid, &type, &size);
|
||||
if (!buffer)
|
||||
return quiet_on_missing ? -1 :
|
||||
error("Could not read %s",
|
||||
@ -467,18 +470,19 @@ int parse_commit_internal(struct commit *item, int quiet_on_missing, int use_com
|
||||
oid_to_hex(&item->object.oid));
|
||||
}
|
||||
|
||||
ret = parse_commit_buffer(the_repository, item, buffer, size, 0);
|
||||
ret = parse_commit_buffer(r, item, buffer, size, 0);
|
||||
if (save_commit_buffer && !ret) {
|
||||
set_commit_buffer(the_repository, item, buffer, size);
|
||||
set_commit_buffer(r, item, buffer, size);
|
||||
return 0;
|
||||
}
|
||||
free(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int parse_commit_gently(struct commit *item, int quiet_on_missing)
|
||||
int repo_parse_commit_gently(struct repository *r,
|
||||
struct commit *item, int quiet_on_missing)
|
||||
{
|
||||
return parse_commit_internal(item, quiet_on_missing, 1);
|
||||
return repo_parse_commit_internal(r, item, quiet_on_missing, 1);
|
||||
}
|
||||
|
||||
void parse_commit_or_die(struct commit *item)
|
||||
|
Reference in New Issue
Block a user