tag: add repository argument to deref_tag
authorStefan Beller <sbeller@google.com>
Fri, 29 Jun 2018 01:22:05 +0000 (18:22 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Jun 2018 17:43:39 +0000 (10:43 -0700)
Add a repository argument to allow the callers of deref_tag
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 <jrnieder@gmail.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18 files changed:
blame.c
builtin/diff.c
builtin/fmt-merge-msg.c
builtin/grep.c
builtin/name-rev.c
commit.c
fetch-pack.c
http-backend.c
http-push.c
line-log.c
merge-recursive.c
remote.c
server-info.c
sha1-name.c
shallow.c
tag.c
tag.h
upload-pack.c
diff --git a/blame.c b/blame.c
index cf102276bea1101b594737e56912e4badd169a42..4229bcd384c275d584c35d9aeee7768aa79348aa 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -1674,7 +1674,7 @@ static struct commit *find_single_final(struct rev_info *revs,
                struct object *obj = revs->pending.objects[i].item;
                if (obj->flags & UNINTERESTING)
                        continue;
-               obj = deref_tag(obj, NULL, 0);
+               obj = deref_tag(the_repository, obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (found)
@@ -1705,7 +1705,7 @@ static struct commit *dwim_reverse_initial(struct rev_info *revs,
 
        /* Is that sole rev a committish? */
        obj = revs->pending.objects[0].item;
-       obj = deref_tag(obj, NULL, 0);
+       obj = deref_tag(the_repository, obj, NULL, 0);
        if (obj->type != OBJ_COMMIT)
                return NULL;
 
@@ -1741,7 +1741,7 @@ static struct commit *find_single_initial(struct rev_info *revs,
                struct object *obj = revs->pending.objects[i].item;
                if (!(obj->flags & UNINTERESTING))
                        continue;
-               obj = deref_tag(obj, NULL, 0);
+               obj = deref_tag(the_repository, obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (found)
index 7971530b9b3034f3af326cc035978927a2c18c73..361a3c3ed38769f798b83933755fed84724ce43c 100644 (file)
@@ -402,7 +402,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                int flags = (obj->flags & UNINTERESTING);
                if (!obj->parsed)
                        obj = parse_object(the_repository, &obj->oid);
-               obj = deref_tag(obj, NULL, 0);
+               obj = deref_tag(the_repository, obj, NULL, 0);
                if (!obj)
                        die(_("invalid object '%s' given."), name);
                if (obj->type == OBJ_COMMIT)
index 36318ef46e74314913386eaae5b24484f56690db..ff165c0fcd209f1bab596905a61bdfa6b491208a 100644 (file)
@@ -344,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(the_repository, oid), oid_to_hex(oid),
+       branch = deref_tag(the_repository, parse_object(the_repository, oid),
+                          oid_to_hex(oid),
                           GIT_SHA1_HEXSZ);
        if (!branch || branch->type != OBJ_COMMIT)
                return;
index ee753a403eba0e9bc25b40a1efd200cafdf31e19..538a818e6dd63cd0825bb6c1b195e49bad9442b9 100644 (file)
@@ -647,7 +647,8 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
 
        for (i = 0; i < nr; i++) {
                struct object *real_obj;
-               real_obj = deref_tag(list->objects[i].item, NULL, 0);
+               real_obj = deref_tag(the_repository, list->objects[i].item,
+                                    NULL, 0);
 
                /* load the gitmodules file for this rev */
                if (recurse_submodules) {
index f6eb419a029700db5e88220de95cea8e3dd6a732..f1cb45c22746bbcfb76d8fb1fefd5061f582cf57 100644 (file)
@@ -455,7 +455,8 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix)
                commit = NULL;
                object = parse_object(the_repository, &oid);
                if (object) {
-                       struct object *peeled = deref_tag(object, *argv, 0);
+                       struct object *peeled = deref_tag(the_repository,
+                                                         object, *argv, 0);
                        if (peeled && peeled->type == OBJ_COMMIT)
                                commit = (struct commit *)peeled;
                }
index 9e2899bd5ad62a2402312599940f5aceeb5e658b..aa5557dee847a1c1d1de0c7827c80794c74b6652 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -27,7 +27,8 @@ const char *commit_type = "commit";
 struct commit *lookup_commit_reference_gently_the_repository(
                const struct object_id *oid, int quiet)
 {
-       struct object *obj = deref_tag(parse_object(the_repository, oid),
+       struct object *obj = deref_tag(the_repository,
+                                      parse_object(the_repository, oid),
                                       NULL, 0);
 
        if (!obj)
index 9f3aa4a88fd41515da79c57813b991c14d4c465f..d60d83f174be139aefbbcaa8fce662b3c10d8169 100644 (file)
@@ -126,7 +126,8 @@ static void rev_list_push(struct commit *commit, int mark)
 
 static int rev_list_insert_ref(const char *refname, const struct object_id *oid)
 {
-       struct object *o = deref_tag(parse_object(the_repository, oid),
+       struct object *o = deref_tag(the_repository,
+                                    parse_object(the_repository, oid),
                                     refname, 0);
 
        if (o && o->type == OBJ_COMMIT)
@@ -144,7 +145,8 @@ static int rev_list_insert_ref_oid(const char *refname, const struct object_id *
 static int clear_marks(const char *refname, const struct object_id *oid,
                       int flag, void *cb_data)
 {
-       struct object *o = deref_tag(parse_object(the_repository, oid),
+       struct object *o = deref_tag(the_repository,
+                                    parse_object(the_repository, oid),
                                     refname, 0);
 
        if (o && o->type == OBJ_COMMIT)
@@ -802,7 +804,8 @@ static int everything_local(struct fetch_pack_args *args,
                 * Don't mark them common yet; the server has to be told so first.
                 */
                for (ref = *refs; ref; ref = ref->next) {
-                       struct object *o = deref_tag(lookup_object(the_repository,
+                       struct object *o = deref_tag(the_repository,
+                                                    lookup_object(the_repository,
                                                     ref->old_oid.hash),
                                                     NULL, 0);
 
index 50ba4d53d54524264f2d4e3465e3689e9dbb1fa1..bd0442a805a16bf2313b65a54fdfd4bf937b13ad 100644 (file)
@@ -442,7 +442,7 @@ static int show_text_ref(const char *name, const struct object_id *oid,
 
        strbuf_addf(buf, "%s\t%s\n", oid_to_hex(oid), name_nons);
        if (o->type == OBJ_TAG) {
-               o = deref_tag(o, name, 0);
+               o = deref_tag(the_repository, o, name, 0);
                if (!o)
                        return 0;
                strbuf_addf(buf, "%s\t%s^{}\n", oid_to_hex(&o->oid),
index f7b70c4efb11b834dc1960a8ccbcb6ae9dae8aa3..5eaf551b51e7aaf87219d4af0ca19873484c90ca 100644 (file)
@@ -1477,7 +1477,7 @@ static void add_remote_info_ref(struct remote_ls_ctx *ls)
                    oid_to_hex(&ref->old_oid), ls->dentry_name);
 
        if (o->type == OBJ_TAG) {
-               o = deref_tag(o, ls->dentry_name, 0);
+               o = deref_tag(the_repository, o, ls->dentry_name, 0);
                if (o)
                        strbuf_addf(buf, "%s\t%s^{}\n",
                                    oid_to_hex(&o->oid), ls->dentry_name);
index fa9cfd5bdbb5dfe4a1ca5c7f7711435caf091805..7fa0f16eba6bbb851be38dd266d597cf450a0275 100644 (file)
@@ -479,7 +479,7 @@ static struct commit *check_single_commit(struct rev_info *revs)
                struct object *obj = revs->pending.objects[i].item;
                if (obj->flags & UNINTERESTING)
                        continue;
-               obj = deref_tag(obj, NULL, 0);
+               obj = deref_tag(the_repository, obj, NULL, 0);
                if (obj->type != OBJ_COMMIT)
                        die("Non commit %s?", revs->pending.objects[i].name);
                if (commit)
index 41366e75e20edbb086efcf99098495da27f1fe63..1dd6ec384de132d24f96b2ee89639bb765de9589 100644 (file)
@@ -3467,7 +3467,8 @@ static struct commit *get_ref(const struct object_id *oid, const char *name)
 {
        struct object *object;
 
-       object = deref_tag(parse_object(the_repository, oid), name,
+       object = deref_tag(the_repository, parse_object(the_repository, oid),
+                          name,
                           strlen(name));
        if (!object)
                return NULL;
index 8c75c45fe65fca6e37ce526b58289878530dba04..26b1fbd9a881d2af7d7cc7a098fe182d36502d80 100644 (file)
--- a/remote.c
+++ b/remote.c
@@ -1802,12 +1802,14 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid)
         * Both new_commit and old_commit must be commit-ish and new_commit is descendant of
         * old_commit.  Otherwise we require --force.
         */
-       o = deref_tag(parse_object(the_repository, old_oid), NULL, 0);
+       o = deref_tag(the_repository, parse_object(the_repository, old_oid),
+                     NULL, 0);
        if (!o || o->type != OBJ_COMMIT)
                return 0;
        old_commit = (struct commit *) o;
 
-       o = deref_tag(parse_object(the_repository, new_oid), NULL, 0);
+       o = deref_tag(the_repository, parse_object(the_repository, new_oid),
+                     NULL, 0);
        if (!o || o->type != OBJ_COMMIT)
                return 0;
        new_commit = (struct commit *) o;
index 2abd0dca088dea5c2348e388da33a53a4656bfe4..41050c2449b1adaaeddda30529f9eb1d62981396 100644 (file)
@@ -64,7 +64,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,
                return -1;
 
        if (o->type == OBJ_TAG) {
-               o = deref_tag(o, path, 0);
+               o = deref_tag(the_repository, o, path, 0);
                if (o)
                        if (fprintf(fp, "%s     %s^{}\n",
                                oid_to_hex(&o->oid), path) < 0)
index 5854bc75fe292949563aabfe715425c1db54d4ca..009faab4aefc34f55daf6fd7e6e63ec0f0ee108a 100644 (file)
@@ -239,7 +239,8 @@ static int disambiguate_committish_only(const struct object_id *oid, void *cb_da
                return 0;
 
        /* We need to do this the hard way... */
-       obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
+       obj = deref_tag(the_repository, parse_object(the_repository, oid),
+                       NULL, 0);
        if (obj && obj->type == OBJ_COMMIT)
                return 1;
        return 0;
@@ -263,7 +264,8 @@ static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_
                return 0;
 
        /* We need to do this the hard way... */
-       obj = deref_tag(parse_object(the_repository, oid), NULL, 0);
+       obj = deref_tag(the_repository, parse_object(the_repository, oid),
+                       NULL, 0);
        if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT))
                return 1;
        return 0;
@@ -968,7 +970,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid,
        if (!o)
                return -1;
        if (!expected_type) {
-               o = deref_tag(o, name, sp - name - 2);
+               o = deref_tag(the_repository, o, name, sp - name - 2);
                if (!o || (!o->parsed && !parse_object(the_repository, &o->oid)))
                        return -1;
                oidcpy(oid, &o->oid);
@@ -1100,7 +1102,8 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
        if (!object)
                return 0;
        if (object->type == OBJ_TAG) {
-               object = deref_tag(object, path, strlen(path));
+               object = deref_tag(the_repository, object, path,
+                                  strlen(path));
                if (!object)
                        return 0;
        }
index e9ce55bba08489d30a7a4516fc39e332260ac2f7..dbe8a2a2906abf9b393eeca1cdad8c9425c3e4bb 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -96,7 +96,9 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
                        if (i < heads->nr) {
                                int **depth_slot;
                                commit = (struct commit *)
-                                       deref_tag(heads->objects[i++].item, NULL, 0);
+                                       deref_tag(the_repository,
+                                                 heads->objects[i++].item,
+                                                 NULL, 0);
                                if (!commit || commit->object.type != OBJ_COMMIT) {
                                        commit = NULL;
                                        continue;
diff --git a/tag.c b/tag.c
index 4971fd4dfc92e664b8ea3a6d65e99f25cccaccd7..fbb4659325ba2027f64360c5b46fa921adb8f944 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -64,7 +64,7 @@ int gpg_verify_tag(const struct object_id *oid, const char *name_to_report,
        return ret;
 }
 
-struct object *deref_tag(struct object *o, const char *warn, int warnlen)
+struct object *deref_tag_the_repository(struct object *o, const char *warn, int warnlen)
 {
        while (o && o->type == OBJ_TAG)
                if (((struct tag *)o)->tagged)
diff --git a/tag.h b/tag.h
index 149959c81ba6a2aadb73b99d5d11b263853b5d36..45b0b08b1f620b46ee65079f2701694861621816 100644 (file)
--- a/tag.h
+++ b/tag.h
@@ -17,7 +17,8 @@ extern struct tag *lookup_tag_the_repository(const struct object_id *oid);
 extern int parse_tag_buffer_the_repository(struct tag *item, const void *data, unsigned long size);
 extern int parse_tag(struct tag *item);
 extern void release_tag_memory(struct tag *t);
-extern struct object *deref_tag(struct object *, const char *, int);
+#define deref_tag(r, o, w, l) deref_tag_##r(o, w, l)
+extern struct object *deref_tag_the_repository(struct object *, const char *, int);
 extern struct object *deref_tag_noverify(struct object *);
 extern int gpg_verify_tag(const struct object_id *oid,
                const char *name_to_report, unsigned flags);
index 45e3a94788f387b9068b4b20f7175a70edf94394..4ca052d0b6418404a81a86df9e434c5a9ba77ab2 100644 (file)
@@ -380,7 +380,7 @@ static int ok_to_give_up(void)
 
                if (want->flags & COMMON_KNOWN)
                        continue;
-               want = deref_tag(want, "a want line", 0);
+               want = deref_tag(the_repository, want, "a want line", 0);
                if (!want || want->type != OBJ_COMMIT) {
                        /* no way to tell if this is reachable by
                         * looking at the ancestry chain alone, so