Skip to content

Commit 0df8e96

Browse files
stefanbellergitster
authored andcommitted
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 <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ecd869 commit 0df8e96

32 files changed

+67
-53
lines changed

archive-tar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static int write_tar_entry(struct archiver_args *args,
276276
memcpy(header.name, path, pathlen);
277277

278278
if (S_ISREG(mode) && !args->convert &&
279-
oid_object_info(oid, &size) == OBJ_BLOB &&
279+
oid_object_info(the_repository, oid, &size) == OBJ_BLOB &&
280280
size > big_file_threshold)
281281
buffer = NULL;
282282
else if (S_ISLNK(mode) || S_ISREG(mode)) {

archive-zip.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,8 @@ static int write_zip_entry(struct archiver_args *args,
325325
compressed_size = 0;
326326
buffer = NULL;
327327
} else if (S_ISREG(mode) || S_ISLNK(mode)) {
328-
enum object_type type = oid_object_info(oid, &size);
328+
enum object_type type = oid_object_info(the_repository, oid,
329+
&size);
329330

330331
method = 0;
331332
attr2 = S_ISLNK(mode) ? ((mode | 0777) << 16) :

blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void verify_working_tree_path(struct commit *work_tree, const char *path)
8181
unsigned mode;
8282

8383
if (!get_tree_entry(commit_oid, path, &blob_oid, &mode) &&
84-
oid_object_info(&blob_oid, NULL) == OBJ_BLOB)
84+
oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB)
8585
return;
8686
}
8787

@@ -504,7 +504,7 @@ static int fill_blob_sha1_and_mode(struct blame_origin *origin)
504504
return 0;
505505
if (get_tree_entry(&origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
506506
goto error_out;
507-
if (oid_object_info(&origin->blob_oid, NULL) != OBJ_BLOB)
507+
if (oid_object_info(the_repository, &origin->blob_oid, NULL) != OBJ_BLOB)
508508
goto error_out;
509509
return 0;
510510
error_out:

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ static int is_a_rev(const char *name)
655655

656656
if (get_oid(name, &oid))
657657
return 0;
658-
return OBJ_NONE < oid_object_info(&oid, NULL);
658+
return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
659659
}
660660

661661
int cmd_blame(int argc, const char **argv, const char *prefix)

builtin/cat-file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
116116
/* else fallthrough */
117117

118118
case 'p':
119-
type = oid_object_info(&oid, NULL);
119+
type = oid_object_info(the_repository, &oid, NULL);
120120
if (type < 0)
121121
die("Not a valid object name %s", obj_name);
122122

@@ -140,7 +140,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
140140
case 0:
141141
if (type_from_string(exp_type) == OBJ_BLOB) {
142142
struct object_id blob_oid;
143-
if (oid_object_info(&oid, NULL) == OBJ_TAG) {
143+
if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
144144
char *buffer = read_object_file(&oid, &type,
145145
&size);
146146
const char *target;
@@ -151,7 +151,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
151151
} else
152152
oidcpy(&blob_oid, &oid);
153153

154-
if (oid_object_info(&blob_oid, NULL) == OBJ_BLOB)
154+
if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB)
155155
return stream_blob_to_fd(1, &blob_oid, NULL, 0);
156156
/*
157157
* we attempted to dereference a tag to a blob

builtin/describe.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ static void describe(const char *arg, int last_one)
502502

503503
if (cmit)
504504
describe_commit(&oid, &sb);
505-
else if (oid_object_info(&oid, NULL) == OBJ_BLOB)
505+
else if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)
506506
describe_blob(oid, &sb);
507507
else
508508
die(_("%s is neither a commit nor blob"), arg);

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ static void import_marks(char *input_file)
947947
if (last_idnum < mark)
948948
last_idnum = mark;
949949

950-
type = oid_object_info(&oid, NULL);
950+
type = oid_object_info(the_repository, &oid, NULL);
951951
if (type < 0)
952952
die("object not found: %s", oid_to_hex(&oid));
953953

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ static int update_local_ref(struct ref *ref,
637637
struct branch *current_branch = branch_get(NULL);
638638
const char *pretty_ref = prettify_refname(ref->name);
639639

640-
type = oid_object_info(&ref->new_oid, NULL);
640+
type = oid_object_info(the_repository, &ref->new_oid, NULL);
641641
if (type < 0)
642642
die(_("object %s not found"), oid_to_hex(&ref->new_oid));
643643

builtin/fsck.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ static const char *printable_type(struct object *obj)
6767
const char *ret;
6868

6969
if (obj->type == OBJ_NONE) {
70-
enum object_type type = oid_object_info(&obj->oid, NULL);
70+
enum object_type type = oid_object_info(the_repository,
71+
&obj->oid, NULL);
7172
if (type > 0)
7273
object_as_type(obj, type, 0);
7374
}

builtin/index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static unsigned check_object(struct object *obj)
223223

224224
if (!(obj->flags & FLAG_CHECKED)) {
225225
unsigned long size;
226-
int type = oid_object_info(&obj->oid, &size);
226+
int type = oid_object_info(the_repository, &obj->oid, &size);
227227
if (type <= 0)
228228
die(_("did not receive expected object %s"),
229229
oid_to_hex(&obj->oid));
@@ -812,7 +812,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
812812
enum object_type has_type;
813813
unsigned long has_size;
814814
read_lock();
815-
has_type = oid_object_info(oid, &has_size);
815+
has_type = oid_object_info(the_repository, oid, &has_size);
816816
if (has_type < 0)
817817
die(_("cannot read existing object info %s"), oid_to_hex(oid));
818818
if (has_type != type || has_size != size)

0 commit comments

Comments
 (0)