Skip to content

Commit fd8030c

Browse files
stefanbellergitster
authored andcommitted
commit.c: allow parse_commit_buffer to handle arbitrary repositories
Signed-off-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 84f80cd commit fd8030c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

commit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)
364364
return ret;
365365
}
366366

367-
int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph)
367+
int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph)
368368
{
369369
const char *tail = buffer;
370370
const char *bufptr = buffer;
@@ -384,11 +384,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,
384384
if (get_oid_hex(bufptr + 5, &parent) < 0)
385385
return error("bad tree pointer in commit %s",
386386
oid_to_hex(&item->object.oid));
387-
item->maybe_tree = lookup_tree(the_repository, &parent);
387+
item->maybe_tree = lookup_tree(r, &parent);
388388
bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
389389
pptr = &item->parents;
390390

391-
graft = lookup_commit_graft(the_repository, &item->object.oid);
391+
graft = lookup_commit_graft(r, &item->object.oid);
392392
while (bufptr + parent_entry_len < tail && !memcmp(bufptr, "parent ", 7)) {
393393
struct commit *new_parent;
394394

@@ -403,15 +403,15 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,
403403
*/
404404
if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
405405
continue;
406-
new_parent = lookup_commit(the_repository, &parent);
406+
new_parent = lookup_commit(r, &parent);
407407
if (new_parent)
408408
pptr = &commit_list_insert(new_parent, pptr)->next;
409409
}
410410
if (graft) {
411411
int i;
412412
struct commit *new_parent;
413413
for (i = 0; i < graft->nr_parent; i++) {
414-
new_parent = lookup_commit(the_repository,
414+
new_parent = lookup_commit(r,
415415
&graft->parent[i]);
416416
if (!new_parent)
417417
continue;

commit.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);
8181
*/
8282
struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);
8383

84-
#define parse_commit_buffer(r, i, b, s, g) parse_commit_buffer_##r(i, b, s, g)
85-
int parse_commit_buffer_the_repository(struct commit *item, const void *buffer, unsigned long size, int check_graph);
84+
int parse_commit_buffer(struct repository *r, struct commit *item, const void *buffer, unsigned long size, int check_graph);
8685
int parse_commit_gently(struct commit *item, int quiet_on_missing);
8786
static inline int parse_commit(struct commit *item)
8887
{

0 commit comments

Comments
 (0)