Skip to content

Commit 3b30cc3

Browse files
pks-tgitster
authored andcommitted
odb: rename oid_object_info()
Rename `oid_object_info()` to `odb_read_object_info()` as well as their `_extended()` variant to match other functions related to the object database and our modern coding guidelines. Introduce compatibility wrappers so that any in-flight topics will continue to compile. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 351d77e commit 3b30cc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+213
-170
lines changed

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
215215

216216
/* Stream it? */
217217
if (S_ISREG(mode) && !args->convert &&
218-
oid_object_info(args->repo, oid, &size) == OBJ_BLOB &&
218+
odb_read_object_info(args->repo->objects, oid, &size) == OBJ_BLOB &&
219219
size > repo_settings_get_big_file_threshold(the_repository))
220220
return write_entry(args, oid, path.buf, path.len, mode, NULL, size);
221221

blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,
116116
unsigned short mode;
117117

118118
if (!get_tree_entry(r, commit_oid, path, &blob_oid, &mode) &&
119-
oid_object_info(r, &blob_oid, NULL) == OBJ_BLOB)
119+
odb_read_object_info(r->objects, &blob_oid, NULL) == OBJ_BLOB)
120120
return;
121121
}
122122

@@ -1245,7 +1245,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,
12451245
return 0;
12461246
if (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
12471247
goto error_out;
1248-
if (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB)
1248+
if (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB)
12491249
goto error_out;
12501250
return 0;
12511251
error_out:

builtin/blame.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ static int is_a_rev(const char *name)
837837

838838
if (repo_get_oid(the_repository, name, &oid))
839839
return 0;
840-
return OBJ_NONE < oid_object_info(the_repository, &oid, NULL);
840+
return OBJ_NONE < odb_read_object_info(the_repository->objects, &oid, NULL);
841841
}
842842

