commit: add repository argument to commit_graft_pos
Add a repository argument to allow callers of commit_graft_pos 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 15, 2018 at 16:42 UTC
be479e801da46b591844467229f003cdcd262e3e
1 file changed
+5
-4
commit.c
+5
-4
@@ -104,7 +104,8 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)
104
return commit_graft_table[index]->oid.hash;
105
}
106
107
-static int commit_graft_pos(const unsigned char *sha1)
107
+#define commit_graft_pos(r, s) commit_graft_pos_##r(s)
108
+static int commit_graft_pos_the_repository(const unsigned char *sha1)
109
{
110
return sha1_pos(sha1, the_repository->parsed_objects->grafts,
111
the_repository->parsed_objects->grafts_nr,
@@ -113,7 +114,7 @@ static int commit_graft_pos(const unsigned char *sha1)
114
115
int register_commit_graft(struct commit_graft *graft, int ignore_dups)
116
{
116
- int pos = commit_graft_pos(graft->oid.hash);
117
+ int pos = commit_graft_pos(the_repository, graft->oid.hash);
118
119
if (0 <= pos) {
120
if (ignore_dups)
@@ -213,7 +214,7 @@ struct commit_graft *lookup_commit_graft(const struct object_id *oid)
214
{
215
int pos;
216
prepare_commit_graft();
216
- pos = commit_graft_pos(oid->hash);
217
+ pos = commit_graft_pos(the_repository, oid->hash);
218
if (pos < 0)
219
return NULL;
220
return the_repository->parsed_objects->grafts[pos];
@@ -229,7 +230,7 @@ int for_each_commit_graft(each_commit_graft_fn fn, void *cb_data)
230
231
int unregister_shallow(const struct object_id *oid)
232
{
232
- int pos = commit_graft_pos(oid->hash);
233
+ int pos = commit_graft_pos(the_repository, oid->hash);
234
if (pos < 0)
235
return -1;
236
if (pos + 1 < the_repository->parsed_objects->grafts_nr)