Skip to content

Commit bac0fee

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 61b886c commit bac0fee

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
@@ -132,7 +132,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
132132
switch (opt) {
133133
case 't':
134134
oi.typep = &type;
135-
if (oid_object_info_extended(the_repository, &oid, &oi, flags) < 0)
135+
if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
136136
die("git cat-file: could not get object info");
137137
printf("%s\n", type_name(type));
138138
ret = 0;
@@ -146,7 +146,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
146146
oi.contentp = (void**)&buf;
147147
}
148148

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

152152
if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
@@ -180,7 +180,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
180180
/* else fallthrough */
181181

182182
case 'p':
183-
type = oid_object_info(the_repository, &oid, NULL);
183+
type = odb_read_object_info(the_repository->objects, &oid, NULL);
184184
if (type < 0)
185185
die("Not a valid object name %s", obj_name);
186186

@@ -217,7 +217,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
217217

218218
if (exp_type_id == OBJ_BLOB) {
219219
struct object_id blob_oid;
220-
if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) {
220+
if (odb_read_object_info(the_repository->objects,
221+
&oid, NULL) == OBJ_TAG) {
221222
char *buffer = repo_read_object_file(the_repository,
222223
&oid,
223224
&type,
@@ -235,7 +236,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
235236
} else
236237
oidcpy(&blob_oid, &oid);
237238

238-
if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) {
239+
if (odb_read_object_info(the_repository->objects,
240+
&blob_oid, NULL) == OBJ_BLOB) {
239241
ret = stream_blob(&blob_oid);
240242
goto cleanup;
241243
}
@@ -294,7 +296,7 @@ struct expand_data {
294296

295297
/*
296298
* After a mark_query run, this object_info is set up to be
297-
* passed to oid_object_info_extended. It will point to the data
299+
* passed to odb_read_object_info_extended. It will point to the data
298300
* elements above, so you can retrieve the response from there.
299301
*/
300302
struct object_info info;
@@ -484,12 +486,12 @@ static void batch_object_write(const char *obj_name,
484486
data->info.sizep = &data->size;
485487

486488
if (pack)
487-
ret = packed_object_info(the_repository, pack, offset,
488-
&data->info);
489+
ret = packed_object_info(the_repository, pack,
490+
offset, &data->info);
489491
else
490-
ret = oid_object_info_extended(the_repository,
491-
&data->oid, &data->info,
492-
OBJECT_INFO_LOOKUP_REPLACE);
492+
ret = odb_read_object_info_extended(the_repository->objects,
493+
&data->oid, &data->info,
494+
OBJECT_INFO_LOOKUP_REPLACE);
493495
if (ret < 0) {
494496
report_object_status(opt, obj_name, &data->oid, "missing");
495497
return;
@@ -872,7 +874,7 @@ static int batch_objects(struct batch_options *opt)
872874

873875
/*
874876
* Expand once with our special mark_query flag, which will prime the
875-
* object_info to be handed to oid_object_info_extended for each
877+
* object_info to be handed to odb_read_object_info_extended for each
876878
* object.
877879
*/
878880
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
@@ -1080,7 +1080,7 @@ static int dfs_on_ref(const char *refname UNUSED,
10801080

10811081
if (!peel_iterated_oid(the_repository, oid, &peeled))
10821082
oid = &peeled;
1083-
if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT)
1083+
if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT)
10841084
return 0;
10851085

10861086
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)