commit: add repository argument to register_commit_graft
Add a repository argument to allow callers of register_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 15, 2018 at 16:42 UTC
3f5787f80662b8f5dbd6fb83d5ca20be224e8a08
4 files changed
+8
-5
builtin/blame.c
+2
-1
@@ -8,6 +8,7 @@
8
#include "cache.h"
9
#include "config.h"
10
#include "builtin.h"
11
+#include "repository.h"
12
#include "commit.h"
13
#include "diff.h"
14
#include "revision.h"
@@ -491,7 +492,7 @@ static int read_ancestry(const char *graft_file)
492
/* The format is just "Commit Parent1 Parent2 ...\n" */
493
struct commit_graft *graft = read_graft_line(&buf);
494
if (graft)
494
- register_commit_graft(graft, 0);
495
+ register_commit_graft(the_repository, graft, 0);
496
}
497
fclose(fp);
498
strbuf_release(&buf);
commit.c
+2
-2
@@ -112,7 +112,7 @@ static int commit_graft_pos_the_repository(const unsigned char *sha1)
112
commit_graft_sha1_access);
113
}
114
115
-int register_commit_graft(struct commit_graft *graft, int ignore_dups)
115
+int register_commit_graft_the_repository(struct commit_graft *graft, int ignore_dups)
116
{
117
int pos = commit_graft_pos(the_repository, graft->oid.hash);
118
@@ -188,7 +188,7 @@ static int read_graft_file(const char *graft_file)
188
struct commit_graft *graft = read_graft_line(&buf);
189
if (!graft)
190
continue;
191
- if (register_commit_graft(graft, 1))
191
+ if (register_commit_graft(the_repository, graft, 1))
192
error("duplicate graft data: %s", buf.buf);
193
}
194
fclose(fp);
commit.h
+2
-1
@@ -174,7 +174,8 @@ struct commit_graft {
174
typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *);
175
176
struct commit_graft *read_graft_line(struct strbuf *line);
177
-int register_commit_graft(struct commit_graft *, int);
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);
180
181
extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2);
shallow.c
+2
-1
@@ -1,4 +1,5 @@
1
#include "cache.h"
2
+#include "repository.h"
3
#include "tempfile.h"
4
#include "lockfile.h"
5
#include "object-store.h"
@@ -38,7 +39,7 @@ int register_shallow(const struct object_id *oid)
39
graft->nr_parent = -1;
40
if (commit && commit->object.parsed)
41
commit->parents = NULL;
41
- return register_commit_graft(graft, 0);
42
+ return register_commit_graft(the_repository, graft, 0);
43
}
44
45
int is_repository_shallow(void)