diff options
author | Stefan Beller <sbeller@google.com> | 2018-04-25 11:20:59 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-04-26 10:54:27 +0900 |
commit | 0df8e96566ddcae4adc4efc096944c064f60b8bd (patch) | |
tree | 19c8b0277b21dcd9a9baa71ca5541bd59853afae /builtin | |
parent | 7ecd8690602170f0993923c99645c7c6005e3dfa (diff) | |
download | git-0df8e96566ddcae4adc4efc096944c064f60b8bd.tar.gz |
cache.h: add repository argument to oid_object_info
Add a repository argument to allow the callers of oid_object_info
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: Stefan Beller <sbeller@google.com>
Reviewed-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/blame.c | 2 | ||||
-rw-r--r-- | builtin/cat-file.c | 6 | ||||
-rw-r--r-- | builtin/describe.c | 2 | ||||
-rw-r--r-- | builtin/fast-export.c | 2 | ||||
-rw-r--r-- | builtin/fetch.c | 2 | ||||
-rw-r--r-- | builtin/fsck.c | 3 | ||||
-rw-r--r-- | builtin/index-pack.c | 4 | ||||
-rw-r--r-- | builtin/ls-tree.c | 2 | ||||
-rw-r--r-- | builtin/mktree.c | 2 | ||||
-rw-r--r-- | builtin/pack-objects.c | 8 | ||||
-rw-r--r-- | builtin/prune.c | 3 | ||||
-rw-r--r-- | builtin/replace.c | 11 | ||||
-rw-r--r-- | builtin/tag.c | 4 | ||||
-rw-r--r-- | builtin/unpack-objects.c | 2 |
14 files changed, 29 insertions, 24 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index db38c0b307..bfdf7cc132 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -655,7 +655,7 @@ static int is_a_rev(const char *name) if (get_oid(name, &oid)) return 0; - return OBJ_NONE < oid_object_info(&oid, NULL); + return OBJ_NONE < oid_object_info(the_repository, &oid, NULL); } int cmd_blame(int argc, const char **argv, const char *prefix) diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 4ecdb9ff54..b8ecbea98e 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, /* else fallthrough */ case 'p': - type = oid_object_info(&oid, NULL); + type = oid_object_info(the_repository, &oid, NULL); if (type < 0) die("Not a valid object name %s", obj_name); @@ -140,7 +140,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, case 0: if (type_from_string(exp_type) == OBJ_BLOB) { struct object_id blob_oid; - if (oid_object_info(&oid, NULL) == OBJ_TAG) { + if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) { char *buffer = read_object_file(&oid, &type, &size); const char *target; @@ -151,7 +151,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, } else oidcpy(&blob_oid, &oid); - if (oid_object_info(&blob_oid, NULL) == OBJ_BLOB) + if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) return stream_blob_to_fd(1, &blob_oid, NULL, 0); /* * we attempted to dereference a tag to a blob diff --git a/builtin/describe.c b/builtin/describe.c index de840f96a4..66c497f789 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one) if (cmit) describe_commit(&oid, &sb); - else if (oid_object_info(&oid, NULL) == OBJ_BLOB) + else if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB) describe_blob(oid, &sb); else die(_("%s is neither a commit nor blob"), arg); diff --git a/builtin/fast-export.c b/builtin/fast-export.c index a15898d641..373c794873 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -947,7 +947,7 @@ static void import_marks(char *input_file) if (last_idnum < mark) last_idnum = mark; - type = oid_object_info(&oid, NULL); + type = oid_object_info(the_repository, &oid, NULL); if (type < 0) die("object not found: %s", oid_to_hex(&oid)); diff --git a/builtin/fetch.c b/builtin/fetch.c index dcdfc66f09..73be393b2e 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -637,7 +637,7 @@ static int update_local_ref(struct ref *ref, struct branch *current_branch = branch_get(NULL); const char *pretty_ref = prettify_refname(ref->name); - type = oid_object_info(&ref->new_oid, NULL); + type = oid_object_info(the_repository, &ref->new_oid, NULL); if (type < 0) die(_("object %s not found"), oid_to_hex(&ref->new_oid)); diff --git a/builtin/fsck.c b/builtin/fsck.c index 087360a675..9d59d7d5a2 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -67,7 +67,8 @@ static const char *printable_type(struct object *obj) const char *ret; if (obj->type == OBJ_NONE) { - enum object_type type = oid_object_info(&obj->oid, NULL); + enum object_type type = oid_object_info(the_repository, + &obj->oid, NULL); if (type > 0) object_as_type(obj, type, 0); } diff --git a/builtin/index-pack.c b/builtin/index-pack.c index d81473e722..2d04a596f5 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -223,7 +223,7 @@ static unsigned check_object(struct object *obj) if (!(obj->flags & FLAG_CHECKED)) { unsigned long size; - int type = oid_object_info(&obj->oid, &size); + int type = oid_object_info(the_repository, &obj->oid, &size); if (type <= 0) die(_("did not receive expected object %s"), oid_to_hex(&obj->oid)); @@ -812,7 +812,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, enum object_type has_type; unsigned long has_size; read_lock(); - has_type = oid_object_info(oid, &has_size); + has_type = oid_object_info(the_repository, oid, &has_size); if (has_type < 0) die(_("cannot read existing object info %s"), oid_to_hex(oid)); if (has_type != type || has_size != size) diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index d44b4f9c27..409da4e835 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -94,7 +94,7 @@ static int show_tree(const struct object_id *oid, struct strbuf *base, char size_text[24]; if (!strcmp(type, blob_type)) { unsigned long size; - if (oid_object_info(oid, &size) == OBJ_BAD) + if (oid_object_info(the_repository, oid, &size) == OBJ_BAD) xsnprintf(size_text, sizeof(size_text), "BAD"); else diff --git a/builtin/mktree.c b/builtin/mktree.c index 263c530315..bb76b469fd 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -116,7 +116,7 @@ static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss } /* Check the type of object identified by sha1 */ - obj_type = oid_object_info(&oid, NULL); + obj_type = oid_object_info(the_repository, &oid, NULL); if (obj_type < 0) { if (allow_missing) { ; /* no problem - missing objects are presumed to be of the right type */ diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 4bdae5a1d8..8d4111f748 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1516,7 +1516,8 @@ static void check_object(struct object_entry *entry) unuse_pack(&w_curs); } - entry->type = oid_object_info(&entry->idx.oid, &entry->size); + entry->type = oid_object_info(the_repository, &entry->idx.oid, + &entry->size); /* * The error condition is checked in prepare_pack(). This is * to permit a missing preferred base object to be ignored @@ -1578,7 +1579,8 @@ static void drop_reused_delta(struct object_entry *entry) * And if that fails, the error will be recorded in entry->type * and dealt with in prepare_pack(). */ - entry->type = oid_object_info(&entry->idx.oid, &entry->size); + entry->type = oid_object_info(the_repository, &entry->idx.oid, + &entry->size); } } @@ -2706,7 +2708,7 @@ static void add_objects_in_unpacked_packs(struct rev_info *revs) static int add_loose_object(const struct object_id *oid, const char *path, void *data) { - enum object_type type = oid_object_info(oid, NULL); + enum object_type type = oid_object_info(the_repository, oid, NULL); if (type < 0) { warning("loose object at %s could not be examined", path); diff --git a/builtin/prune.c b/builtin/prune.c index 38ced18dad..518ffbea13 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -50,7 +50,8 @@ static int prune_object(const struct object_id *oid, const char *fullpath, if (st.st_mtime > expire) return 0; if (show_only || verbose) { - enum object_type type = oid_object_info(oid, NULL); + enum object_type type = oid_object_info(the_repository, oid, + NULL); printf("%s %s\n", oid_to_hex(oid), (type > 0) ? type_name(type) : "unknown"); } diff --git a/builtin/replace.c b/builtin/replace.c index 237ea656cf..14e142d5a8 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -55,8 +55,9 @@ static int show_reference(const char *refname, const struct object_id *oid, if (get_oid(refname, &object)) return error("Failed to resolve '%s' as a valid ref.", refname); - obj_type = oid_object_info(&object, NULL); - repl_type = oid_object_info(oid, NULL); + obj_type = oid_object_info(the_repository, &object, + NULL); + repl_type = oid_object_info(the_repository, oid, NULL); printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type), oid_to_hex(oid), type_name(repl_type)); @@ -164,8 +165,8 @@ static int replace_object_oid(const char *object_ref, struct ref_transaction *transaction; struct strbuf err = STRBUF_INIT; - obj_type = oid_object_info(object, NULL); - repl_type = oid_object_info(repl, NULL); + obj_type = oid_object_info(the_repository, object, NULL); + repl_type = oid_object_info(the_repository, repl, NULL); if (!force && obj_type != repl_type) die("Objects must be of the same type.\n" "'%s' points to a replaced object of type '%s'\n" @@ -292,7 +293,7 @@ static int edit_and_replace(const char *object_ref, int force, int raw) if (get_oid(object_ref, &old_oid) < 0) die("Not a valid object name: '%s'", object_ref); - type = oid_object_info(&old_oid, NULL); + type = oid_object_info(the_repository, &old_oid, NULL); if (type < 0) die("unable to get object type for %s", oid_to_hex(&old_oid)); diff --git a/builtin/tag.c b/builtin/tag.c index 8cff6d0b72..26d7729f57 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -212,7 +212,7 @@ static void create_tag(const struct object_id *object, const char *tag, struct strbuf header = STRBUF_INIT; char *path = NULL; - type = oid_object_info(object, NULL); + type = oid_object_info(the_repository, object, NULL); if (type <= OBJ_NONE) die(_("bad object type.")); @@ -298,7 +298,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb) } strbuf_addstr(sb, " ("); - type = oid_object_info(oid, NULL); + type = oid_object_info(the_repository, oid, NULL); switch (type) { default: strbuf_addstr(sb, "object of unknown type"); diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index b7755c6cc5..cfe9019f80 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -199,7 +199,7 @@ static int check_object(struct object *obj, int type, void *data, struct fsck_op if (!(obj->flags & FLAG_OPEN)) { unsigned long size; - int type = oid_object_info(&obj->oid, &size); + int type = oid_object_info(the_repository, &obj->oid, &size); if (type != obj->type || type <= 0) die("object of unexpected type"); obj->flags |= FLAG_WRITTEN; |