blob: add repository argument to lookup_blob

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>

Stefan Beller committed Jun 28, 2018 at 18:21 UTC da14a7ff99e1d011192a1fe330dd3fddf8977dc3
15 files changed +23 -18
blob.c
+1 -1
@@ -5,7 +5,7 @@
5
6 const char *blob_type = "blob";
7
8 -struct blob *lookup_blob(const struct object_id *oid)
8 +struct blob *lookup_blob_the_repository(const struct object_id *oid)
9 {
10 struct object *obj = lookup_object(the_repository, oid->hash);
11 if (!obj)
blob.h
+2 -1
@@ -9,7 +9,8 @@ struct blob {
9 struct object object;
10 };
11
12 -struct blob *lookup_blob(const struct object_id *oid);
12 +#define lookup_blob(r, o) lookup_blob_##r(o)
13 +struct blob *lookup_blob_the_repository(const struct object_id *oid);
14
15 int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
16
builtin/fast-export.c
+1 -1
@@ -236,7 +236,7 @@ static void export_blob(const struct object_id *oid)
236
237 if (anonymize) {
238 buf = anonymize_blob(&size);
239 - object = (struct object *)lookup_blob(oid);
239 + object = (struct object *)lookup_blob(the_repository, oid);
240 eaten = 0;
241 } else {
242 buf = read_object_file(oid, &type, &size);
builtin/fsck.c
+2 -1
@@ -810,7 +810,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
810 mode = active_cache[i]->ce_mode;
811 if (S_ISGITLINK(mode))
812 continue;
813 - blob = lookup_blob(&active_cache[i]->oid);
813 + blob = lookup_blob(the_repository,
814 + &active_cache[i]->oid);
815 if (!blob)
816 continue;
817 obj = &blob->object;
builtin/index-pack.c
+1 -1
@@ -832,7 +832,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
832 if (strict || do_fsck_object) {
833 read_lock();
834 if (type == OBJ_BLOB) {
835 - struct blob *blob = lookup_blob(oid);
835 + struct blob *blob = lookup_blob(the_repository, oid);
836 if (blob)
837 blob->object.flags |= FLAG_CHECKED;
838 else
builtin/merge-tree.c
+2 -1
@@ -2,6 +2,7 @@
2 #include "tree-walk.h"
3 #include "xdiff-interface.h"
4 #include "object-store.h"
5 +#include "repository.h"
6 #include "blob.h"
7 #include "exec-cmd.h"
8 #include "merge-blobs.h"
@@ -170,7 +171,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
171 res->stage = stage;
172 res->path = path;
173 res->mode = mode;
173 - res->blob = lookup_blob(oid);
174 + res->blob = lookup_blob(the_repository, oid);
175 return res;
176 }
177
builtin/unpack-objects.c
+1 -1
@@ -254,7 +254,7 @@ static void write_object(unsigned nr, enum object_type type,
254 added_object(nr, type, buf, size);
255 free(buf);
256
257 - blob = lookup_blob(&obj_list[nr].oid);
257 + blob = lookup_blob(the_repository, &obj_list[nr].oid);
258 if (blob)
259 blob->object.flags |= FLAG_WRITTEN;
260 else
fsck.c
+2 -2
@@ -414,7 +414,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
414 result = options->walk(obj, OBJ_TREE, data, options);
415 }
416 else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
417 - obj = (struct object *)lookup_blob(entry.oid);
417 + obj = (struct object *)lookup_blob(the_repository, entry.oid);
418 if (name && obj)
419 put_object_name(options, obj, "%s%s", name,
420 entry.path);
@@ -1070,7 +1070,7 @@ int fsck_finish(struct fsck_options *options)
1070 if (oidset_contains(&gitmodules_done, oid))
1071 continue;
1072
1073 - blob = lookup_blob(oid);
1073 + blob = lookup_blob(the_repository, oid);
1074 if (!blob) {
1075 struct object *obj = lookup_unknown_object(oid->hash);
1076 ret |= report(options, obj,
http-push.c
+2 -1
@@ -1314,7 +1314,8 @@ static struct object_list **process_tree(struct tree *tree,
1314 p = process_tree(lookup_tree(entry.oid), p);
1315 break;
1316 case OBJ_BLOB:
1317 - p = process_blob(lookup_blob(entry.oid), p);
1317 + p = process_blob(lookup_blob(the_repository, entry.oid),
1318 + p);
1319 break;
1320 default:
1321 /* Subproject commit - not in this repository */
list-objects.c
+1 -1
@@ -167,7 +167,7 @@ static void process_tree(struct rev_info *revs,
167 cb_data);
168 else
169 process_blob(revs,
170 - lookup_blob(entry.oid),
170 + lookup_blob(the_repository, entry.oid),
171 show, base, entry.path,
172 cb_data, filter_fn, filter_data);
173 }
object.c
+2 -2
@@ -193,7 +193,7 @@ struct object *parse_object_buffer_the_repository(const struct object_id *oid, e
193
194 obj = NULL;
195 if (type == OBJ_BLOB) {
196 - struct blob *blob = lookup_blob(oid);
196 + struct blob *blob = lookup_blob(the_repository, oid);
197 if (blob) {
198 if (parse_blob_buffer(blob, buffer, size))
199 return NULL;
@@ -266,7 +266,7 @@ struct object *parse_object_the_repository(const struct object_id *oid)
266 error("sha1 mismatch %s", oid_to_hex(oid));
267 return NULL;
268 }
269 - parse_blob_buffer(lookup_blob(oid), NULL, 0);
269 + parse_blob_buffer(lookup_blob(the_repository, oid), NULL, 0);
270 return lookup_object(the_repository, oid->hash);
271 }
272
reachable.c
+1 -1
@@ -91,7 +91,7 @@ static void add_recent_object(const struct object_id *oid,
91 obj = (struct object *)lookup_tree(oid);
92 break;
93 case OBJ_BLOB:
94 - obj = (struct object *)lookup_blob(oid);
94 + obj = (struct object *)lookup_blob(the_repository, oid);
95 break;
96 default:
97 die("unknown object type for %s: %s",
revision.c
+2 -2
@@ -66,7 +66,7 @@ static void mark_tree_contents_uninteresting(struct tree *tree)
66 mark_tree_uninteresting(lookup_tree(entry.oid));
67 break;
68 case OBJ_BLOB:
69 - mark_blob_uninteresting(lookup_blob(entry.oid));
69 + mark_blob_uninteresting(lookup_blob(the_repository, entry.oid));
70 break;
71 default:
72 /* Subproject commit - not in this repository */
@@ -1348,7 +1348,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs,
1348 if (S_ISGITLINK(ce->ce_mode))
1349 continue;
1350
1351 - blob = lookup_blob(&ce->oid);
1351 + blob = lookup_blob(the_repository, &ce->oid);
1352 if (!blob)
1353 die("unable to add index blob to traversal");
1354 add_pending_object_with_path(revs, &blob->object, "",
tag.c
+1 -1
@@ -154,7 +154,7 @@ int parse_tag_buffer(struct tag *item, const void *data, unsigned long size)
154 bufptr = nl + 1;
155
156 if (!strcmp(type, blob_type)) {
157 - item->tagged = (struct object *)lookup_blob(&oid);
157 + item->tagged = (struct object *)lookup_blob(the_repository, &oid);
158 } else if (!strcmp(type, tree_type)) {
159 item->tagged = (struct object *)lookup_tree(&oid);
160 } else if (!strcmp(type, commit_type)) {
walker.c
+2 -1
@@ -54,7 +54,8 @@ static int process_tree(struct walker *walker, struct tree *tree)
54 obj = &tree->object;
55 }
56 else {
57 - struct blob *blob = lookup_blob(entry.oid);
57 + struct blob *blob = lookup_blob(the_repository,
58 + entry.oid);
59 if (blob)
60 obj = &blob->object;
61 }