Skip to content

Commit d4ff88a

Browse files
pks-tgitster
authored andcommitted
odb: rename repo_read_object_file()
Rename `repo_read_object_file()` to `odb_read_object()` to match other functions related to the object database and our modern coding guidelines. Introduce a compatibility wrapper 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 e989dd9 commit d4ff88a

Some content is hidden

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

47 files changed

+157
-150
lines changed

apply.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,8 +3210,8 @@ static int apply_binary(struct apply_state *state,
32103210
unsigned long size;
32113211
char *result;
32123212

3213-
result = repo_read_object_file(the_repository, &oid, &type,
3214-
&size);
3213+
result = odb_read_object(the_repository->objects, &oid,
3214+
&type, &size);
32153215
if (!result)
32163216
return error(_("the necessary postimage %s for "
32173217
"'%s' cannot be read"),
@@ -3273,8 +3273,8 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
32733273
unsigned long sz;
32743274
char *result;
32753275

3276-
result = repo_read_object_file(the_repository, oid, &type,
3277-
&sz);
3276+
result = odb_read_object(the_repository->objects, oid,
3277+
&type, &sz);
32783278
if (!result)
32793279
return -1;
32803280
/* XXX read_sha1_file NUL-terminates */
@@ -3503,7 +3503,7 @@ static int resolve_to(struct image *image, const struct object_id *result_id)
35033503

35043504
image_clear(image);
35053505

3506-
data = repo_read_object_file(the_repository, result_id, &type, &size);
3506+
data = odb_read_object(the_repository->objects, result_id, &type, &size);
35073507
if (!data || type != OBJ_BLOB)
35083508
die("unable to read blob object %s", oid_to_hex(result_id));
35093509
strbuf_attach(&image->buf, data, size, size + 1);

archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
9898
(args->tree ? &args->tree->object.oid : NULL), oid);
9999

100100
path += args->baselen;
101-
buffer = repo_read_object_file(the_repository, oid, type, sizep);
101+
buffer = odb_read_object(the_repository->objects, oid, type, sizep);
102102
if (buffer && S_ISREG(mode)) {
103103
struct strbuf buf = STRBUF_INIT;
104104
size_t size = 0;

attr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,
779779
if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))
780780
return NULL;
781781

782-
buf = repo_read_object_file(istate->repo, &oid, &type, &sz);
782+
buf = odb_read_object(istate->repo->objects, &oid, &type, &sz);
783783
if (!buf || type != OBJ_BLOB) {
784784
free(buf);
785785
return NULL;

bisect.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,9 @@ static void show_list(const char *debug, int counted, int nr,
155155
unsigned commit_flags = commit->object.flags;
156156
enum object_type type;
157157
unsigned long size;
158-
char *buf = repo_read_object_file(the_repository,
159-
&commit->object.oid, &type,
160-
&size);
158+
char *buf = odb_read_object(the_repository->objects,
159+
&commit->object.oid, &type,
160+
&size);
161161
const char *subject_start;
162162
int subject_len;
163163

blame.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,9 @@ static void fill_origin_blob(struct diff_options *opt,
10411041
&o->blob_oid, 1, &file->ptr, &file_size))
10421042
;
10431043
else
1044-
file->ptr = repo_read_object_file(the_repository,
1045-
&o->blob_oid, &type,
1046-
&file_size);
1044+
file->ptr = odb_read_object(the_repository->objects,
1045+
&o->blob_oid, &type,
1046+
&file_size);
10471047
file->size = file_size;
10481048

10491049
if (!file->ptr)
@@ -2869,10 +2869,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,
28692869
&sb->final_buf_size))
28702870
;
28712871
else
2872-
sb->final_buf = repo_read_object_file(the_repository,
2873-
&o->blob_oid,
2874-
&type,
2875-
&sb->final_buf_size);
2872+
sb->final_buf = odb_read_object(the_repository->objects,
2873+
&o->blob_oid, &type,
2874+
&sb->final_buf_size);
28762875

