From 109cd76dd3467bd05f8d2145b857006649741d5c Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Thu, 28 Jun 2018 18:21:51 -0700 Subject: object: add repository argument to parse_object Add a repository argument to allow the callers of parse_object to be more specific about which repository to act on. 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 --- builtin/diff-tree.c | 3 ++- builtin/diff.c | 2 +- builtin/fast-export.c | 2 +- builtin/fmt-merge-msg.c | 6 ++++-- builtin/fsck.c | 4 ++-- builtin/log.c | 3 ++- builtin/name-rev.c | 7 ++++--- builtin/receive-pack.c | 6 +++--- builtin/reflog.c | 3 ++- builtin/rev-list.c | 2 +- 10 files changed, 22 insertions(+), 16 deletions(-) (limited to 'builtin') diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 473615117e..d8db8f682f 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -5,6 +5,7 @@ #include "log-tree.h" #include "builtin.h" #include "submodule.h" +#include "repository.h" static struct rev_info log_tree_opt; @@ -68,7 +69,7 @@ static int diff_tree_stdin(char *line) line[len-1] = 0; if (parse_oid_hex(line, &oid, &p)) return -1; - obj = parse_object(&oid); + obj = parse_object(the_repository, &oid); if (!obj) return -1; if (obj->type == OBJ_COMMIT) diff --git a/builtin/diff.c b/builtin/diff.c index b709b6e984..d0421c90e2 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -400,7 +400,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix) const char *name = entry->name; int flags = (obj->flags & UNINTERESTING); if (!obj->parsed) - obj = parse_object(&obj->oid); + obj = parse_object(the_repository, &obj->oid); obj = deref_tag(obj, NULL, 0); if (!obj) die(_("invalid object '%s' given."), name); diff --git a/builtin/fast-export.c b/builtin/fast-export.c index 9ee6a4d2e8..a16aeaa826 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -801,7 +801,7 @@ static struct commit *get_commit(struct rev_cmdline_entry *e, char *full_name) /* handle nested tags */ while (tag && tag->object.type == OBJ_TAG) { - parse_object(&tag->object.oid); + parse_object(the_repository, &tag->object.oid); string_list_append(&extra_refs, full_name)->util = tag; tag = (struct tag *)tag->tagged; } diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c index 1b526adb3a..5e44589b54 100644 --- a/builtin/fmt-merge-msg.c +++ b/builtin/fmt-merge-msg.c @@ -11,6 +11,7 @@ #include "branch.h" #include "fmt-merge-msg.h" #include "gpg-interface.h" +#include "repository.h" static const char * const fmt_merge_msg_usage[] = { N_("git fmt-merge-msg [-m ] [--log[=] | --no-log] [--file ]"), @@ -343,7 +344,8 @@ static void shortlog(const char *name, const struct object_id *oid = &origin_data->oid; int limit = opts->shortlog_len; - branch = deref_tag(parse_object(oid), oid_to_hex(oid), GIT_SHA1_HEXSZ); + branch = deref_tag(parse_object(the_repository, oid), oid_to_hex(oid), + GIT_SHA1_HEXSZ); if (!branch || branch->type != OBJ_COMMIT) return; @@ -563,7 +565,7 @@ static void find_merge_parents(struct merge_parents *result, * "name" here and we do not want to contaminate its * util field yet. */ - obj = parse_object(&oid); + obj = parse_object(the_repository, &oid); parent = (struct commit *)peel_to_type(NULL, 0, obj, OBJ_COMMIT); if (!parent) continue; diff --git a/builtin/fsck.c b/builtin/fsck.c index 3ad4f160f9..2b0930101d 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -452,7 +452,7 @@ static int fsck_handle_ref(const char *refname, const struct object_id *oid, { struct object *obj; - obj = parse_object(oid); + obj = parse_object(the_repository, oid); if (!obj) { if (is_promisor_object(oid)) { /* @@ -614,7 +614,7 @@ static int fsck_cache_tree(struct cache_tree *it) fprintf(stderr, "Checking cache tree\n"); if (0 <= it->entry_count) { - struct object *obj = parse_object(&it->oid); + struct object *obj = parse_object(the_repository, &it->oid); if (!obj) { error("%s: invalid sha1 pointer in cache-tree", oid_to_hex(&it->oid)); diff --git a/builtin/log.c b/builtin/log.c index c77af79755..05217596a2 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -30,6 +30,7 @@ #include "gpg-interface.h" #include "progress.h" #include "commit-slab.h" +#include "repository.h" #define MAIL_DEFAULT_WRAP 72 @@ -619,7 +620,7 @@ int cmd_show(int argc, const char **argv, const char *prefix) rev.shown_one = 1; if (ret) break; - o = parse_object(&t->tagged->oid); + o = parse_object(the_repository, &t->tagged->oid); if (!o) ret = error(_("Could not read object %s"), oid_to_hex(&t->tagged->oid)); diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 0eb440359d..de54fa93e4 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "repository.h" #include "config.h" #include "commit.h" #include "tag.h" @@ -203,7 +204,7 @@ static int tipcmp(const void *a_, const void *b_) static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data) { - struct object *o = parse_object(oid); + struct object *o = parse_object(the_repository, oid); struct name_ref_data *data = cb_data; int can_abbreviate_output = data->tags_only && data->name_only; int deref = 0; @@ -261,7 +262,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo struct tag *t = (struct tag *) o; if (!t->tagged) break; /* broken repository */ - o = parse_object(&t->tagged->oid); + o = parse_object(the_repository, &t->tagged->oid); deref = 1; taggerdate = t->date; } @@ -451,7 +452,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) } commit = NULL; - object = parse_object(&oid); + object = parse_object(the_repository, &oid); if (object) { struct object *peeled = deref_tag(object, *argv, 0); if (peeled && peeled->type == OBJ_COMMIT) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 44c7c9ee82..400d31c18c 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1108,8 +1108,8 @@ static const char *update(struct command *cmd, struct shallow_info *si) struct object *old_object, *new_object; struct commit *old_commit, *new_commit; - old_object = parse_object(old_oid); - new_object = parse_object(new_oid); + old_object = parse_object(the_repository, old_oid); + new_object = parse_object(the_repository, new_oid); if (!old_object || !new_object || old_object->type != OBJ_COMMIT || @@ -1132,7 +1132,7 @@ static const char *update(struct command *cmd, struct shallow_info *si) if (is_null_oid(new_oid)) { struct strbuf err = STRBUF_INIT; - if (!parse_object(old_oid)) { + if (!parse_object(the_repository, old_oid)) { old_oid = NULL; if (ref_exists(name)) { rp_warning("Allowing deletion of corrupt ref."); diff --git a/builtin/reflog.c b/builtin/reflog.c index 0091192995..948002b81e 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -2,6 +2,7 @@ #include "config.h" #include "lockfile.h" #include "object-store.h" +#include "repository.h" #include "commit.h" #include "refs.h" #include "dir.h" @@ -129,7 +130,7 @@ static int commit_is_complete(struct commit *commit) struct commit_list *parent; c = (struct commit *)object_array_pop(&study); - if (!c->object.parsed && !parse_object(&c->object.oid)) + if (!c->object.parsed && !parse_object(the_repository, &c->object.oid)) c->object.flags |= INCOMPLETE; if (c->object.flags & INCOMPLETE) { diff --git a/builtin/rev-list.c b/builtin/rev-list.c index e9bd4e378a..cbaaae83ea 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -239,7 +239,7 @@ static int finish_object(struct object *obj, const char *name, void *cb_data) return 1; } if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT) - parse_object(&obj->oid); + parse_object(the_repository, &obj->oid); return 0; } -- cgit v1.2.3