From 3f5787f80662b8f5dbd6fb83d5ca20be224e8a08 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Tue, 15 May 2018 16:42:18 -0700 Subject: 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 Signed-off-by: Stefan Beller Signed-off-by: Junio C Hamano diff --git a/builtin/blame.c b/builtin/blame.c index 0ffd1d4..7a07bff 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -8,6 +8,7 @@ #include "cache.h" #include "config.h" #include "builtin.h" +#include "repository.h" #include "commit.h" #include "diff.h" #include "revision.h" @@ -491,7 +492,7 @@ static int read_ancestry(const char *graft_file) /* The format is just "Commit Parent1 Parent2 ...\n" */ struct commit_graft *graft = read_graft_line(&buf); if (graft) - register_commit_graft(graft, 0); + register_commit_graft(the_repository, graft, 0); } fclose(fp); strbuf_release(&buf); diff --git a/commit.c b/commit.c index 2cd5b8a..4e8d348 100644 --- a/commit.c +++ b/commit.c @@ -112,7 +112,7 @@ static int commit_graft_pos_the_repository(const unsigned char *sha1) commit_graft_sha1_access); } -int register_commit_graft(struct commit_graft *graft, int ignore_dups) +int register_commit_graft_the_repository(struct commit_graft *graft, int ignore_dups) { int pos = commit_graft_pos(the_repository, graft->oid.hash); @@ -188,7 +188,7 @@ static int read_graft_file(const char *graft_file) struct commit_graft *graft = read_graft_line(&buf); if (!graft) continue; - if (register_commit_graft(graft, 1)) + if (register_commit_graft(the_repository, graft, 1)) error("duplicate graft data: %s", buf.buf); } fclose(fp); diff --git a/commit.h b/commit.h index 2d764ab..40a5b5e 100644 --- a/commit.h +++ b/commit.h @@ -174,7 +174,8 @@ struct commit_graft { typedef int (*each_commit_graft_fn)(const struct commit_graft *, void *); struct commit_graft *read_graft_line(struct strbuf *line); -int register_commit_graft(struct commit_graft *, int); +#define register_commit_graft(r, g, i) register_commit_graft_##r(g, i) +int register_commit_graft_the_repository(struct commit_graft *, int); struct commit_graft *lookup_commit_graft(const struct object_id *oid); extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *rev2); diff --git a/shallow.c b/shallow.c index c2f81a5..ef802de 100644 --- a/shallow.c +++ b/shallow.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "repository.h" #include "tempfile.h" #include "lockfile.h" #include "object-store.h" @@ -38,7 +39,7 @@ int register_shallow(const struct object_id *oid) graft->nr_parent = -1; if (commit && commit->object.parsed) commit->parents = NULL; - return register_commit_graft(graft, 0); + return register_commit_graft(the_repository, graft, 0); } int is_repository_shallow(void) -- cgit v0.10.2-6-g49f6