Git fork

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 <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
d4ff88ae e989dd96

+157 -150
+5 -5
apply.c
··· 3210 3210 unsigned long size; 3211 3211 char *result; 3212 3212 3213 - result = repo_read_object_file(the_repository, &oid, &type, 3214 - &size); 3213 + result = odb_read_object(the_repository->objects, &oid, 3214 + &type, &size); 3215 3215 if (!result) 3216 3216 return error(_("the necessary postimage %s for " 3217 3217 "'%s' cannot be read"), ··· 3273 3273 unsigned long sz; 3274 3274 char *result; 3275 3275 3276 - result = repo_read_object_file(the_repository, oid, &type, 3277 - &sz); 3276 + result = odb_read_object(the_repository->objects, oid, 3277 + &type, &sz); 3278 3278 if (!result) 3279 3279 return -1; 3280 3280 /* XXX read_sha1_file NUL-terminates */ ··· 3503 3503 3504 3504 image_clear(image); 3505 3505 3506 - data = repo_read_object_file(the_repository, result_id, &type, &size); 3506 + data = odb_read_object(the_repository->objects, result_id, &type, &size); 3507 3507 if (!data || type != OBJ_BLOB) 3508 3508 die("unable to read blob object %s", oid_to_hex(result_id)); 3509 3509 strbuf_attach(&image->buf, data, size, size + 1);
+1 -1
archive.c
··· 98 98 (args->tree ? &args->tree->object.oid : NULL), oid); 99 99 100 100 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); 102 102 if (buffer && S_ISREG(mode)) { 103 103 struct strbuf buf = STRBUF_INIT; 104 104 size_t size = 0;
+1 -1
attr.c
··· 779 779 if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode)) 780 780 return NULL; 781 781 782 - buf = repo_read_object_file(istate->repo, &oid, &type, &sz); 782 + buf = odb_read_object(istate->repo->objects, &oid, &type, &sz); 783 783 if (!buf || type != OBJ_BLOB) { 784 784 free(buf); 785 785 return NULL;
+3 -3
bisect.c
··· 155 155 unsigned commit_flags = commit->object.flags; 156 156 enum object_type type; 157 157 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); 161 161 const char *subject_start; 162 162 int subject_len; 163 163
+6 -7
blame.c
··· 1041 1041 &o->blob_oid, 1, &file->ptr, &file_size)) 1042 1042 ; 1043 1043 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); 1047 1047 file->size = file_size; 1048 1048 1049 1049 if (!file->ptr) ··· 2869 2869 &sb->final_buf_size)) 2870 2870 ; 2871 2871 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); 2876 2875 2877 2876 if (!sb->final_buf) 2878 2877 die(_("cannot read blob %s for path %s"),
+11 -15
builtin/cat-file.c
··· 74 74 { 75 75 enum object_type type; 76 76 77 - *buf = repo_read_object_file(the_repository, oid, &type, size); 77 + *buf = odb_read_object(the_repository->objects, oid, &type, size); 78 78 if (!*buf) 79 79 return error(_("cannot read object %s '%s'"), 80 80 oid_to_hex(oid), path); ··· 197 197 ret = stream_blob(&oid); 198 198 goto cleanup; 199 199 } 200 - buf = repo_read_object_file(the_repository, &oid, &type, 201 - &size); 200 + buf = odb_read_object(the_repository->objects, &oid, 201 + &type, &size); 202 202 if (!buf) 203 203 die("Cannot read object %s", obj_name); 204 204 ··· 219 219 struct object_id blob_oid; 220 220 if (odb_read_object_info(the_repository->objects, 221 221 &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); 226 224 const char *target; 227 225 228 226 if (!buffer) ··· 403 401 if (!textconv_object(the_repository, 404 402 data->rest, 0100644, oid, 405 403 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); 410 406 if (!contents) 411 407 die("could not convert '%s' %s", 412 408 oid_to_hex(oid), data->rest); ··· 423 419 unsigned long size; 424 420 void *contents; 425 421 426 - contents = repo_read_object_file(the_repository, oid, &type, 427 - &size); 422 + contents = odb_read_object(the_repository->objects, oid, 423 + &type, &size); 428 424 if (!contents) 429 425 die("object %s disappeared", oid_to_hex(oid)); 430 426 ··· 533 529 size_t s = data->size; 534 530 char *buf = NULL; 535 531 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); 538 534 if (!buf) 539 535 die(_("unable to read %s"), oid_to_hex(&data->oid)); 540 536 buf = replace_idents_using_mailmap(buf, &s);
+1 -1
builtin/difftool.c
··· 320 320 } else { 321 321 enum object_type type; 322 322 unsigned long size; 323 - data = repo_read_object_file(repo, oid, &type, &size); 323 + data = odb_read_object(repo->objects, oid, &type, &size); 324 324 if (!data) 325 325 die(_("could not read object %s for symlink %s"), 326 326 oid_to_hex(oid), path);
+3 -3
builtin/fast-export.c
··· 323 323 object = (struct object *)lookup_blob(the_repository, oid); 324 324 eaten = 0; 325 325 } else { 326 - buf = repo_read_object_file(the_repository, oid, &type, &size); 326 + buf = odb_read_object(the_repository->objects, oid, &type, &size); 327 327 if (!buf) 328 328 die("could not read blob %s", oid_to_hex(oid)); 329 329 if (check_object_signature(the_repository, oid, buf, size, ··· 869 869 return; 870 870 } 871 871 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); 874 874 if (!buf) 875 875 die("could not read tag %s", oid_to_hex(&tag->object.oid)); 876 876 message = memmem(buf, size, "\n\n", 2);
+4 -4
builtin/fast-import.c
··· 1265 1265 die("Can't load tree %s", oid_to_hex(oid)); 1266 1266 } else { 1267 1267 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); 1269 1269 if (!buf || type != OBJ_TREE) 1270 1270 die("Can't load tree %s", oid_to_hex(oid)); 1271 1271 } ··· 3002 3002 char *buf; 3003 3003 3004 3004 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); 3006 3006 } else { 3007 3007 type = oe->type; 3008 3008 buf = gfi_unpack_entry(oe, &size); ··· 3110 3110 buf = gfi_unpack_entry(oe, &size); 3111 3111 } else { 3112 3112 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); 3115 3115 } 3116 3116 if (!buf) 3117 3117 die("Can't load object %s", oid_to_hex(oid));
+4 -4
builtin/grep.c
··· 573 573 void *data; 574 574 unsigned long size; 575 575 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); 578 578 if (!data) 579 579 die(_("unable to read tree %s"), oid_to_hex(&ce->oid)); 580 580 init_tree_desc(&tree, &ce->oid, data, size); ··· 666 666 void *data; 667 667 unsigned long size; 668 668 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); 671 671 if (!data) 672 672 die(_("unable to read tree (%s)"), 673 673 oid_to_hex(&entry.oid));
+4 -4
builtin/index-pack.c
··· 914 914 die(_("cannot read existing object info %s"), oid_to_hex(oid)); 915 915 if (has_type != type || has_size != size) 916 916 die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid)); 917 - has_data = repo_read_object_file(the_repository, oid, 918 - &has_type, &has_size); 917 + has_data = odb_read_object(the_repository->objects, oid, 918 + &has_type, &has_size); 919 919 read_unlock(); 920 920 if (!data) 921 921 data = new_data = get_data_from_pack(obj_entry); ··· 1521 1521 1522 1522 if (objects[d->obj_no].real_type != OBJ_REF_DELTA) 1523 1523 continue; 1524 - data = repo_read_object_file(the_repository, &d->oid, &type, 1525 - &size); 1524 + data = odb_read_object(the_repository->objects, &d->oid, 1525 + &type, &size); 1526 1526 if (!data) 1527 1527 continue; 1528 1528
+1 -1
builtin/log.c
··· 714 714 { 715 715 unsigned long size; 716 716 enum object_type type; 717 - char *buf = repo_read_object_file(the_repository, oid, &type, &size); 717 + char *buf = odb_read_object(the_repository->objects, oid, &type, &size); 718 718 unsigned long offset = 0; 719 719 720 720 if (!buf)
+6 -6
builtin/merge-tree.c
··· 75 75 const char *path = entry->path; 76 76 77 77 if (!entry->stage) 78 - return repo_read_object_file(the_repository, 79 - &entry->blob->object.oid, &type, 80 - size); 78 + return odb_read_object(the_repository->objects, 79 + &entry->blob->object.oid, &type, 80 + size); 81 81 base = NULL; 82 82 if (entry->stage == 1) { 83 83 base = entry->blob; ··· 100 100 enum object_type type; 101 101 while (entry) { 102 102 if (entry->stage == 2) 103 - return repo_read_object_file(the_repository, 104 - &entry->blob->object.oid, 105 - &type, size); 103 + return odb_read_object(the_repository->objects, 104 + &entry->blob->object.oid, 105 + &type, size); 106 106 entry = entry->link; 107 107 } 108 108 return NULL;
+2 -2
builtin/mktag.c
··· 54 54 void *buffer; 55 55 const struct object_id *repl; 56 56 57 - buffer = repo_read_object_file(the_repository, tagged_oid, &type, 58 - &size); 57 + buffer = odb_read_object(the_repository->objects, tagged_oid, 58 + &type, &size); 59 59 if (!buffer) 60 60 die(_("could not read tagged object '%s'"), 61 61 oid_to_hex(tagged_oid));
+3 -3
builtin/notes.c
··· 152 152 { 153 153 unsigned long size; 154 154 enum object_type type; 155 - char *buf = repo_read_object_file(the_repository, oid, &type, &size); 155 + char *buf = odb_read_object(the_repository->objects, oid, &type, &size); 156 156 if (buf) { 157 157 if (size) 158 158 write_or_die(fd, buf, size); ··· 319 319 strbuf_init(&msg->buf, 0); 320 320 if (repo_get_oid(the_repository, arg, &object)) 321 321 die(_("failed to resolve '%s' as a valid ref."), arg); 322 - if (!(value = repo_read_object_file(the_repository, &object, &type, &len))) 322 + if (!(value = odb_read_object(the_repository->objects, &object, &type, &len))) 323 323 die(_("failed to read object '%s'."), arg); 324 324 if (type != OBJ_BLOB) { 325 325 strbuf_release(&msg->buf); ··· 722 722 unsigned long size; 723 723 enum object_type type; 724 724 struct strbuf buf = STRBUF_INIT; 725 - char *prev_buf = repo_read_object_file(the_repository, note, &type, &size); 725 + char *prev_buf = odb_read_object(the_repository->objects, note, &type, &size); 726 726 727 727 if (!prev_buf) 728 728 die(_("unable to read %s"), oid_to_hex(note));
+15 -15
builtin/pack-objects.c
··· 337 337 void *buf, *base_buf, *delta_buf; 338 338 enum object_type type; 339 339 340 - buf = repo_read_object_file(the_repository, &entry->idx.oid, &type, 341 - &size); 340 + buf = odb_read_object(the_repository->objects, &entry->idx.oid, 341 + &type, &size); 342 342 if (!buf) 343 343 die(_("unable to read %s"), oid_to_hex(&entry->idx.oid)); 344 - base_buf = repo_read_object_file(the_repository, 345 - &DELTA(entry)->idx.oid, &type, 346 - &base_size); 344 + base_buf = odb_read_object(the_repository->objects, 345 + &DELTA(entry)->idx.oid, &type, 346 + &base_size); 347 347 if (!base_buf) 348 348 die("unable to read %s", 349 349 oid_to_hex(&DELTA(entry)->idx.oid)); ··· 506 506 &size, NULL)) != NULL) 507 507 buf = NULL; 508 508 else { 509 - buf = repo_read_object_file(the_repository, 510 - &entry->idx.oid, &type, 511 - &size); 509 + buf = odb_read_object(the_repository->objects, 510 + &entry->idx.oid, &type, 511 + &size); 512 512 if (!buf) 513 513 die(_("unable to read %s"), 514 514 oid_to_hex(&entry->idx.oid)); ··· 1895 1895 /* Did not find one. Either we got a bogus request or 1896 1896 * we need to read and perhaps cache. 1897 1897 */ 1898 - data = repo_read_object_file(the_repository, oid, &type, &size); 1898 + data = odb_read_object(the_repository->objects, oid, &type, &size); 1899 1899 if (!data) 1900 1900 return NULL; 1901 1901 if (type != OBJ_TREE) { ··· 2762 2762 /* Load data if not already done */ 2763 2763 if (!trg->data) { 2764 2764 packing_data_lock(&to_pack); 2765 - trg->data = repo_read_object_file(the_repository, 2766 - &trg_entry->idx.oid, &type, 2767 - &sz); 2765 + trg->data = odb_read_object(the_repository->objects, 2766 + &trg_entry->idx.oid, &type, 2767 + &sz); 2768 2768 packing_data_unlock(&to_pack); 2769 2769 if (!trg->data) 2770 2770 die(_("object %s cannot be read"), ··· 2777 2777 } 2778 2778 if (!src->data) { 2779 2779 packing_data_lock(&to_pack); 2780 - src->data = repo_read_object_file(the_repository, 2781 - &src_entry->idx.oid, &type, 2782 - &sz); 2780 + src->data = odb_read_object(the_repository->objects, 2781 + &src_entry->idx.oid, &type, 2782 + &sz); 2783 2783 packing_data_unlock(&to_pack); 2784 2784 if (!src->data) { 2785 2785 if (src_entry->preferred_base) {
+2 -2
builtin/tag.c
··· 244 244 struct strbuf payload = STRBUF_INIT; 245 245 struct strbuf signature = STRBUF_INIT; 246 246 247 - orig = buf = repo_read_object_file(the_repository, oid, &type, &size); 247 + orig = buf = odb_read_object(the_repository->objects, oid, &type, &size); 248 248 if (!buf) 249 249 return; 250 250 if (parse_signature(buf, size, &payload, &signature)) { ··· 407 407 strbuf_addstr(sb, "object of unknown type"); 408 408 break; 409 409 case OBJ_COMMIT: 410 - if ((buf = repo_read_object_file(the_repository, oid, &type, &size))) { 410 + if ((buf = odb_read_object(the_repository->objects, oid, &type, &size))) { 411 411 subject_len = find_commit_subject(buf, &subject_start); 412 412 strbuf_insert(sb, sb->len, subject_start, subject_len); 413 413 } else {
+1 -1
builtin/unpack-file.c
··· 14 14 unsigned long size; 15 15 int fd; 16 16 17 - buf = repo_read_object_file(the_repository, oid, &type, &size); 17 + buf = odb_read_object(the_repository->objects, oid, &type, &size); 18 18 if (!buf || type != OBJ_BLOB) 19 19 die("unable to read blob object %s", oid_to_hex(oid)); 20 20
+2 -2
builtin/unpack-objects.c
··· 516 516 if (resolve_against_held(nr, &base_oid, delta_data, delta_size)) 517 517 return; 518 518 519 - base = repo_read_object_file(the_repository, &base_oid, &type, 520 - &base_size); 519 + base = odb_read_object(the_repository->objects, &base_oid, 520 + &type, &base_size); 521 521 if (!base) { 522 522 error("failed to read delta-pack base object %s", 523 523 oid_to_hex(&base_oid));
+1 -1
bundle.c
··· 305 305 if (revs->max_age == -1 && revs->min_age == -1) 306 306 goto out; 307 307 308 - buf = repo_read_object_file(the_repository, &tag->oid, &type, &size); 308 + buf = odb_read_object(the_repository->objects, &tag->oid, &type, &size); 309 309 if (!buf) 310 310 goto out; 311 311 line = memmem(buf, size, "\ntagger ", 8);
+1 -1
combine-diff.c
··· 325 325 *size = fill_textconv(r, textconv, df, &blob); 326 326 free_filespec(df); 327 327 } else { 328 - blob = repo_read_object_file(r, oid, &type, size); 328 + blob = odb_read_object(r->objects, oid, &type, size); 329 329 if (!blob) 330 330 die(_("unable to read %s"), oid_to_hex(oid)); 331 331 if (type != OBJ_BLOB)
+3 -3
commit.c
··· 374 374 if (!ret) { 375 375 enum object_type type; 376 376 unsigned long size; 377 - ret = repo_read_object_file(r, &commit->object.oid, &type, &size); 377 + ret = odb_read_object(r->objects, &commit->object.oid, &type, &size); 378 378 if (!ret) 379 379 die("cannot read commit object %s", 380 380 oid_to_hex(&commit->object.oid)); ··· 1275 1275 desc = merge_remote_util(parent); 1276 1276 if (!desc || !desc->obj) 1277 1277 return; 1278 - buf = repo_read_object_file(the_repository, &desc->obj->oid, &type, 1279 - &size); 1278 + buf = odb_read_object(the_repository->objects, &desc->obj->oid, 1279 + &type, &size); 1280 1280 if (!buf || type != OBJ_TAG) 1281 1281 goto free_return; 1282 1282 if (!parse_signature(buf, size, &payload, &signature))
+1 -1
config.c
··· 1942 1942 unsigned long size; 1943 1943 int ret; 1944 1944 1945 - buf = repo_read_object_file(repo, oid, &type, &size); 1945 + buf = odb_read_object(repo->objects, oid, &type, &size); 1946 1946 if (!buf) 1947 1947 return error(_("unable to load config blob object '%s'"), name); 1948 1948 if (type != OBJ_BLOB) {
+1 -1
dir.c
··· 302 302 *size_out = 0; 303 303 *data_out = NULL; 304 304 305 - data = repo_read_object_file(the_repository, oid, &type, &sz); 305 + data = odb_read_object(the_repository->objects, oid, &type, &sz); 306 306 if (!data || type != OBJ_BLOB) { 307 307 free(data); 308 308 return -1;
+2 -2
entry.c
··· 93 93 { 94 94 enum object_type type; 95 95 unsigned long ul; 96 - void *blob_data = repo_read_object_file(the_repository, &ce->oid, 97 - &type, &ul); 96 + void *blob_data = odb_read_object(the_repository->objects, &ce->oid, 97 + &type, &ul); 98 98 99 99 *size = ul; 100 100 if (blob_data) {
+2 -2
fmt-merge-msg.c
··· 526 526 struct object_id *oid = origins.items[i].util; 527 527 enum object_type type; 528 528 unsigned long size; 529 - char *buf = repo_read_object_file(the_repository, oid, &type, 530 - &size); 529 + char *buf = odb_read_object(the_repository->objects, oid, 530 + &type, &size); 531 531 char *origbuf = buf; 532 532 unsigned long len = size; 533 533 struct signature_check sigc = { NULL };
+1 -1
fsck.c
··· 1293 1293 if (oidset_contains(blobs_done, oid)) 1294 1294 continue; 1295 1295 1296 - buf = repo_read_object_file(the_repository, oid, &type, &size); 1296 + buf = odb_read_object(the_repository->objects, oid, &type, &size); 1297 1297 if (!buf) { 1298 1298 if (is_promisor_object(the_repository, oid)) 1299 1299 continue;
+2 -2
grep.c
··· 1931 1931 { 1932 1932 enum object_type type; 1933 1933 1934 - gs->buf = repo_read_object_file(gs->repo, gs->identifier, &type, 1935 - &gs->size); 1934 + gs->buf = odb_read_object(gs->repo->objects, gs->identifier, 1935 + &type, &gs->size); 1936 1936 if (!gs->buf) 1937 1937 return error(_("'%s': unable to read %s"), 1938 1938 gs->name,
+2 -2
http-push.c
··· 369 369 ssize_t size; 370 370 git_zstream stream; 371 371 372 - unpacked = repo_read_object_file(the_repository, &request->obj->oid, 373 - &type, &len); 372 + unpacked = odb_read_object(the_repository->objects, &request->obj->oid, 373 + &type, &len); 374 374 hdrlen = format_object_header(hdr, sizeof(hdr), type, len); 375 375 376 376 /* Set it up */
+1 -1
mailmap.c
··· 196 196 if (repo_get_oid(the_repository, name, &oid) < 0) 197 197 return 0; 198 198 199 - buf = repo_read_object_file(the_repository, &oid, &type, &size); 199 + buf = odb_read_object(the_repository->objects, &oid, &type, &size); 200 200 if (!buf) 201 201 return error("unable to read mailmap object at %s", name); 202 202 if (type != OBJ_BLOB) {
+2 -2
match-trees.c
··· 63 63 enum object_type type; 64 64 unsigned long size; 65 65 66 - buffer = repo_read_object_file(r, hash, &type, &size); 66 + buffer = odb_read_object(r->objects, hash, &type, &size); 67 67 if (!buffer) 68 68 die("unable to read tree (%s)", oid_to_hex(hash)); 69 69 if (type != OBJ_TREE) ··· 199 199 if (*subpath) 200 200 subpath++; 201 201 202 - buf = repo_read_object_file(r, oid1, &type, &sz); 202 + buf = odb_read_object(r->objects, oid1, &type, &sz); 203 203 if (!buf) 204 204 die("cannot read tree %s", oid_to_hex(oid1)); 205 205 init_tree_desc(&desc, oid1, buf, sz);
+4 -4
merge-blobs.c
··· 12 12 unsigned long size; 13 13 enum object_type type; 14 14 15 - buf = repo_read_object_file(the_repository, &obj->object.oid, &type, 16 - &size); 15 + buf = odb_read_object(the_repository->objects, &obj->object.oid, 16 + &type, &size); 17 17 if (!buf) 18 18 return -1; 19 19 if (type != OBJ_BLOB) { ··· 79 79 return NULL; 80 80 if (!our) 81 81 our = their; 82 - return repo_read_object_file(the_repository, &our->object.oid, 83 - &type, size); 82 + return odb_read_object(the_repository->objects, &our->object.oid, 83 + &type, size); 84 84 } 85 85 86 86 if (fill_mmfile_blob(&f1, our) < 0)
+1 -1
merge-ort.c
··· 3629 3629 void *buf; 3630 3630 enum object_type type; 3631 3631 unsigned long size; 3632 - buf = repo_read_object_file(the_repository, oid, &type, &size); 3632 + buf = odb_read_object(the_repository->objects, oid, &type, &size); 3633 3633 if (!buf) { 3634 3634 path_msg(opt, ERROR_OBJECT_READ_FAILED, 0, 3635 3635 path, NULL, NULL, NULL,
+1 -1
notes-cache.c
··· 87 87 value_oid = get_note(&c->tree, key_oid); 88 88 if (!value_oid) 89 89 return NULL; 90 - value = repo_read_object_file(the_repository, value_oid, &type, &size); 90 + value = odb_read_object(the_repository->objects, value_oid, &type, &size); 91 91 92 92 *outsize = size; 93 93 return value;
+1 -1
notes-merge.c
··· 340 340 { 341 341 enum object_type type; 342 342 unsigned long size; 343 - void *buf = repo_read_object_file(the_repository, note, &type, &size); 343 + void *buf = odb_read_object(the_repository->objects, note, &type, &size); 344 344 345 345 if (!buf) 346 346 die("cannot read note %s for object %s",
+7 -6
notes.c
··· 816 816 817 817 /* read in both note blob objects */ 818 818 if (!is_null_oid(new_oid)) 819 - new_msg = repo_read_object_file(the_repository, new_oid, 820 - &new_type, &new_len); 819 + new_msg = odb_read_object(the_repository->objects, new_oid, 820 + &new_type, &new_len); 821 821 if (!new_msg || !new_len || new_type != OBJ_BLOB) { 822 822 free(new_msg); 823 823 return 0; 824 824 } 825 825 if (!is_null_oid(cur_oid)) 826 - cur_msg = repo_read_object_file(the_repository, cur_oid, 827 - &cur_type, &cur_len); 826 + cur_msg = odb_read_object(the_repository->objects, cur_oid, 827 + &cur_type, &cur_len); 828 828 if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) { 829 829 free(cur_msg); 830 830 free(new_msg); ··· 880 880 return 0; 881 881 882 882 /* read_sha1_file NUL-terminates */ 883 - data = repo_read_object_file(the_repository, oid, &t, &len); 883 + data = odb_read_object(the_repository->objects, oid, &t, &len); 884 884 if (t != OBJ_BLOB || !data || !len) { 885 885 free(data); 886 886 return t != OBJ_BLOB || !data; ··· 1290 1290 if (!oid) 1291 1291 return; 1292 1292 1293 - if (!(msg = repo_read_object_file(the_repository, oid, &type, &msglen)) || type != OBJ_BLOB) { 1293 + if (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) || 1294 + type != OBJ_BLOB) { 1294 1295 free(msg); 1295 1296 return; 1296 1297 }
+1 -1
object.c
··· 335 335 return &lookup_tree(r, oid)->object; 336 336 } 337 337 338 - buffer = repo_read_object_file(r, oid, &type, &size); 338 + buffer = odb_read_object(r->objects, oid, &type, &size); 339 339 if (buffer) { 340 340 if (!skip_hash && 341 341 check_object_signature(r, repl, buffer, size, type) < 0) {
+7 -12
odb.c
··· 30 30 31 31 /* 32 32 * This is meant to hold a *small* number of objects that you would 33 - * want repo_read_object_file() to be able to return, but yet you do not want 33 + * want odb_read_object() to be able to return, but yet you do not want 34 34 * to write them into the object store (e.g. a browse-only 35 35 * application). 36 36 */ ··· 887 887 return 0; 888 888 } 889 889 890 - /* 891 - * This function dies on corrupt objects; the callers who want to 892 - * deal with them should arrange to call odb_read_object_info_extended() and give 893 - * error messages themselves. 894 - */ 895 - void *repo_read_object_file(struct repository *r, 896 - const struct object_id *oid, 897 - enum object_type *type, 898 - unsigned long *size) 890 + void *odb_read_object(struct object_database *odb, 891 + const struct object_id *oid, 892 + enum object_type *type, 893 + unsigned long *size) 899 894 { 900 895 struct object_info oi = OBJECT_INFO_INIT; 901 896 unsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE; ··· 904 899 oi.typep = type; 905 900 oi.sizep = size; 906 901 oi.contentp = &data; 907 - if (odb_read_object_info_extended(r->objects, oid, &oi, flags)) 902 + if (odb_read_object_info_extended(odb, oid, &oi, flags)) 908 903 return NULL; 909 904 910 905 return data; ··· 926 921 int ref_length = -1; 927 922 const char *ref_type = NULL; 928 923 929 - buffer = repo_read_object_file(r, &actual_oid, &type, &isize); 924 + buffer = odb_read_object(r->objects, &actual_oid, &type, &isize); 930 925 if (!buffer) 931 926 return NULL; 932 927 if (type == required_type) {
+23 -6
odb.h
··· 140 140 141 141 /* 142 142 * This is meant to hold a *small* number of objects that you would 143 - * want repo_read_object_file() to be able to return, but yet you do not want 143 + * want odb_read_object() to be able to return, but yet you do not want 144 144 * to write them into the object store (e.g. a browse-only 145 145 * application). 146 146 */ ··· 260 260 void odb_add_to_alternates_memory(struct object_database *odb, 261 261 const char *dir); 262 262 263 - void *repo_read_object_file(struct repository *r, 264 - const struct object_id *oid, 265 - enum object_type *type, 266 - unsigned long *size); 263 + /* 264 + * Read an object from the database. Returns the object data and assigns object 265 + * type and size to the `type` and `size` pointers, if these pointers are 266 + * non-NULL. Returns a `NULL` pointer in case the object does not exist. 267 + * 268 + * This function dies on corrupt objects; the callers who want to deal with 269 + * them should arrange to call odb_read_object_info_extended() and give error 270 + * messages themselves. 271 + */ 272 + void *odb_read_object(struct object_database *odb, 273 + const struct object_id *oid, 274 + enum object_type *type, 275 + unsigned long *size); 267 276 268 277 /* 269 278 * Add an object file to the in-memory object store, without writing it ··· 371 380 372 381 /* 373 382 * Enabling the object read lock allows multiple threads to safely call the 374 - * following functions in parallel: repo_read_object_file(), 383 + * following functions in parallel: odb_read_object(), 375 384 * read_object_with_reference(), odb_read_object_info() and odb(). 376 385 * 377 386 * obj_read_lock() and obj_read_unlock() may also be used to protect other ··· 444 453 unsigned long *sizep) 445 454 { 446 455 return odb_read_object_info(r->objects, oid, sizep); 456 + } 457 + 458 + static inline void *repo_read_object_file(struct repository *r, 459 + const struct object_id *oid, 460 + enum object_type *type, 461 + unsigned long *size) 462 + { 463 + return odb_read_object(r->objects, oid, type, size); 447 464 } 448 465 449 466 #endif /* ODB_H */
+3 -3
read-cache.c
··· 254 254 if (strbuf_readlink(&sb, ce->name, expected_size)) 255 255 return -1; 256 256 257 - buffer = repo_read_object_file(the_repository, &ce->oid, &type, &size); 257 + buffer = odb_read_object(the_repository->objects, &ce->oid, &type, &size); 258 258 if (buffer) { 259 259 if (size == sb.len) 260 260 match = memcmp(buffer, sb.buf, size); ··· 3485 3485 } 3486 3486 if (pos < 0) 3487 3487 return NULL; 3488 - data = repo_read_object_file(the_repository, &istate->cache[pos]->oid, 3489 - &type, &sz); 3488 + data = odb_read_object(the_repository->objects, &istate->cache[pos]->oid, 3489 + &type, &sz); 3490 3490 if (!data || type != OBJ_BLOB) { 3491 3491 free(data); 3492 3492 return NULL;
+2 -2
reflog.c
··· 140 140 if (!tree->buffer) { 141 141 enum object_type type; 142 142 unsigned long size; 143 - void *data = repo_read_object_file(the_repository, oid, &type, 144 - &size); 143 + void *data = odb_read_object(the_repository->objects, oid, 144 + &type, &size); 145 145 if (!data) { 146 146 tree->object.flags |= INCOMPLETE; 147 147 return 0;
+2 -3
rerere.c
··· 1000 1000 break; 1001 1001 i = ce_stage(ce) - 1; 1002 1002 if (!mmfile[i].ptr) { 1003 - mmfile[i].ptr = repo_read_object_file(the_repository, 1004 - &ce->oid, &type, 1005 - &size); 1003 + mmfile[i].ptr = odb_read_object(the_repository->objects, 1004 + &ce->oid, &type, &size); 1006 1005 if (!mmfile[i].ptr) 1007 1006 die(_("unable to read %s"), 1008 1007 oid_to_hex(&ce->oid));
+2 -2
submodule-config.c
··· 743 743 if (submodule) 744 744 goto out; 745 745 746 - config = repo_read_object_file(the_repository, &oid, &type, 747 - &config_size); 746 + config = odb_read_object(the_repository->objects, &oid, 747 + &type, &config_size); 748 748 if (!config || type != OBJ_BLOB) 749 749 goto out; 750 750
+3 -3
tag.c
··· 60 60 repo_find_unique_abbrev(the_repository, oid, DEFAULT_ABBREV), 61 61 type_name(type)); 62 62 63 - buf = repo_read_object_file(the_repository, oid, &type, &size); 63 + buf = odb_read_object(the_repository->objects, oid, &type, &size); 64 64 if (!buf) 65 65 return error("%s: unable to read file.", 66 66 name_to_report ? ··· 222 222 223 223 if (item->object.parsed) 224 224 return 0; 225 - data = repo_read_object_file(the_repository, &item->object.oid, &type, 226 - &size); 225 + data = odb_read_object(the_repository->objects, &item->object.oid, 226 + &type, &size); 227 227 if (!data) 228 228 return error("Could not read %s", 229 229 oid_to_hex(&item->object.oid));
+3 -3
tree-walk.c
··· 795 795 */ 796 796 retval = DANGLING_SYMLINK; 797 797 798 - contents = repo_read_object_file(r, 799 - &current_tree_oid, &type, 800 - &link_len); 798 + contents = odb_read_object(r->objects, 799 + &current_tree_oid, &type, 800 + &link_len); 801 801 802 802 if (!contents) 803 803 goto done;
+2 -2
tree.c
··· 193 193 194 194 if (item->object.parsed) 195 195 return 0; 196 - buffer = repo_read_object_file(the_repository, &item->object.oid, 197 - &type, &size); 196 + buffer = odb_read_object(the_repository->objects, &item->object.oid, 197 + &type, &size); 198 198 if (!buffer) 199 199 return quiet_on_missing ? -1 : 200 200 error("Could not read %s",
+1 -1
xdiff-interface.c
··· 187 187 return; 188 188 } 189 189 190 - ptr->ptr = repo_read_object_file(the_repository, oid, &type, &size); 190 + ptr->ptr = odb_read_object(the_repository->objects, oid, &type, &size); 191 191 if (!ptr->ptr || type != OBJ_BLOB) 192 192 die("unable to read blob object %s", oid_to_hex(oid)); 193 193 ptr->size = size;