843843
static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
@@ -848,7 +848,7 @@ static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata)
848848
oidcpy(&oid, oid_ret);
849849
while (1) {
850850
struct object *obj;
851-
int kind = oid_object_info(r, &oid, NULL);
851+
int kind = odb_read_object_info(r->objects, &oid, NULL);
852852
if (kind == OBJ_COMMIT) {
853853
oidcpy(oid_ret, &oid);
854854
return 0;

builtin/cat-file.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
137137
switch (opt) {
138138
case 't':
139139
oi.type_name = &sb;
140-
if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
140+
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
141141
die("git cat-file: could not get object info");
142142
if (sb.len) {
143143
printf("%s\n", sb.buf);
@@ -155,7 +155,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
155155
oi.contentp = (void**)&buf;
156156
}
157157

158-
if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
158+
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
159159
die("git cat-file: could not get object info");
160160

161161
if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
@@ -189,7 +189,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
189189
/* else fallthrough */
190190

191191
case 'p':
192-
type = oid_object_info(the_repository, &oid, NULL);
192+
type = odb_read_object_info(the_repository->objects, &oid, NULL);
193193
if (type < 0)
194194
die("Not a valid object name %s", obj_name);
195195

@@ -226,7 +226,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
226226

227227
if (exp_type_id == OBJ_BLOB) {
228228
struct object_id blob_oid;
229-
if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
229+
if (odb_read_object_info(the_repository->objects,
230+
&oid, NULL) == OBJ_TAG) {
230231
char *buffer = repo_read_object_file(the_repository,
231232
&oid,
232233
&type,
@@ -244,7 +245,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
244245
} else
245246
oidcpy(&blob_oid, &oid);
246247

247-
if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {
248+
if (odb_read_object_info(the_repository->objects,
249+
&blob_oid, NULL) == OBJ_BLOB) {
248250
ret = stream_blob(&blob_oid);
249251
goto cleanup;
250252
}
@@ -303,7 +305,7 @@ struct expand_data {
303305

304306
/*
305307
* After a mark_query run, this object_info is set up to be
306-
* passed to oid_object_info_extended. It will point to the data
308+
* passed to odb_read_object_info_extended. It will point to the data
307309
* elements above, so you can retrieve the response from there.
308310
*/
309311
struct object_info info;
@@ -493,12 +495,12 @@ static void batch_object_write(const char *obj_name,
493495
data->info.sizep = &data->size;
494496

495497
if (pack)
496-
ret = packed_object_info(the_repository, pack, offset,
497-
&data->info);
498+
ret = packed_object_info(the_repository, pack,
499+
offset, &data->info);
498500
else
499-
ret = oid_object_info_extended(the_repository,
500-
&data->oid, &data->info,
501-
OBJECT_INFO_LOOKUP_REPLACE);
501+
ret = odb_read_object_info_extended(the_repository->objects,
502+
&data->oid, &data->info,
503+
OBJECT_INFO_LOOKUP_REPLACE);
502504
if (ret < 0) {
503505
report_object_status(opt, obj_name, &data->oid, "missing");
504506
return;
@@ -881,7 +883,7 @@ static int batch_objects(struct batch_options *opt)
881883

882884
/*
883885
* Expand once with our special mark_query flag, which will prime the
884-
* object_info to be handed to oid_object_info_extended for each
886+
* object_info to be handed to odb_read_object_info_extended for each
885887
* object.
886888
*/
887889
memset(&data, 0, sizeof(data));

builtin/describe.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ static void describe(const char *arg, int last_one)
552552

553553
if (cmit)
554554
describe_commit(&oid, &sb);
555-
else if (oid_object_info(the_repository, &oid, NULL) == OBJ_BLOB)
555+
else if (odb_read_object_info(the_repository->objects,
556+
&oid, NULL) == OBJ_BLOB)
556557
describe_blob(oid, &sb);
557558
else
558559
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
@@ -1200,7 +1200,7 @@ static void import_marks(char *input_file, int check_exists)
12001200
if (last_idnum < mark)
12011201
last_idnum = mark;
12021202

1203-
type = oid_object_info(the_repository, &oid, NULL);
1203+
type = odb_read_object_info(the_repository->objects, &oid, NULL);
12041204
if (type < 0)
12051205
die("object not found: %s", oid_to_hex(&oid));
12061206

builtin/fast-import.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,8 +1756,8 @@ static void insert_object_entry(struct mark_set **s, struct object_id *oid, uint
17561756
struct object_entry *e;
17571757
e = find_object(oid);
17581758
if (!e) {
1759-
enum object_type type = oid_object_info(the_repository,
1760-
oid, NULL);
1759+
enum object_type type = odb_read_object_info(the_repository->objects,
1760+
oid, NULL);
17611761
if (type < 0)
17621762
die("object not found: %s", oid_to_hex(oid));
17631763
e = insert_object(oid);
@@ -2416,8 +2416,8 @@ static void file_change_m(const char *p, struct branch *b)
24162416
enum object_type expected = S_ISDIR(mode) ?
24172417
OBJ_TREE: OBJ_BLOB;
24182418
enum object_type type = oe ? oe->type :
2419-
oid_object_info(the_repository, &oid,
2420-
NULL);
2419+
odb_read_object_info(the_repository->objects,
2420+
&oid, NULL);
24212421
if (type < 0)
24222422
die("%s not found: %s",
24232423
S_ISDIR(mode) ? "Tree" : "Blob",
@@ -2553,7 +2553,7 @@ static void note_change_n(const char *p, struct branch *b, unsigned char *old_fa
25532553
die("Not a blob (actually a %s): %s",
25542554
type_name(oe->type), command_buf.buf);
25552555
} else if (!is_null_oid(&oid)) {
2556-
enum object_type type = oid_object_info(the_repository, &oid,
2556+
enum object_type type = odb_read_object_info(the_repository->objects, &oid,
25572557
NULL);
25582558
if (type < 0)
25592559
die("Blob not found: %s", command_buf.buf);
@@ -2895,7 +2895,8 @@ static void parse_new_tag(const char *arg)
28952895
} else if (!repo_get_oid(the_repository, from, &oid)) {
28962896
struct object_entry *oe = find_object(&oid);
28972897
if (!oe) {
2898-
type = oid_object_info(the_repository, &oid, NULL);
2898+
type = odb_read_object_info(the_repository->objects,
2899+
&oid, NULL);
28992900
if (type < 0)
29002901
die("Not a valid object: %s", from);
29012902
} else
@@ -3085,8 +3086,8 @@ static struct object_entry *dereference(struct object_entry *oe,
30853086
const unsigned hexsz = the_hash_algo->hexsz;
30863087

30873088
if (!oe) {
3088-
enum object_type type = oid_object_info(the_repository, oid,
3089-
NULL);
3089+
enum object_type type = odb_read_object_info(the_repository->objects,
3090+
oid, NULL);
30903091
if (type < 0)
30913092
die("object not found: %s", oid_to_hex(oid));
30923093
/* cache it! */

builtin/fsck.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ static const char *printable_type(const struct object_id *oid,
7171
const char *ret;
7272

7373
if (type == OBJ_NONE)
74-
type = oid_object_info(the_repository, oid, NULL);
74+
type = odb_read_object_info(the_repository->objects,
75+
oid, NULL);
7576

7677
ret = type_name(type);
7778
if (!ret)
@@ -232,8 +233,8 @@ static void mark_unreachable_referents(const struct object_id *oid)
232233
* (and we want to avoid parsing blobs).
233234
*/
234235
if (obj->type == OBJ_NONE) {
235-
enum object_type type = oid_object_info(the_repository,
236-
&obj->oid, NULL);
236+
enum object_type type = odb_read_object_info(the_repository->objects,
237+
&obj->oid, NULL);
237238
if (type > 0)
238239
object_as_type(obj, type, 0);
239240
}

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ static int dfs_on_ref(const char *refname UNUSED,
10061006

10071007
if (!peel_iterated_oid(the_repository, oid, &peeled))
10081008
oid = &peeled;
1009-
if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
1009+
if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
10101010
return 0;
10111011

10121012
commit = lookup_commit(the_repository, oid);

builtin/grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static int grep_submodule(struct grep_opt *opt,
520520
struct strbuf base = STRBUF_INIT;
521521

522522
obj_read_lock();
523-
object_type = oid_object_info(subrepo, oid, NULL);
523+
object_type = odb_read_object_info(subrepo->objects, oid, NULL);
524524
obj_read_unlock();
525525
data = read_object_with_reference(subrepo,
526526
oid, OBJ_TREE,

0 commit comments

Comments
 (0)