commit: add repository argument to lookup_commit_graft

Add a repository argument to allow callers of lookup_commit_graft to be more specific about which repository to handle. This is a small mechanical change; it doesn't change the implementation to handle repositories other than the_repository yet. As with the previous commits, use a macro to catch callers passing a repository other than the_repository at compile time. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed May 17, 2018 at 15:51 UTC 1f93ecd1ab15800fa98a0ce3efa5166fa642ab80
4 files changed +8 -6
commit.c
+2 -2
@@ -212,7 +212,7 @@ static void prepare_commit_graft_the_repository(void)
212 commit_graft_prepared = 1;
213 }
214
215 -struct commit_graft *lookup_commit_graft(const struct object_id *oid)
215 +struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid)
216 {
217 int pos;
218 prepare_commit_graft(the_repository);
@@ -359,7 +359,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
359 bufptr += tree_entry_len + 1; /* "tree " + "hex sha1" + "\n" */
360 pptr = &item->parents;
361
362 - graft = lookup_commit_graft(&item->object.oid);
362 + graft = lookup_commit_graft(the_repository, &item->object.oid);
363 while (bufptr + parent_entry_len < tail && !memcmp(bufptr, "parent ", 7)) {
364 struct commit *new_parent;
365
commit.h
+2 -1
@@ -176,7 +176,8 @@ typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);
176 struct commit_graft *read_graft_line(struct strbuf *line);
177 #define register_commit_graft(r, g, i) register_commit_graft_##r(g, i)
178 int register_commit_graft_the_repository(struct commit_graft *, int);
179 -struct commit_graft *lookup_commit_graft(const struct object_id *oid);
179 +#define lookup_commit_graft(r, o) lookup_commit_graft_##r(o)
180 +struct commit_graft *lookup_commit_graft_the_repository(const struct object_id *oid);
181
182 extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2);
183 extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos);
fsck.c
+1 -1
@@ -738,7 +738,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
738 buffer += 41;
739 parent_line_count++;
740 }
741 - graft = lookup_commit_graft(&commit->object.oid);
741 + graft = lookup_commit_graft(the_repository, &commit->object.oid);
742 parent_count = commit_list_count(commit->parents);
743 if (graft) {
744 if (graft->nr_parent == -1 && !parent_count)
shallow.c
+3 -2
@@ -109,7 +109,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
109 cur_depth++;
110 if ((depth != INFINITE_DEPTH && cur_depth >= depth) ||
111 (is_repository_shallow() && !commit->parents &&
112 - (graft = lookup_commit_graft(&commit->object.oid)) != NULL &&
112 + (graft = lookup_commit_graft(the_repository, &commit->object.oid)) != NULL &&
113 graft->nr_parent < 0)) {
114 commit_list_insert(commit, &result);
115 commit->object.flags |= shallow_flag;
@@ -398,7 +398,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa)
398 for (i = 0; i < sa->nr; i++) {
399 if (has_object_file(sa->oid + i)) {
400 struct commit_graft *graft;
401 - graft = lookup_commit_graft(&sa->oid[i]);
401 + graft = lookup_commit_graft(the_repository,
402 + &sa->oid[i]);
403 if (graft && graft->nr_parent < 0)
404 continue;
405 info->ours[info->nr_ours++] = i;