blob: add repository argument to lookup_blob
authorStefan Beller <sbeller@google.com>
Fri, 29 Jun 2018 01:21:55 +0000 (18:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Jun 2018 17:43:38 +0000 (10:43 -0700)
Add a repository argument to allow the callers of lookup_blob
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>
15 files changed:
blob.c
blob.h
builtin/fast-export.c
builtin/fsck.c
builtin/index-pack.c
builtin/merge-tree.c
builtin/unpack-objects.c
fsck.c
http-push.c
list-objects.c
object.c
reachable.c
revision.c
tag.c
walker.c

diff --git a/blob.c b/blob.c
index dada295..17b9314 100644 (file)
--- a/blob.c
+++ b/blob.c
@@ -5,7 +5,7 @@
 
 const char *blob_type = "blob";
 
-struct blob *lookup_blob(const struct object_id *oid)
+struct blob *lookup_blob_the_repository(const struct object_id *oid)
 {
        struct object *obj = lookup_object(the_repository, oid->hash);
        if (!obj)
diff --git a/blob.h b/blob.h
index 4460616..08bc344 100644 (file)
--- a/blob.h
+++ b/blob.h
@@ -9,7 +9,8 @@ struct blob {
        struct object object;
 };
 
-struct blob *lookup_blob(const struct object_id *oid);
+#define lookup_blob(r, o) lookup_blob_##r(o)
+struct blob *lookup_blob_the_repository(const struct object_id *oid);
 
 int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
 
index 03a2e4b..7d6b1d8 100644 (file)
@@ -236,7 +236,7 @@ static void export_blob(const struct object_id *oid)
 
        if (anonymize) {
                buf = anonymize_blob(&size);
-               object = (struct object *)lookup_blob(oid);
+               object = (struct object *)lookup_blob(the_repository, oid);
                eaten = 0;
        } else {
                buf = read_object_file(oid, &type, &size);
index a906fe4..2631919 100644 (file)
@@ -810,7 +810,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
                        mode = active_cache[i]->ce_mode;
                        if (S_ISGITLINK(mode))
                                continue;
-                       blob = lookup_blob(&active_cache[i]->oid);
+                       blob = lookup_blob(the_repository,
+                                          &active_cache[i]->oid);
                        if (!blob)
                                continue;
                        obj = &blob->object;
index 9c08cf3..de311fe 100644 (file)
@@ -832,7 +832,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
        if (strict || do_fsck_object) {
                read_lock();
                if (type == OBJ_BLOB) {
-                       struct blob *blob = lookup_blob(oid);
+                       struct blob *blob = lookup_blob(the_repository, oid);
                        if (blob)
                                blob->object.flags |= FLAG_CHECKED;
                        else
index 8a8d579..f8023ba 100644 (file)
@@ -2,6 +2,7 @@
 #include "tree-walk.h"
 #include "xdiff-interface.h"
 #include "object-store.h"
+#include "repository.h"
 #include "blob.h"
 #include "exec-cmd.h"
 #include "merge-blobs.h"
@@ -170,7 +171,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
        res->stage = stage;
        res->path = path;
        res->mode = mode;
-       res->blob = lookup_blob(oid);
+       res->blob = lookup_blob(the_repository, oid);
        return res;
 }
 
index 75d1d5e..716408e 100644 (file)
@@ -254,7 +254,7 @@ static void write_object(unsigned nr, enum object_type type,
                added_object(nr, type, buf, size);
                free(buf);
 
-               blob = lookup_blob(&obj_list[nr].oid);
+               blob = lookup_blob(the_repository, &obj_list[nr].oid);
                if (blob)
                        blob->object.flags |= FLAG_WRITTEN;
                else
diff --git a/fsck.c b/fsck.c
index bb3d622..ea00f72 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -414,7 +414,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
                        result = options->walk(obj, OBJ_TREE, data, options);
                }
                else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
-                       obj = (struct object *)lookup_blob(entry.oid);
+                       obj = (struct object *)lookup_blob(the_repository, entry.oid);
                        if (name && obj)
                                put_object_name(options, obj, "%s%s", name,
                                        entry.path);
@@ -1070,7 +1070,7 @@ int fsck_finish(struct fsck_options *options)
                if (oidset_contains(&gitmodules_done, oid))
                        continue;
 
-               blob = lookup_blob(oid);
+               blob = lookup_blob(the_repository, oid);
                if (!blob) {
                        struct object *obj = lookup_unknown_object(oid->hash);
                        ret |= report(options, obj,
index d2245cc..191b51c 100644 (file)
@@ -1314,7 +1314,8 @@ static struct object_list **process_tree(struct tree *tree,
                        p = process_tree(lookup_tree(entry.oid), p);
                        break;
                case OBJ_BLOB:
-                       p = process_blob(lookup_blob(entry.oid), p);
+                       p = process_blob(lookup_blob(the_repository, entry.oid),
+                                        p);
                        break;
                default:
                        /* Subproject commit - not in this repository */
index 3e5e199..04c45f6 100644 (file)
@@ -167,7 +167,7 @@ static void process_tree(struct rev_info *revs,
                                        cb_data);
                else
                        process_blob(revs,
-                                    lookup_blob(entry.oid),
+                                    lookup_blob(the_repository, entry.oid),
                                     show, base, entry.path,
                                     cb_data, filter_fn, filter_data);
        }
index 4049190..fde816a 100644 (file)
--- a/object.c
+++ b/object.c
@@ -193,7 +193,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e
 
        obj = NULL;
        if (type == OBJ_BLOB) {
-               struct blob *blob = lookup_blob(oid);
+               struct blob *blob = lookup_blob(the_repository, oid);
                if (blob) {
                        if (parse_blob_buffer(blob, buffer, size))
                                return NULL;
@@ -266,7 +266,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)
                        error("sha1 mismatch %s", oid_to_hex(oid));
                        return NULL;
                }
-               parse_blob_buffer(lookup_blob(oid), NULL, 0);
+               parse_blob_buffer(lookup_blob(the_repository, oid), NULL, 0);
                return lookup_object(the_repository, oid->hash);
        }
 
index 2ee5569..cc25f01 100644 (file)
@@ -91,7 +91,7 @@ static void add_recent_object(const struct object_id *oid,
                obj = (struct object *)lookup_tree(oid);
                break;
        case OBJ_BLOB:
-               obj = (struct object *)lookup_blob(oid);
+               obj = (struct object *)lookup_blob(the_repository, oid);
                break;
        default:
                die("unknown object type for %s: %s",
index 8a2b285..e382412 100644 (file)
@@ -66,7 +66,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
                        mark_tree_uninteresting(lookup_tree(entry.oid));
                        break;
                case OBJ_BLOB:
-                       mark_blob_uninteresting(lookup_blob(entry.oid));
+                       mark_blob_uninteresting(lookup_blob(the_repository, entry.oid));
                        break;
                default:
                        /* Subproject commit - not in this repository */
@@ -1348,7 +1348,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,
                if (S_ISGITLINK(ce->ce_mode))
                        continue;
 
-               blob = lookup_blob(&ce->oid);
+               blob = lookup_blob(the_repository, &ce->oid);
                if (!blob)
                        die("unable to add index blob to traversal");
                add_pending_object_with_path(revs, &blob->object, "",
diff --git a/tag.c b/tag.c
index a14a4f2..a31ae75 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -154,7 +154,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
        bufptr = nl + 1;
 
        if (!strcmp(type, blob_type)) {
-               item->tagged = (struct object *)lookup_blob(&oid);
+               item->tagged = (struct object *)lookup_blob(the_repository, &oid);
        } else if (!strcmp(type, tree_type)) {
                item->tagged = (struct object *)lookup_tree(&oid);
        } else if (!strcmp(type, commit_type)) {
index 63002b1..5b56c72 100644 (file)
--- a/walker.c
+++ b/walker.c
@@ -54,7 +54,8 @@ static int process_tree(struct walker *walker, struct tree *tree)
                                obj = &tree->object;
                }
                else {
-                       struct blob *blob = lookup_blob(entry.oid);
+                       struct blob *blob = lookup_blob(the_repository,
+                                                       entry.oid);
                        if (blob)
                                obj = &blob->object;
                }