commit.c: allow parse_commit_buffer to handle arbitrary repositories
Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Jun 28, 2018 at 18:22 UTC
fd8030c739522acf3f55879b29f4716b36f4d440
2 files changed
+6
-7
commit.c
+5
-5
@@ -364,7 +364,7 @@ const void *detach_commit_buffer(struct commit *commit, unsigned long *sizep)
364
return ret;
365
}
366
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)
368
{
369
const char *tail = buffer;
370
const char *bufptr = buffer;
@@ -384,11 +384,11 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,
384
if (get_oid_hex(bufptr + 5, &parent) < 0)
385
return error("bad tree pointer in commit %s",
386
oid_to_hex(&item->object.oid));
387
- item->maybe_tree = lookup_tree(the_repository, &parent);
387
+ item->maybe_tree = lookup_tree(r, &parent);
388
bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
389
pptr = &item->parents;
390
391
- graft = lookup_commit_graft(the_repository, &item->object.oid);
391
+ graft = lookup_commit_graft(r, &item->object.oid);
392
while (bufptr + parent_entry_len < tail && !memcmp(bufptr, "parent ", 7)) {
393
struct commit *new_parent;
394
@@ -403,7 +403,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,
403
*/
404
if (graft && (graft->nr_parent < 0 || grafts_replace_parents))
405
continue;
406
- new_parent = lookup_commit(the_repository, &parent);
406
+ new_parent = lookup_commit(r, &parent);
407
if (new_parent)
408
pptr = &commit_list_insert(new_parent, pptr)->next;
409
}
@@ -411,7 +411,7 @@ int parse_commit_buffer_the_repository(struct commit *item, const void *buffer,
411
int i;
412
struct commit *new_parent;
413
for (i = 0; i < graft->nr_parent; i++) {
414
- new_parent = lookup_commit(the_repository,
414
+ new_parent = lookup_commit(r,
415
&graft->parent[i]);
416
if (!new_parent)
417
continue;
commit.h
+1
-2
@@ -81,8 +81,7 @@ struct commit *lookup_commit_reference_by_name(const char *name);
81
*/
82
struct commit *lookup_commit_or_die(const struct object_id *oid, const char *ref_name);
83
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);
85
int parse_commit_gently(struct commit *item, int quiet_on_missing);
86
static inline int parse_commit(struct commit *item)
87
{