28772876
if (!sb->final_buf)
28782877
die(_("cannot read blob %s for path %s"),

builtin/cat-file.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ static int filter_object(const char *path, unsigned mode,
7474
{
7575
enum object_type type;
7676

77-
*buf = repo_read_object_file(the_repository, oid, &type, size);
77+
*buf = odb_read_object(the_repository->objects, oid, &type, size);
7878
if (!*buf)
7979
return error(_("cannot read object %s '%s'"),
8080
oid_to_hex(oid), path);
@@ -197,8 +197,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
197197
ret = stream_blob(&oid);
198198
goto cleanup;
199199
}
200-
buf = repo_read_object_file(the_repository, &oid, &type,
201-
&size);
200+
buf = odb_read_object(the_repository->objects, &oid,
201+
&type, &size);
202202
if (!buf)
203203
die("Cannot read object %s", obj_name);
204204

@@ -219,10 +219,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
219219
struct object_id blob_oid;
220220
if (odb_read_object_info(the_repository->objects,
221221
&oid, NULL) == OBJ_TAG) {
222-
char *buffer = repo_read_object_file(the_repository,
223-
&oid,
224-
&type,
225-
&size);
222+
char *buffer = odb_read_object(the_repository->objects,
223+
&oid, &type, &size);
226224
const char *target;
227225

228226
if (!buffer)
@@ -403,10 +401,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
403401
if (!textconv_object(the_repository,
404402
data->rest, 0100644, oid,
405403
1, &contents, &size))
406-
contents = repo_read_object_file(the_repository,
407-
oid,
408-
&type,
409-
&size);
404+
contents = odb_read_object(the_repository->objects,
405+
oid, &type, &size);
410406
if (!contents)
411407
die("could not convert '%s' %s",
412408
oid_to_hex(oid), data->rest);
@@ -423,8 +419,8 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
423419
unsigned long size;
424420
void *contents;
425421

426-
contents = repo_read_object_file(the_repository, oid, &type,
427-
&size);
422+
contents = odb_read_object(the_repository->objects, oid,
423+
&type, &size);
428424
if (!contents)
429425
die("object %s disappeared", oid_to_hex(oid));
430426

@@ -533,8 +529,8 @@ static void batch_object_write(const char *obj_name,
533529
size_t s = data->size;
534530
char *buf = NULL;
535531

536-
buf = repo_read_object_file(the_repository, &data->oid, &data->type,
537-
&data->size);
532+
buf = odb_read_object(the_repository->objects, &data->oid,
533+
&data->type, &data->size);
538534
if (!buf)
539535
die(_("unable to read %s"), oid_to_hex(&data->oid));
540536
buf = replace_idents_using_mailmap(buf, &s);

builtin/difftool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static char *get_symlink(struct repository *repo,
320320
} else {
321321
enum object_type type;
322322
unsigned long size;
323-
data = repo_read_object_file(repo, oid, &type, &size);
323+
data = odb_read_object(repo->objects, oid, &type, &size);
324324
if (!data)
325325
die(_("could not read object %s for symlink %s"),
326326
oid_to_hex(oid), path);

builtin/fast-export.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static void export_blob(const struct object_id *oid)
323323
object = (struct object *)lookup_blob(the_repository, oid);
324324
eaten = 0;
325325
} else {
326-
buf = repo_read_object_file(the_repository, oid, &type, &size);
326+
buf = odb_read_object(the_repository->objects, oid, &type, &size);
327327
if (!buf)
328328
die("could not read blob %s", oid_to_hex(oid));
329329
if (check_object_signature(the_repository, oid, buf, size,
@@ -869,8 +869,8 @@ static void handle_tag(const char *name, struct tag *tag)
869869
return;
870870
}
871871

872-
buf = repo_read_object_file(the_repository, &tag->object.oid, &type,
873-
&size);
872+
buf = odb_read_object(the_repository->objects, &tag->object.oid,
873+
&type, &size);
874874
if (!buf)
875875
die("could not read tag %s", oid_to_hex(&tag->object.oid));
876876
message = memmem(buf, size, "\n\n", 2);

builtin/fast-import.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ static void load_tree(struct tree_entry *root)
12651265
die("Can't load tree %s", oid_to_hex(oid));
12661266
} else {
12671267
enum object_type type;
1268-
buf = repo_read_object_file(the_repository, oid, &type, &size);
1268+
buf = odb_read_object(the_repository->objects, oid, &type, &size);
12691269
if (!buf || type != OBJ_TREE)
12701270
die("Can't load tree %s", oid_to_hex(oid));
12711271
}
@@ -3002,7 +3002,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
30023002
char *buf;
30033003

30043004
if (!oe || oe->pack_id == MAX_PACK_ID) {
3005-
buf = repo_read_object_file(the_repository, oid, &type, &size);
3005+
buf = odb_read_object(the_repository->objects, oid, &type, &size);
30063006
} else {
30073007
type = oe->type;
30083008
buf = gfi_unpack_entry(oe, &size);
@@ -3110,8 +3110,8 @@ static struct object_entry *dereference(struct object_entry *oe,
31103110
buf = gfi_unpack_entry(oe, &size);
31113111
} else {
31123112
enum object_type unused;
3113-
buf = repo_read_object_file(the_repository, oid, &unused,
3114-
&size);
3113+
buf = odb_read_object(the_repository->objects, oid,
3114+
&unused, &size);
31153115
}
31163116
if (!buf)
31173117
die("Can't load object %s", oid_to_hex(oid));

builtin/grep.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,8 @@ static int grep_cache(struct grep_opt *opt,
573573
void *data;
574574
unsigned long size;
575575

576-
data = repo_read_object_file(the_repository, &ce->oid,
577-
&type, &size);
576+
data = odb_read_object(the_repository->objects, &ce->oid,
577+
&type, &size);
578578
if (!data)
579579
die(_("unable to read tree %s"), oid_to_hex(&ce->oid));
580580
init_tree_desc(&tree, &ce->oid, data, size);
@@ -666,8 +666,8 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
666666
void *data;
667667
unsigned long size;
668668

669-
data = repo_read_object_file(the_repository,
670-
&entry.oid, &type, &size);
669+
data = odb_read_object(the_repository->objects,
670+
&entry.oid, &type, &size);
671671
if (!data)
672672
die(_("unable to read tree (%s)"),
673673
oid_to_hex(&entry.oid));

0 commit comments

Comments
 (0)