Skip to content

Commit da14a7f

Browse files
stefanbellergitster
authored andcommitted
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>
1 parent 1268dfa commit da14a7f

File tree

15 files changed

+23
-18
lines changed

15 files changed

+23
-18
lines changed

blob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
const char *blob_type = "blob";
77

8-
struct blob *lookup_blob(const struct object_id *oid)
8+
struct blob *lookup_blob_the_repository(const struct object_id *oid)
99
{
1010
struct object *obj = lookup_object(the_repository, oid->hash);
1111
if (!obj)

blob.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ struct blob {
99
struct object object;
1010
};
1111

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);
1314

1415
int parse_blob_buffer(struct blob *item, void *buffer, unsigned long size);
1516

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static void export_blob(const struct object_id *oid)
236236

237237
if (anonymize) {
238238
buf = anonymize_blob(&size);
239-
object = (struct object *)lookup_blob(oid);
239+
object = (struct object *)lookup_blob(the_repository, oid);
240240
eaten = 0;
241241
} else {
242242
buf = read_object_file(oid, &type, &size);

builtin/fsck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,8 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
810810
mode = active_cache[i]->ce_mode;
811811
if (S_ISGITLINK(mode))
812812
continue;
813-
blob = lookup_blob(&active_cache[i]->oid);
813+
blob = lookup_blob(the_repository,
814+
&active_cache[i]->oid);
814815
if (!blob)
815816
continue;
816817
obj = &blob->object;

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
832832
if (strict || do_fsck_object) {
833833
read_lock();
834834
if (type == OBJ_BLOB) {
835-
struct blob *blob = lookup_blob(oid);
835+
struct blob *blob = lookup_blob(the_repository, oid);
836836
if (blob)
837837
blob->object.flags |= FLAG_CHECKED;
838838
else

builtin/merge-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "tree-walk.h"
33
#include "xdiff-interface.h"
44
#include "object-store.h"
5+
#include "repository.h"
56
#include "blob.h"
67
#include "exec-cmd.h"
78
#include "merge-blobs.h"
@@ -170,7 +171,7 @@ static struct merge_list *create_entry(unsigned stage, unsigned mode, const stru
170171
res->stage = stage;
171172
res->path = path;
172173
res->mode = mode;
173-
res->blob = lookup_blob(oid);
174+
res->blob = lookup_blob(the_repository, oid);
174175
return res;
175176
}
176177

builtin/unpack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ static void write_object(unsigned nr, enum object_type type,
254254
added_object(nr, type, buf, size);
255255
free(buf);
256256

257-
blob = lookup_blob(&obj_list[nr].oid);
257+
blob = lookup_blob(the_repository, &obj_list[nr].oid);
258258
if (blob)
259259
blob->object.flags |= FLAG_WRITTEN;
260260
else

fsck.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ static int fsck_walk_tree(struct tree *tree, void *data, struct fsck_options *op
414414
result = options->walk(obj, OBJ_TREE, data, options);
415415
}
416416
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);
418418
if (name && obj)
419419
put_object_name(options, obj, "%s%s", name,
420420
entry.path);
@@ -1070,7 +1070,7 @@ int fsck_finish(struct fsck_options *options)
10701070
if (oidset_contains(&gitmodules_done, oid))
10711071
continue;
10721072

1073-
blob = lookup_blob(oid);
1073+
blob = lookup_blob(the_repository, oid);
10741074
if (!blob) {
10751075
struct object *obj = lookup_unknown_object(oid->hash);
10761076
ret |= report(options, obj,

http-push.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1314,7 +1314,8 @@ static struct object_list **process_tree(struct tree *tree,
13141314
p = process_tree(lookup_tree(entry.oid), p);
13151315
break;
13161316
case OBJ_BLOB:
1317-
p = process_blob(lookup_blob(entry.oid), p);
1317+
p = process_blob(lookup_blob(the_repository, entry.oid),
1318+
p);
13181319
break;
13191320
default:
13201321
/* Subproject commit - not in this repository */

list-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static void process_tree(struct rev_info *revs,
167167
cb_data);
168168
else
169169
process_blob(revs,
170-
lookup_blob(entry.oid),
170+
lookup_blob(the_repository, entry.oid),
171171
show, base, entry.path,
172172
cb_data, filter_fn, filter_data);
173173
}

0 commit comments

Comments
 (0)