Git fork

Merge branch 'ps/object-store' into ps/object-file-wo-the-repository

* ps/object-store:
odb: rename `read_object_with_reference()`
odb: rename `pretend_object_file()`
odb: rename `has_object()`
odb: rename `repo_read_object_file()`
odb: rename `oid_object_info()`
odb: trivial refactorings to get rid of `the_repository`
odb: get rid of `the_repository` when handling submodule sources
odb: get rid of `the_repository` when handling the primary source
odb: get rid of `the_repository` in `for_each()` functions
odb: get rid of `the_repository` when handling alternates
odb: get rid of `the_repository` in `odb_mkstemp()`
odb: get rid of `the_repository` in `assert_oid_type()`
odb: get rid of `the_repository` in `find_odb()`
odb: introduce parent pointers
object-store: rename files to "odb.{c,h}"
object-store: rename `object_directory` to `odb_source`
object-store: rename `raw_object_store` to `object_database`

+1453 -1298
+2 -2
Documentation/user-manual.adoc
··· 4301 4301 4302 4302 ----------------------------------------------------------------------------- 4303 4303 case 0: 4304 - buf = read_object_with_reference(sha1, argv[1], &size, NULL); 4304 + buf = odb_read_object_peeled(r->objects, sha1, argv[1], &size, NULL); 4305 4305 ----------------------------------------------------------------------------- 4306 4306 4307 4307 This is how you read a blob (actually, not only a blob, but any type of 4308 - object). To know how the function `read_object_with_reference()` actually 4308 + object). To know how the function `odb_read_object_peeled()` actually 4309 4309 works, find the source code for it (something like `git grep 4310 4310 read_object_with | grep ":[a-z]"` in the Git repository), and read 4311 4311 the source.
+1 -1
Makefile
··· 1085 1085 LIB_OBJS += object-file-convert.o 1086 1086 LIB_OBJS += object-file.o 1087 1087 LIB_OBJS += object-name.o 1088 - LIB_OBJS += object-store.o 1089 1088 LIB_OBJS += object.o 1089 + LIB_OBJS += odb.o 1090 1090 LIB_OBJS += oid-array.o 1091 1091 LIB_OBJS += oidmap.o 1092 1092 LIB_OBJS += oidset.o
+7 -7
apply.c
··· 14 14 #include "abspath.h" 15 15 #include "base85.h" 16 16 #include "config.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 #include "delta.h" 19 19 #include "diff.h" 20 20 #include "dir.h" ··· 3204 3204 return 0; /* deletion patch */ 3205 3205 } 3206 3206 3207 - if (has_object(the_repository, &oid, 0)) { 3207 + if (odb_has_object(the_repository->objects, &oid, 0)) { 3208 3208 /* We already have the postimage */ 3209 3209 enum object_type type; 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-tar.c
··· 11 11 #include "hex.h" 12 12 #include "tar.h" 13 13 #include "archive.h" 14 - #include "object-store.h" 14 + #include "odb.h" 15 15 #include "strbuf.h" 16 16 #include "streaming.h" 17 17 #include "run-command.h"
+1 -1
archive-zip.c
··· 12 12 #include "hex.h" 13 13 #include "streaming.h" 14 14 #include "utf8.h" 15 - #include "object-store.h" 15 + #include "odb.h" 16 16 #include "strbuf.h" 17 17 #include "userdiff.h" 18 18 #include "write-or-die.h"
+3 -3
archive.c
··· 14 14 #include "pretty.h" 15 15 #include "setup.h" 16 16 #include "refs.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 #include "commit.h" 19 19 #include "tree.h" 20 20 #include "tree-walk.h" ··· 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; ··· 215 215 216 216 /* Stream it? */ 217 217 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 && 219 219 size > repo_settings_get_big_file_threshold(the_repository)) 220 220 return write_entry(args, oid, path.buf, path.len, mode, NULL, size); 221 221
+2 -2
attr.c
··· 22 22 #include "read-cache-ll.h" 23 23 #include "refs.h" 24 24 #include "revision.h" 25 - #include "object-store.h" 25 + #include "odb.h" 26 26 #include "setup.h" 27 27 #include "thread-utils.h" 28 28 #include "tree-walk.h" ··· 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;
+4 -4
bisect.c
··· 20 20 #include "commit-slab.h" 21 21 #include "commit-reach.h" 22 22 #include "object-name.h" 23 - #include "object-store.h" 23 + #include "odb.h" 24 24 #include "path.h" 25 25 #include "dir.h" 26 26 ··· 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
+11 -11
blame.c
··· 3 3 4 4 #include "git-compat-util.h" 5 5 #include "refs.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 #include "cache-tree.h" 8 8 #include "mergesort.h" 9 9 #include "commit.h" ··· 116 116 unsigned short mode; 117 117 118 118 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) 120 120 return; 121 121 } 122 122 ··· 277 277 convert_to_git(r->index, path, buf.buf, buf.len, &buf, 0); 278 278 origin->file.ptr = buf.buf; 279 279 origin->file.size = buf.len; 280 - pretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid); 280 + odb_pretend_object(the_repository->objects, buf.buf, buf.len, 281 + OBJ_BLOB, &origin->blob_oid); 281 282 282 283 /* 283 284 * Read the current index, replace the path entry with ··· 1041 1042 &o->blob_oid, 1, &file->ptr, &file_size)) 1042 1043 ; 1043 1044 else 1044 - file->ptr = repo_read_object_file(the_repository, 1045 - &o->blob_oid, &type, 1046 - &file_size); 1045 + file->ptr = odb_read_object(the_repository->objects, 1046 + &o->blob_oid, &type, 1047 + &file_size); 1047 1048 file->size = file_size; 1048 1049 1049 1050 if (!file->ptr) ··· 1245 1246 return 0; 1246 1247 if (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode)) 1247 1248 goto error_out; 1248 - if (oid_object_info(r, &origin->blob_oid, NULL) != OBJ_BLOB) 1249 + if (odb_read_object_info(r->objects, &origin->blob_oid, NULL) != OBJ_BLOB) 1249 1250 goto error_out; 1250 1251 return 0; 1251 1252 error_out: ··· 2869 2870 &sb->final_buf_size)) 2870 2871 ; 2871 2872 else 2872 - sb->final_buf = repo_read_object_file(the_repository, 2873 - &o->blob_oid, 2874 - &type, 2875 - &sb->final_buf_size); 2873 + sb->final_buf = odb_read_object(the_repository->objects, 2874 + &o->blob_oid, &type, 2875 + &sb->final_buf_size); 2876 2876 2877 2877 if (!sb->final_buf) 2878 2878 die(_("cannot read blob %s for path %s"),
+3 -3
builtin/backfill.c
··· 13 13 #include "tree.h" 14 14 #include "tree-walk.h" 15 15 #include "object.h" 16 - #include "object-store.h" 16 + #include "odb.h" 17 17 #include "oid-array.h" 18 18 #include "oidset.h" 19 19 #include "promisor-remote.h" ··· 67 67 return 0; 68 68 69 69 for (size_t i = 0; i < list->nr; i++) { 70 - if (!has_object(ctx->repo, &list->oid[i], 71 - OBJECT_INFO_FOR_PREFETCH)) 70 + if (!odb_has_object(ctx->repo->objects, &list->oid[i], 71 + OBJECT_INFO_FOR_PREFETCH)) 72 72 oid_array_append(&ctx->current_batch, &list->oid[i]); 73 73 } 74 74
+3 -3
builtin/blame.c
··· 28 28 #include "line-log.h" 29 29 #include "progress.h" 30 30 #include "object-name.h" 31 - #include "object-store.h" 31 + #include "odb.h" 32 32 #include "pager.h" 33 33 #include "blame.h" 34 34 #include "refs.h" ··· 837 837 838 838 if (repo_get_oid(the_repository, name, &oid)) 839 839 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); 841 841 } 842 842 843 843 static int peel_to_commit_oid(struct object_id *oid_ret, void *cbdata) ··· 848 848 oidcpy(&oid, oid_ret); 849 849 while (1) { 850 850 struct object *obj; 851 - int kind = oid_object_info(r, &oid, NULL); 851 + int kind = odb_read_object_info(r->objects, &oid, NULL); 852 852 if (kind == OBJ_COMMIT) { 853 853 oidcpy(oid_ret, &oid); 854 854 return 0;
+30 -32
builtin/cat-file.c
··· 24 24 #include "pack-bitmap.h" 25 25 #include "object-file.h" 26 26 #include "object-name.h" 27 - #include "object-store.h" 27 + #include "odb.h" 28 28 #include "replace-object.h" 29 29 #include "promisor-remote.h" 30 30 #include "mailmap.h" ··· 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); ··· 132 132 switch (opt) { 133 133 case 't': 134 134 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) 136 136 die("git cat-file: could not get object info"); 137 137 printf("%s\n", type_name(type)); 138 138 ret = 0; ··· 146 146 oi.contentp = (void**)&buf; 147 147 } 148 148 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) 150 150 die("git cat-file: could not get object info"); 151 151 152 152 if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) { ··· 160 160 goto cleanup; 161 161 162 162 case 'e': 163 - ret = !has_object(the_repository, &oid, 164 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR); 163 + ret = !odb_has_object(the_repository->objects, &oid, 164 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR); 165 165 goto cleanup; 166 166 167 167 case 'w': ··· 180 180 /* else fallthrough */ 181 181 182 182 case 'p': 183 - type = oid_object_info(the_repository, &oid, NULL); 183 + type = odb_read_object_info(the_repository->objects, &oid, NULL); 184 184 if (type < 0) 185 185 die("Not a valid object name %s", obj_name); 186 186 ··· 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 ··· 217 217 218 218 if (exp_type_id == OBJ_BLOB) { 219 219 struct object_id blob_oid; 220 - if (oid_object_info(the_repository, &oid, NULL) == OBJ_TAG) { 221 - char *buffer = repo_read_object_file(the_repository, 222 - &oid, 223 - &type, 224 - &size); 220 + if (odb_read_object_info(the_repository->objects, 221 + &oid, NULL) == OBJ_TAG) { 222 + char *buffer = odb_read_object(the_repository->objects, 223 + &oid, &type, &size); 225 224 const char *target; 226 225 227 226 if (!buffer) ··· 235 234 } else 236 235 oidcpy(&blob_oid, &oid); 237 236 238 - if (oid_object_info(the_repository, &blob_oid, NULL) == OBJ_BLOB) { 237 + if (odb_read_object_info(the_repository->objects, 238 + &blob_oid, NULL) == OBJ_BLOB) { 239 239 ret = stream_blob(&blob_oid); 240 240 goto cleanup; 241 241 } ··· 246 246 * fall-back to the usual case. 247 247 */ 248 248 } 249 - buf = read_object_with_reference(the_repository, &oid, 250 - exp_type_id, &size, NULL); 249 + buf = odb_read_object_peeled(the_repository->objects, &oid, 250 + exp_type_id, &size, NULL); 251 251 252 252 if (use_mailmap) { 253 253 size_t s = size; ··· 295 295 296 296 /* 297 297 * After a mark_query run, this object_info is set up to be 298 - * passed to oid_object_info_extended. It will point to the data 298 + * passed to odb_read_object_info_extended. It will point to the data 299 299 * elements above, so you can retrieve the response from there. 300 300 */ 301 301 struct object_info info; ··· 406 406 if (!textconv_object(the_repository, 407 407 data->rest, 0100644, oid, 408 408 1, &contents, &size)) 409 - contents = repo_read_object_file(the_repository, 410 - oid, 411 - &type, 412 - &size); 409 + contents = odb_read_object(the_repository->objects, 410 + oid, &type, &size); 413 411 if (!contents) 414 412 die("could not convert '%s' %s", 415 413 oid_to_hex(oid), data->rest); ··· 426 424 unsigned long size; 427 425 void *contents; 428 426 429 - contents = repo_read_object_file(the_repository, oid, &type, 430 - &size); 427 + contents = odb_read_object(the_repository->objects, oid, 428 + &type, &size); 431 429 if (!contents) 432 430 die("object %s disappeared", oid_to_hex(oid)); 433 431 ··· 489 487 data->info.sizep = &data->size; 490 488 491 489 if (pack) 492 - ret = packed_object_info(the_repository, pack, offset, 493 - &data->info); 490 + ret = packed_object_info(the_repository, pack, 491 + offset, &data->info); 494 492 else 495 - ret = oid_object_info_extended(the_repository, 496 - &data->oid, &data->info, 497 - OBJECT_INFO_LOOKUP_REPLACE); 493 + ret = odb_read_object_info_extended(the_repository->objects, 494 + &data->oid, &data->info, 495 + OBJECT_INFO_LOOKUP_REPLACE); 498 496 if (ret < 0) { 499 497 if (data->mode == S_IFGITLINK) 500 498 report_object_status(opt, oid_to_hex(&data->oid), &data->oid, "submodule"); ··· 539 537 size_t s = data->size; 540 538 char *buf = NULL; 541 539 542 - buf = repo_read_object_file(the_repository, &data->oid, &data->type, 543 - &data->size); 540 + buf = odb_read_object(the_repository->objects, &data->oid, 541 + &data->type, &data->size); 544 542 if (!buf) 545 543 die(_("unable to read %s"), oid_to_hex(&data->oid)); 546 544 buf = replace_idents_using_mailmap(buf, &s); ··· 881 879 882 880 /* 883 881 * 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 882 + * object_info to be handed to odb_read_object_info_extended for each 885 883 * object. 886 884 */ 887 885 data.mark_query = 1;
+1 -1
builtin/checkout.c
··· 20 20 #include "merge-ort-wrappers.h" 21 21 #include "object-file.h" 22 22 #include "object-name.h" 23 - #include "object-store.h" 23 + #include "odb.h" 24 24 #include "parse-options.h" 25 25 #include "path.h" 26 26 #include "preload-index.h"
+8 -6
builtin/clone.c
··· 25 25 #include "refs.h" 26 26 #include "refspec.h" 27 27 #include "object-file.h" 28 - #include "object-store.h" 28 + #include "odb.h" 29 29 #include "tree.h" 30 30 #include "tree-walk.h" 31 31 #include "unpack-trees.h" ··· 171 171 } else { 172 172 struct strbuf sb = STRBUF_INIT; 173 173 strbuf_addf(&sb, "%s/objects", ref_git); 174 - add_to_alternates_file(sb.buf); 174 + odb_add_to_alternates_file(the_repository->objects, sb.buf); 175 175 strbuf_release(&sb); 176 176 } 177 177 ··· 212 212 if (!line.len || line.buf[0] == '#') 213 213 continue; 214 214 if (is_absolute_path(line.buf)) { 215 - add_to_alternates_file(line.buf); 215 + odb_add_to_alternates_file(the_repository->objects, 216 + line.buf); 216 217 continue; 217 218 } 218 219 abs_path = mkpathdup("%s/objects/%s", src_repo, line.buf); 219 220 if (!normalize_path_copy(abs_path, abs_path)) 220 - add_to_alternates_file(abs_path); 221 + odb_add_to_alternates_file(the_repository->objects, 222 + abs_path); 221 223 else 222 224 warning("skipping invalid relative alternate: %s/%s", 223 225 src_repo, line.buf); ··· 352 354 struct strbuf alt = STRBUF_INIT; 353 355 get_common_dir(&alt, src_repo); 354 356 strbuf_addstr(&alt, "/objects"); 355 - add_to_alternates_file(alt.buf); 357 + odb_add_to_alternates_file(the_repository->objects, alt.buf); 356 358 strbuf_release(&alt); 357 359 } else { 358 360 struct strbuf src = STRBUF_INIT; ··· 504 506 continue; 505 507 if (ends_with(ref->name, "^{}")) 506 508 continue; 507 - if (!has_object(the_repository, &ref->old_oid, 0)) 509 + if (!odb_has_object(the_repository->objects, &ref->old_oid, 0)) 508 510 continue; 509 511 refs_update_ref(get_main_ref_store(the_repository), msg, 510 512 ref->name, &ref->old_oid, NULL, 0,
+10 -10
builtin/commit-graph.c
··· 6 6 #include "hex.h" 7 7 #include "parse-options.h" 8 8 #include "commit-graph.h" 9 - #include "object-store.h" 9 + #include "odb.h" 10 10 #include "progress.h" 11 11 #include "replace-object.h" 12 12 #include "strbuf.h" ··· 66 66 struct repository *repo UNUSED) 67 67 { 68 68 struct commit_graph *graph = NULL; 69 - struct object_directory *odb = NULL; 69 + struct odb_source *source = NULL; 70 70 char *graph_name; 71 71 char *chain_name; 72 72 enum { OPENED_NONE, OPENED_GRAPH, OPENED_CHAIN } opened = OPENED_NONE; ··· 101 101 if (opts.progress) 102 102 flags |= COMMIT_GRAPH_WRITE_PROGRESS; 103 103 104 - odb = find_odb(the_repository, opts.obj_dir); 105 - graph_name = get_commit_graph_filename(odb); 106 - chain_name = get_commit_graph_chain_filename(odb); 104 + source = odb_find_source(the_repository->objects, opts.obj_dir); 105 + graph_name = get_commit_graph_filename(source); 106 + chain_name = get_commit_graph_chain_filename(source); 107 107 if (open_commit_graph(graph_name, &fd, &st)) 108 108 opened = OPENED_GRAPH; 109 109 else if (errno != ENOENT) ··· 120 120 if (opened == OPENED_NONE) 121 121 return 0; 122 122 else if (opened == OPENED_GRAPH) 123 - graph = load_commit_graph_one_fd_st(the_repository, fd, &st, odb); 123 + graph = load_commit_graph_one_fd_st(the_repository, fd, &st, source); 124 124 else 125 125 graph = load_commit_graph_chain_fd_st(the_repository, fd, &st, 126 126 &incomplete_chain); ··· 221 221 struct string_list pack_indexes = STRING_LIST_INIT_DUP; 222 222 struct strbuf buf = STRBUF_INIT; 223 223 struct oidset commits = OIDSET_INIT; 224 - struct object_directory *odb = NULL; 224 + struct odb_source *source = NULL; 225 225 int result = 0; 226 226 enum commit_graph_write_flags flags = 0; 227 227 struct progress *progress = NULL; ··· 289 289 git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0)) 290 290 flags |= COMMIT_GRAPH_WRITE_BLOOM_FILTERS; 291 291 292 - odb = find_odb(the_repository, opts.obj_dir); 292 + source = odb_find_source(the_repository->objects, opts.obj_dir); 293 293 294 294 if (opts.reachable) { 295 - if (write_commit_graph_reachable(odb, flags, &write_opts)) 295 + if (write_commit_graph_reachable(source, flags, &write_opts)) 296 296 result = 1; 297 297 goto cleanup; 298 298 } ··· 319 319 stop_progress(&progress); 320 320 } 321 321 322 - if (write_commit_graph(odb, 322 + if (write_commit_graph(source, 323 323 opts.stdin_packs ? &pack_indexes : NULL, 324 324 opts.stdin_commits ? &commits : NULL, 325 325 flags,
+2 -2
builtin/commit-tree.c
··· 9 9 #include "gettext.h" 10 10 #include "hex.h" 11 11 #include "object-name.h" 12 - #include "object-store.h" 12 + #include "odb.h" 13 13 14 14 #include "commit.h" 15 15 #include "parse-options.h" ··· 48 48 if (repo_get_oid_commit(the_repository, arg, &oid)) 49 49 die(_("not a valid object name %s"), arg); 50 50 51 - assert_oid_type(&oid, OBJ_COMMIT); 51 + odb_assert_oid_type(the_repository->objects, &oid, OBJ_COMMIT); 52 52 new_parent(lookup_commit(the_repository, &oid), parents); 53 53 return 0; 54 54 }
+3 -3
builtin/count-objects.c
··· 80 80 return 0; 81 81 } 82 82 83 - static int print_alternate(struct object_directory *odb, void *data UNUSED) 83 + static int print_alternate(struct odb_source *alternate, void *data UNUSED) 84 84 { 85 85 printf("alternate: "); 86 - quote_c_style(odb->path, NULL, stdout, 0); 86 + quote_c_style(alternate->path, NULL, stdout, 0); 87 87 putchar('\n'); 88 88 return 0; 89 89 } ··· 159 159 printf("prune-packable: %lu\n", packed_loose); 160 160 printf("garbage: %lu\n", garbage); 161 161 printf("size-garbage: %s\n", garbage_buf.buf); 162 - foreach_alt_odb(print_alternate, NULL); 162 + odb_for_each_alternate(the_repository->objects, print_alternate, NULL); 163 163 strbuf_release(&loose_buf); 164 164 strbuf_release(&pack_buf); 165 165 strbuf_release(&garbage_buf);
+3 -2
builtin/describe.c
··· 19 19 #include "setup.h" 20 20 #include "strvec.h" 21 21 #include "run-command.h" 22 - #include "object-store.h" 22 + #include "odb.h" 23 23 #include "list-objects.h" 24 24 #include "commit-slab.h" 25 25 #include "wildmatch.h" ··· 552 552 553 553 if (cmit) 554 554 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) 556 557 describe_blob(oid, &sb); 557 558 else 558 559 die(_("%s is neither a commit nor blob"), arg);
+2 -2
builtin/difftool.c
··· 30 30 #include "strbuf.h" 31 31 #include "lockfile.h" 32 32 #include "object-file.h" 33 - #include "object-store.h" 33 + #include "odb.h" 34 34 #include "dir.h" 35 35 #include "entry.h" 36 36 #include "setup.h" ··· 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);
+5 -5
builtin/fast-export.c
··· 14 14 #include "refs.h" 15 15 #include "refspec.h" 16 16 #include "object-file.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 #include "commit.h" 19 19 #include "object.h" 20 20 #include "tag.h" ··· 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); ··· 1200 1200 if (last_idnum < mark) 1201 1201 last_idnum = mark; 1202 1202 1203 - type = oid_object_info(the_repository, &oid, NULL); 1203 + type = odb_read_object_info(the_repository->objects, &oid, NULL); 1204 1204 if (type < 0) 1205 1205 die("object not found: %s", oid_to_hex(&oid)); 1206 1206
+24 -25
builtin/fast-import.c
··· 24 24 #include "packfile.h" 25 25 #include "object-file.h" 26 26 #include "object-name.h" 27 - #include "object-store.h" 27 + #include "odb.h" 28 28 #include "mem-pool.h" 29 29 #include "commit-reach.h" 30 30 #include "khash.h" ··· 763 763 struct packed_git *p; 764 764 int pack_fd; 765 765 766 - pack_fd = odb_mkstemp(&tmp_file, "pack/tmp_pack_XXXXXX"); 766 + pack_fd = odb_mkstemp(the_repository->objects, &tmp_file, 767 + "pack/tmp_pack_XXXXXX"); 767 768 FLEX_ALLOC_STR(p, pack_name, tmp_file.buf); 768 769 strbuf_release(&tmp_file); 769 770 ··· 1264 1265 die("Can't load tree %s", oid_to_hex(oid)); 1265 1266 } else { 1266 1267 enum object_type type; 1267 - buf = repo_read_object_file(the_repository, oid, &type, &size); 1268 + buf = odb_read_object(the_repository->objects, oid, &type, &size); 1268 1269 if (!buf || type != OBJ_TREE) 1269 1270 die("Can't load tree %s", oid_to_hex(oid)); 1270 1271 } ··· 1755 1756 struct object_entry *e; 1756 1757 e = find_object(oid); 1757 1758 if (!e) { 1758 - enum object_type type = oid_object_info(the_repository, 1759 - oid, NULL); 1759 + enum object_type type = odb_read_object_info(the_repository->objects, 1760 + oid, NULL); 1760 1761 if (type < 0) 1761 1762 die("object not found: %s", oid_to_hex(oid)); 1762 1763 e = insert_object(oid); ··· 2415 2416 enum object_type expected = S_ISDIR(mode) ? 2416 2417 OBJ_TREE: OBJ_BLOB; 2417 2418 enum object_type type = oe ? oe->type : 2418 - oid_object_info(the_repository, &oid, 2419 - NULL); 2419 + odb_read_object_info(the_repository->objects, 2420 + &oid, NULL); 2420 2421 if (type < 0) 2421 2422 die("%s not found: %s", 2422 2423 S_ISDIR(mode) ? "Tree" : "Blob", ··· 2534 2535 oidcpy(&commit_oid, &commit_oe->idx.oid); 2535 2536 } else if (!repo_get_oid(the_repository, p, &commit_oid)) { 2536 2537 unsigned long size; 2537 - char *buf = read_object_with_reference(the_repository, 2538 - &commit_oid, 2539 - OBJ_COMMIT, &size, 2540 - &commit_oid); 2538 + char *buf = odb_read_object_peeled(the_repository->objects, 2539 + &commit_oid, OBJ_COMMIT, &size, 2540 + &commit_oid); 2541 2541 if (!buf || size < the_hash_algo->hexsz + 6) 2542 2542 die("Not a valid commit: %s", p); 2543 2543 free(buf); ··· 2552 2552 die("Not a blob (actually a %s): %s", 2553 2553 type_name(oe->type), command_buf.buf); 2554 2554 } else if (!is_null_oid(&oid)) { 2555 - enum object_type type = oid_object_info(the_repository, &oid, 2555 + enum object_type type = odb_read_object_info(the_repository->objects, &oid, 2556 2556 NULL); 2557 2557 if (type < 0) 2558 2558 die("Blob not found: %s", command_buf.buf); ··· 2603 2603 unsigned long size; 2604 2604 char *buf; 2605 2605 2606 - buf = read_object_with_reference(the_repository, 2607 - &b->oid, OBJ_COMMIT, &size, 2608 - &b->oid); 2606 + buf = odb_read_object_peeled(the_repository->objects, &b->oid, 2607 + OBJ_COMMIT, &size, &b->oid); 2609 2608 parse_from_commit(b, buf, size); 2610 2609 free(buf); 2611 2610 } ··· 2698 2697 oidcpy(&n->oid, &oe->idx.oid); 2699 2698 } else if (!repo_get_oid(the_repository, from, &n->oid)) { 2700 2699 unsigned long size; 2701 - char *buf = read_object_with_reference(the_repository, 2702 - &n->oid, 2703 - OBJ_COMMIT, 2704 - &size, &n->oid); 2700 + char *buf = odb_read_object_peeled(the_repository->objects, 2701 + &n->oid, OBJ_COMMIT, 2702 + &size, &n->oid); 2705 2703 if (!buf || size < the_hash_algo->hexsz + 6) 2706 2704 die("Not a valid commit: %s", from); 2707 2705 free(buf); ··· 2894 2892 } else if (!repo_get_oid(the_repository, from, &oid)) { 2895 2893 struct object_entry *oe = find_object(&oid); 2896 2894 if (!oe) { 2897 - type = oid_object_info(the_repository, &oid, NULL); 2895 + type = odb_read_object_info(the_repository->objects, 2896 + &oid, NULL); 2898 2897 if (type < 0) 2899 2898 die("Not a valid object: %s", from); 2900 2899 } else ··· 3000 2999 char *buf; 3001 3000 3002 3001 if (!oe || oe->pack_id == MAX_PACK_ID) { 3003 - buf = repo_read_object_file(the_repository, oid, &type, &size); 3002 + buf = odb_read_object(the_repository->objects, oid, &type, &size); 3004 3003 } else { 3005 3004 type = oe->type; 3006 3005 buf = gfi_unpack_entry(oe, &size); ··· 3084 3083 const unsigned hexsz = the_hash_algo->hexsz; 3085 3084 3086 3085 if (!oe) { 3087 - enum object_type type = oid_object_info(the_repository, oid, 3088 - NULL); 3086 + enum object_type type = odb_read_object_info(the_repository->objects, 3087 + oid, NULL); 3089 3088 if (type < 0) 3090 3089 die("object not found: %s", oid_to_hex(oid)); 3091 3090 /* cache it! */ ··· 3108 3107 buf = gfi_unpack_entry(oe, &size); 3109 3108 } else { 3110 3109 enum object_type unused; 3111 - buf = repo_read_object_file(the_repository, oid, &unused, 3112 - &size); 3110 + buf = odb_read_object(the_repository->objects, oid, 3111 + &unused, &size); 3113 3112 } 3114 3113 if (!buf) 3115 3114 die("Can't load object %s", oid_to_hex(oid));
+11 -10
builtin/fetch.c
··· 14 14 #include "refs.h" 15 15 #include "refspec.h" 16 16 #include "object-name.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 #include "oidset.h" 19 19 #include "oid-array.h" 20 20 #include "commit.h" ··· 366 366 */ 367 367 if (ends_with(ref->name, "^{}")) { 368 368 if (item && 369 - !has_object(the_repository, &ref->old_oid, 0) && 369 + !odb_has_object(the_repository->objects, &ref->old_oid, 0) && 370 370 !oidset_contains(&fetch_oids, &ref->old_oid) && 371 - !has_object(the_repository, &item->oid, 0) && 371 + !odb_has_object(the_repository->objects, &item->oid, 0) && 372 372 !oidset_contains(&fetch_oids, &item->oid)) 373 373 clear_item(item); 374 374 item = NULL; ··· 382 382 * fetch. 383 383 */ 384 384 if (item && 385 - !has_object(the_repository, &item->oid, 0) && 385 + !odb_has_object(the_repository->objects, &item->oid, 0) && 386 386 !oidset_contains(&fetch_oids, &item->oid)) 387 387 clear_item(item); 388 388 ··· 403 403 * checked to see if it needs fetching. 404 404 */ 405 405 if (item && 406 - !has_object(the_repository, &item->oid, 0) && 406 + !odb_has_object(the_repository->objects, &item->oid, 0) && 407 407 !oidset_contains(&fetch_oids, &item->oid)) 408 408 clear_item(item); 409 409 ··· 873 873 struct commit *current = NULL, *updated; 874 874 int fast_forward = 0; 875 875 876 - if (!has_object(the_repository, &ref->new_oid, 877 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 876 + if (!odb_has_object(the_repository->objects, &ref->new_oid, 877 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 878 878 die(_("object %s not found"), oid_to_hex(&ref->new_oid)); 879 879 880 880 if (oideq(&ref->old_oid, &ref->new_oid)) { ··· 1287 1287 * we need all direct targets to exist. 1288 1288 */ 1289 1289 for (r = rm; r; r = r->next) { 1290 - if (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED)) 1290 + if (!odb_has_object(the_repository->objects, &r->old_oid, 1291 + HAS_OBJECT_RECHECK_PACKED)) 1291 1292 return -1; 1292 1293 } 1293 1294 ··· 1441 1442 struct object_id oid; 1442 1443 if (repo_get_oid(the_repository, s, &oid)) 1443 1444 die(_("%s is not a valid object"), s); 1444 - if (!has_object(the_repository, &oid, 0)) 1445 + if (!odb_has_object(the_repository->objects, &oid, 0)) 1445 1446 die(_("the object %s does not exist"), s); 1446 1447 oid_array_append(oids, &oid); 1447 1448 continue; ··· 2672 2673 commit_graph_flags |= COMMIT_GRAPH_WRITE_PROGRESS; 2673 2674 2674 2675 trace2_region_enter("fetch", "write-commit-graph", the_repository); 2675 - write_commit_graph_reachable(the_repository->objects->odb, 2676 + write_commit_graph_reachable(the_repository->objects->sources, 2676 2677 commit_graph_flags, 2677 2678 NULL); 2678 2679 trace2_region_leave("fetch", "write-commit-graph", the_repository);
+16 -15
builtin/fsck.c
··· 17 17 #include "packfile.h" 18 18 #include "object-file.h" 19 19 #include "object-name.h" 20 - #include "object-store.h" 20 + #include "odb.h" 21 21 #include "path.h" 22 22 #include "read-cache-ll.h" 23 23 #include "replace-object.h" ··· 71 71 const char *ret; 72 72 73 73 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); 75 76 76 77 ret = type_name(type); 77 78 if (!ret) ··· 160 161 return 0; 161 162 162 163 if (!(obj->flags & HAS_OBJ)) { 163 - if (parent && !has_object(the_repository, &obj->oid, 1)) { 164 + if (parent && !odb_has_object(the_repository->objects, &obj->oid, 1)) { 164 165 printf_ln(_("broken link from %7s %s\n" 165 166 " to %7s %s"), 166 167 printable_type(&parent->oid, parent->type), ··· 232 233 * (and we want to avoid parsing blobs). 233 234 */ 234 235 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); 237 238 if (type > 0) 238 239 object_as_type(obj, type, 0); 239 240 } ··· 956 957 struct repository *repo UNUSED) 957 958 { 958 959 int i; 959 - struct object_directory *odb; 960 + struct odb_source *source; 960 961 961 962 /* fsck knows how to handle missing promisor objects */ 962 963 fetch_if_missing = 0; ··· 997 998 for_each_packed_object(the_repository, 998 999 mark_packed_for_connectivity, NULL, 0); 999 1000 } else { 1000 - prepare_alt_odb(the_repository); 1001 - for (odb = the_repository->objects->odb; odb; odb = odb->next) 1002 - fsck_object_dir(odb->path); 1001 + odb_prepare_alternates(the_repository->objects); 1002 + for (source = the_repository->objects->sources; source; source = source->next) 1003 + fsck_object_dir(source->path); 1003 1004 1004 1005 if (check_full) { 1005 1006 struct packed_git *p; ··· 1108 1109 if (the_repository->settings.core_commit_graph) { 1109 1110 struct child_process commit_graph_verify = CHILD_PROCESS_INIT; 1110 1111 1111 - prepare_alt_odb(the_repository); 1112 - for (odb = the_repository->objects->odb; odb; odb = odb->next) { 1112 + odb_prepare_alternates(the_repository->objects); 1113 + for (source = the_repository->objects->sources; source; source = source->next) { 1113 1114 child_process_init(&commit_graph_verify); 1114 1115 commit_graph_verify.git_cmd = 1; 1115 1116 strvec_pushl(&commit_graph_verify.args, "commit-graph", 1116 - "verify", "--object-dir", odb->path, NULL); 1117 + "verify", "--object-dir", source->path, NULL); 1117 1118 if (show_progress) 1118 1119 strvec_push(&commit_graph_verify.args, "--progress"); 1119 1120 else ··· 1126 1127 if (the_repository->settings.core_multi_pack_index) { 1127 1128 struct child_process midx_verify = CHILD_PROCESS_INIT; 1128 1129 1129 - prepare_alt_odb(the_repository); 1130 - for (odb = the_repository->objects->odb; odb; odb = odb->next) { 1130 + odb_prepare_alternates(the_repository->objects); 1131 + for (source = the_repository->objects->sources; source; source = source->next) { 1131 1132 child_process_init(&midx_verify); 1132 1133 midx_verify.git_cmd = 1; 1133 1134 strvec_pushl(&midx_verify.args, "multi-pack-index", 1134 - "verify", "--object-dir", odb->path, NULL); 1135 + "verify", "--object-dir", source->path, NULL); 1135 1136 if (show_progress) 1136 1137 strvec_push(&midx_verify.args, "--progress"); 1137 1138 else
+8 -8
builtin/gc.c
··· 1040 1040 } 1041 1041 1042 1042 if (the_repository->settings.gc_write_commit_graph == 1) 1043 - write_commit_graph_reachable(the_repository->objects->odb, 1043 + write_commit_graph_reachable(the_repository->objects->sources, 1044 1044 !opts.quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0, 1045 1045 NULL); 1046 1046 ··· 1103 1103 1104 1104 if (!peel_iterated_oid(the_repository, oid, &peeled)) 1105 1105 oid = &peeled; 1106 - if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT) 1106 + if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT) 1107 1107 return 0; 1108 1108 1109 1109 commit = lookup_commit(the_repository, oid); ··· 1301 1301 if (loose_object_auto_limit < 0) 1302 1302 return 1; 1303 1303 1304 - return for_each_loose_file_in_objdir(the_repository->objects->odb->path, 1304 + return for_each_loose_file_in_objdir(the_repository->objects->sources->path, 1305 1305 loose_object_count, 1306 1306 NULL, NULL, &count); 1307 1307 } ··· 1336 1336 * Do not start pack-objects process 1337 1337 * if there are no loose objects. 1338 1338 */ 1339 - if (!for_each_loose_file_in_objdir(r->objects->odb->path, 1339 + if (!for_each_loose_file_in_objdir(r->objects->sources->path, 1340 1340 bail_on_loose, 1341 1341 NULL, NULL, NULL)) 1342 1342 return 0; ··· 1348 1348 strvec_push(&pack_proc.args, "--quiet"); 1349 1349 else 1350 1350 strvec_push(&pack_proc.args, "--no-quiet"); 1351 - strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->odb->path); 1351 + strvec_pushf(&pack_proc.args, "%s/pack/loose", r->objects->sources->path); 1352 1352 1353 1353 pack_proc.in = -1; 1354 1354 ··· 1376 1376 else if (data.batch_size > 0) 1377 1377 data.batch_size--; /* Decrease for equality on limit. */ 1378 1378 1379 - for_each_loose_file_in_objdir(r->objects->odb->path, 1379 + for_each_loose_file_in_objdir(r->objects->sources->path, 1380 1380 write_loose_object_to_stdin, 1381 1381 NULL, 1382 1382 NULL, ··· 1654 1654 int result = 0; 1655 1655 struct lock_file lk; 1656 1656 struct repository *r = the_repository; 1657 - char *lock_path = xstrfmt("%s/maintenance", r->objects->odb->path); 1657 + char *lock_path = xstrfmt("%s/maintenance", r->objects->sources->path); 1658 1658 1659 1659 if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) { 1660 1660 /* ··· 3151 3151 unsigned int i; 3152 3152 int result = 0; 3153 3153 struct lock_file lk; 3154 - char *lock_path = xstrfmt("%s/schedule", the_repository->objects->odb->path); 3154 + char *lock_path = xstrfmt("%s/schedule", the_repository->objects->sources->path); 3155 3155 3156 3156 if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) { 3157 3157 if (errno == EEXIST)
+12 -14
builtin/grep.c
··· 26 26 #include "submodule-config.h" 27 27 #include "object-file.h" 28 28 #include "object-name.h" 29 - #include "object-store.h" 29 + #include "odb.h" 30 30 #include "packfile.h" 31 31 #include "pager.h" 32 32 #include "path.h" ··· 462 462 463 463 /* 464 464 * NEEDSWORK: repo_read_gitmodules() might call 465 - * add_to_alternates_memory() via config_from_gitmodules(). This 465 + * odb_add_to_alternates_memory() via config_from_gitmodules(). This 466 466 * operation causes a race condition with concurrent object readings 467 467 * performed by the worker threads. That's why we need obj_read_lock() 468 468 * here. It should be removed once it's no longer necessary to add the ··· 505 505 * lazily registered as alternates when needed (and except in an 506 506 * unexpected code interaction, it won't be needed). 507 507 */ 508 - add_submodule_odb_by_path(subrepo->objects->odb->path); 508 + odb_add_submodule_source_by_path(the_repository->objects, 509 + subrepo->objects->sources->path); 509 510 obj_read_unlock(); 510 511 511 512 memcpy(&subopt, opt, sizeof(subopt)); ··· 519 520 struct strbuf base = STRBUF_INIT; 520 521 521 522 obj_read_lock(); 522 - object_type = oid_object_info(subrepo, oid, NULL); 523 + object_type = odb_read_object_info(subrepo->objects, oid, NULL); 523 524 obj_read_unlock(); 524 - data = read_object_with_reference(subrepo, 525 - oid, OBJ_TREE, 526 - &size, NULL); 525 + data = odb_read_object_peeled(subrepo->objects, oid, OBJ_TREE, &size, NULL); 527 526 if (!data) 528 527 die(_("unable to read tree (%s)"), oid_to_hex(oid)); 529 528 ··· 572 571 void *data; 573 572 unsigned long size; 574 573 575 - data = repo_read_object_file(the_repository, &ce->oid, 576 - &type, &size); 574 + data = odb_read_object(the_repository->objects, &ce->oid, 575 + &type, &size); 577 576 if (!data) 578 577 die(_("unable to read tree %s"), oid_to_hex(&ce->oid)); 579 578 init_tree_desc(&tree, &ce->oid, data, size); ··· 665 664 void *data; 666 665 unsigned long size; 667 666 668 - data = repo_read_object_file(the_repository, 669 - &entry.oid, &type, &size); 667 + data = odb_read_object(the_repository->objects, 668 + &entry.oid, &type, &size); 670 669 if (!data) 671 670 die(_("unable to read tree (%s)"), 672 671 oid_to_hex(&entry.oid)); ··· 704 703 struct strbuf base; 705 704 int hit, len; 706 705 707 - data = read_object_with_reference(opt->repo, 708 - &obj->oid, OBJ_TREE, 709 - &size, NULL); 706 + data = odb_read_object_peeled(opt->repo->objects, &obj->oid, 707 + OBJ_TREE, &size, NULL); 710 708 if (!data) 711 709 die(_("unable to read tree (%s)"), oid_to_hex(&obj->oid)); 712 710
+1 -1
builtin/hash-object.c
··· 11 11 #include "gettext.h" 12 12 #include "hex.h" 13 13 #include "object-file.h" 14 - #include "object-store.h" 14 + #include "odb.h" 15 15 #include "blob.h" 16 16 #include "quote.h" 17 17 #include "parse-options.h"
+15 -14
builtin/index-pack.c
··· 21 21 #include "packfile.h" 22 22 #include "pack-revindex.h" 23 23 #include "object-file.h" 24 - #include "object-store.h" 24 + #include "odb.h" 25 25 #include "oid-array.h" 26 26 #include "oidset.h" 27 27 #include "path.h" ··· 260 260 261 261 if (!(obj->flags & FLAG_CHECKED)) { 262 262 unsigned long size; 263 - int type = oid_object_info(the_repository, &obj->oid, &size); 263 + int type = odb_read_object_info(the_repository->objects, 264 + &obj->oid, &size); 264 265 if (type <= 0) 265 266 die(_("did not receive expected object %s"), 266 267 oid_to_hex(&obj->oid)); ··· 362 363 input_fd = 0; 363 364 if (!pack_name) { 364 365 struct strbuf tmp_file = STRBUF_INIT; 365 - output_fd = odb_mkstemp(&tmp_file, 366 + output_fd = odb_mkstemp(the_repository->objects, &tmp_file, 366 367 "pack/tmp_pack_XXXXXX"); 367 368 pack_name = strbuf_detach(&tmp_file, NULL); 368 369 } else { ··· 892 893 893 894 if (startup_info->have_repository) { 894 895 read_lock(); 895 - collision_test_needed = has_object(the_repository, oid, 896 - HAS_OBJECT_FETCH_PROMISOR); 896 + collision_test_needed = odb_has_object(the_repository->objects, oid, 897 + HAS_OBJECT_FETCH_PROMISOR); 897 898 read_unlock(); 898 899 } 899 900 ··· 908 909 enum object_type has_type; 909 910 unsigned long has_size; 910 911 read_lock(); 911 - has_type = oid_object_info(the_repository, oid, &has_size); 912 + has_type = odb_read_object_info(the_repository->objects, oid, &has_size); 912 913 if (has_type < 0) 913 914 die(_("cannot read existing object info %s"), oid_to_hex(oid)); 914 915 if (has_type != type || has_size != size) 915 916 die(_("SHA1 COLLISION FOUND WITH %s !"), oid_to_hex(oid)); 916 - has_data = repo_read_object_file(the_repository, oid, 917 - &has_type, &has_size); 917 + has_data = odb_read_object(the_repository->objects, oid, 918 + &has_type, &has_size); 918 919 read_unlock(); 919 920 if (!data) 920 921 data = new_data = get_data_from_pack(obj_entry); ··· 1501 1502 struct oid_array to_fetch = OID_ARRAY_INIT; 1502 1503 for (i = 0; i < nr_ref_deltas; i++) { 1503 1504 struct ref_delta_entry *d = sorted_by_pos[i]; 1504 - if (!oid_object_info_extended(the_repository, &d->oid, 1505 - NULL, 1506 - OBJECT_INFO_FOR_PREFETCH)) 1505 + if (!odb_read_object_info_extended(the_repository->objects, 1506 + &d->oid, NULL, 1507 + OBJECT_INFO_FOR_PREFETCH)) 1507 1508 continue; 1508 1509 oid_array_append(&to_fetch, &d->oid); 1509 1510 } ··· 1520 1521 1521 1522 if (objects[d->obj_no].real_type != OBJ_REF_DELTA) 1522 1523 continue; 1523 - data = repo_read_object_file(the_repository, &d->oid, &type, 1524 - &size); 1524 + data = odb_read_object(the_repository->objects, &d->oid, 1525 + &type, &size); 1525 1526 if (!data) 1526 1527 continue; 1527 1528 ··· 1829 1830 oidset_iter_init(&outgoing_links, &iter); 1830 1831 while ((oid = oidset_iter_next(&iter))) { 1831 1832 struct object_info info = OBJECT_INFO_INIT; 1832 - if (oid_object_info_extended(the_repository, oid, &info, 0)) 1833 + if (odb_read_object_info_extended(the_repository->objects, oid, &info, 0)) 1833 1834 /* Missing; assume it is a promisor object */ 1834 1835 continue; 1835 1836 if (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)
+2 -2
builtin/log.c
··· 15 15 #include "hex.h" 16 16 #include "refs.h" 17 17 #include "object-name.h" 18 - #include "object-store.h" 18 + #include "odb.h" 19 19 #include "pager.h" 20 20 #include "color.h" 21 21 #include "commit.h" ··· 733 733 { 734 734 unsigned long size; 735 735 enum object_type type; 736 - char *buf = repo_read_object_file(the_repository, oid, &type, &size); 736 + char *buf = odb_read_object(the_repository->objects, oid, &type, &size); 737 737 unsigned long offset = 0; 738 738 739 739 if (!buf)
+2 -2
builtin/ls-files.c
··· 25 25 #include "setup.h" 26 26 #include "sparse-index.h" 27 27 #include "submodule.h" 28 - #include "object-store.h" 28 + #include "odb.h" 29 29 #include "hex.h" 30 30 31 31 ··· 251 251 { 252 252 if (type == OBJ_BLOB) { 253 253 unsigned long size; 254 - if (oid_object_info(repo, oid, &size) < 0) 254 + if (odb_read_object_info(repo->objects, oid, &size) < 0) 255 255 die(_("could not get object info about '%s'"), 256 256 oid_to_hex(oid)); 257 257 if (padded)
+3 -3
builtin/ls-tree.c
··· 10 10 #include "gettext.h" 11 11 #include "hex.h" 12 12 #include "object-name.h" 13 - #include "object-store.h" 13 + #include "odb.h" 14 14 #include "tree.h" 15 15 #include "path.h" 16 16 #include "quote.h" ··· 27 27 { 28 28 if (type == OBJ_BLOB) { 29 29 unsigned long size; 30 - if (oid_object_info(the_repository, oid, &size) < 0) 30 + if (odb_read_object_info(the_repository->objects, oid, &size) < 0) 31 31 die(_("could not get object info about '%s'"), 32 32 oid_to_hex(oid)); 33 33 if (padded) ··· 217 217 218 218 if (type == OBJ_BLOB) { 219 219 unsigned long size; 220 - if (oid_object_info(the_repository, oid, &size) == OBJ_BAD) 220 + if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD) 221 221 xsnprintf(size_text, sizeof(size_text), "BAD"); 222 222 else 223 223 xsnprintf(size_text, sizeof(size_text),
+1 -1
builtin/merge-file.c
··· 7 7 #include "hex.h" 8 8 #include "object-file.h" 9 9 #include "object-name.h" 10 - #include "object-store.h" 10 + #include "odb.h" 11 11 #include "config.h" 12 12 #include "gettext.h" 13 13 #include "setup.h"
+7 -7
builtin/merge-tree.c
··· 10 10 #include "commit-reach.h" 11 11 #include "merge-ort.h" 12 12 #include "object-name.h" 13 - #include "object-store.h" 13 + #include "odb.h" 14 14 #include "parse-options.h" 15 15 #include "blob.h" 16 16 #include "merge-blobs.h" ··· 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;
+3 -3
builtin/mktag.c
··· 6 6 #include "strbuf.h" 7 7 #include "replace-object.h" 8 8 #include "object-file.h" 9 - #include "object-store.h" 9 + #include "odb.h" 10 10 #include "fsck.h" 11 11 #include "config.h" 12 12 ··· 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));
+5 -5
builtin/mktree.c
··· 12 12 #include "tree.h" 13 13 #include "parse-options.h" 14 14 #include "object-file.h" 15 - #include "object-store.h" 15 + #include "odb.h" 16 16 17 17 static struct treeent { 18 18 unsigned mode; ··· 124 124 125 125 /* Check the type of object identified by oid without fetching objects */ 126 126 oi.typep = &obj_type; 127 - if (oid_object_info_extended(the_repository, &oid, &oi, 128 - OBJECT_INFO_LOOKUP_REPLACE | 129 - OBJECT_INFO_QUICK | 130 - OBJECT_INFO_SKIP_FETCH_OBJECT) < 0) 127 + if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, 128 + OBJECT_INFO_LOOKUP_REPLACE | 129 + OBJECT_INFO_QUICK | 130 + OBJECT_INFO_SKIP_FETCH_OBJECT) < 0) 131 131 obj_type = -1; 132 132 133 133 if (obj_type < 0) {
+3 -3
builtin/multi-pack-index.c
··· 7 7 #include "midx.h" 8 8 #include "strbuf.h" 9 9 #include "trace2.h" 10 - #include "object-store.h" 10 + #include "odb.h" 11 11 #include "replace-object.h" 12 12 #include "repository.h" 13 13 ··· 294 294 295 295 if (the_repository && 296 296 the_repository->objects && 297 - the_repository->objects->odb) 298 - opts.object_dir = xstrdup(the_repository->objects->odb->path); 297 + the_repository->objects->sources) 298 + opts.object_dir = xstrdup(the_repository->objects->sources->path); 299 299 300 300 argc = parse_options(argc, argv, prefix, options, 301 301 builtin_multi_pack_index_usage, 0);
+4 -4
builtin/notes.c
··· 16 16 #include "notes.h" 17 17 #include "object-file.h" 18 18 #include "object-name.h" 19 - #include "object-store.h" 19 + #include "odb.h" 20 20 #include "path.h" 21 21 22 22 #include "pretty.h" ··· 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));
+36 -34
builtin/pack-objects.c
··· 32 32 #include "list.h" 33 33 #include "packfile.h" 34 34 #include "object-file.h" 35 - #include "object-store.h" 35 + #include "odb.h" 36 36 #include "replace-object.h" 37 37 #include "dir.h" 38 38 #include "midx.h" ··· 349 349 void *buf, *base_buf, *delta_buf; 350 350 enum object_type type; 351 351 352 - buf = repo_read_object_file(the_repository, &entry->idx.oid, &type, 353 - &size); 352 + buf = odb_read_object(the_repository->objects, &entry->idx.oid, 353 + &type, &size); 354 354 if (!buf) 355 355 die(_("unable to read %s"), oid_to_hex(&entry->idx.oid)); 356 - base_buf = repo_read_object_file(the_repository, 357 - &DELTA(entry)->idx.oid, &type, 358 - &base_size); 356 + base_buf = odb_read_object(the_repository->objects, 357 + &DELTA(entry)->idx.oid, &type, 358 + &base_size); 359 359 if (!base_buf) 360 360 die("unable to read %s", 361 361 oid_to_hex(&DELTA(entry)->idx.oid)); ··· 518 518 &size, NULL)) != NULL) 519 519 buf = NULL; 520 520 else { 521 - buf = repo_read_object_file(the_repository, 522 - &entry->idx.oid, &type, 523 - &size); 521 + buf = odb_read_object(the_repository->objects, 522 + &entry->idx.oid, &type, 523 + &size); 524 524 if (!buf) 525 525 die(_("unable to read %s"), 526 526 oid_to_hex(&entry->idx.oid)); ··· 1907 1907 /* Did not find one. Either we got a bogus request or 1908 1908 * we need to read and perhaps cache. 1909 1909 */ 1910 - data = repo_read_object_file(the_repository, oid, &type, &size); 1910 + data = odb_read_object(the_repository->objects, oid, &type, &size); 1911 1911 if (!data) 1912 1912 return NULL; 1913 1913 if (type != OBJ_TREE) { ··· 2067 2067 if (window <= num_preferred_base++) 2068 2068 return; 2069 2069 2070 - data = read_object_with_reference(the_repository, oid, 2071 - OBJ_TREE, &size, &tree_oid); 2070 + data = odb_read_object_peeled(the_repository->objects, oid, 2071 + OBJ_TREE, &size, &tree_oid); 2072 2072 if (!data) 2073 2073 return; 2074 2074 ··· 2166 2166 for (i = object_index_start; i < to_pack.nr_objects; i++) { 2167 2167 struct object_entry *entry = to_pack.objects + i; 2168 2168 2169 - if (!oid_object_info_extended(the_repository, 2170 - &entry->idx.oid, 2171 - NULL, 2172 - OBJECT_INFO_FOR_PREFETCH)) 2169 + if (!odb_read_object_info_extended(the_repository->objects, 2170 + &entry->idx.oid, 2171 + NULL, 2172 + OBJECT_INFO_FOR_PREFETCH)) 2173 2173 continue; 2174 2174 oid_array_append(&to_fetch, &entry->idx.oid); 2175 2175 } ··· 2310 2310 2311 2311 /* 2312 2312 * No choice but to fall back to the recursive delta walk 2313 - * with oid_object_info() to find about the object type 2313 + * with odb_read_object_info() to find about the object type 2314 2314 * at this point... 2315 2315 */ 2316 2316 give_up: 2317 2317 unuse_pack(&w_curs); 2318 2318 } 2319 2319 2320 - if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi, 2321 - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) { 2320 + if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi, 2321 + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) { 2322 2322 if (repo_has_promisor_remote(the_repository)) { 2323 2323 prefetch_to_pack(object_index); 2324 - if (oid_object_info_extended(the_repository, &entry->idx.oid, &oi, 2325 - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) 2324 + if (odb_read_object_info_extended(the_repository->objects, &entry->idx.oid, &oi, 2325 + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_LOOKUP_REPLACE) < 0) 2326 2326 type = -1; 2327 2327 } else { 2328 2328 type = -1; ··· 2396 2396 if (packed_object_info(the_repository, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) { 2397 2397 /* 2398 2398 * We failed to get the info from this pack for some reason; 2399 - * fall back to oid_object_info, which may find another copy. 2399 + * fall back to odb_read_object_info, which may find another copy. 2400 2400 * And if that fails, the error will be recorded in oe_type(entry) 2401 2401 * and dealt with in prepare_pack(). 2402 2402 */ 2403 2403 oe_set_type(entry, 2404 - oid_object_info(the_repository, &entry->idx.oid, &size)); 2404 + odb_read_object_info(the_repository->objects, 2405 + &entry->idx.oid, &size)); 2405 2406 } else { 2406 2407 oe_set_type(entry, type); 2407 2408 } ··· 2689 2690 2690 2691 if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) { 2691 2692 packing_data_lock(&to_pack); 2692 - if (oid_object_info(the_repository, &e->idx.oid, &size) < 0) 2693 + if (odb_read_object_info(the_repository->objects, 2694 + &e->idx.oid, &size) < 0) 2693 2695 die(_("unable to get size of %s"), 2694 2696 oid_to_hex(&e->idx.oid)); 2695 2697 packing_data_unlock(&to_pack); ··· 2772 2774 /* Load data if not already done */ 2773 2775 if (!trg->data) { 2774 2776 packing_data_lock(&to_pack); 2775 - trg->data = repo_read_object_file(the_repository, 2776 - &trg_entry->idx.oid, &type, 2777 - &sz); 2777 + trg->data = odb_read_object(the_repository->objects, 2778 + &trg_entry->idx.oid, &type, 2779 + &sz); 2778 2780 packing_data_unlock(&to_pack); 2779 2781 if (!trg->data) 2780 2782 die(_("object %s cannot be read"), ··· 2787 2789 } 2788 2790 if (!src->data) { 2789 2791 packing_data_lock(&to_pack); 2790 - src->data = repo_read_object_file(the_repository, 2791 - &src_entry->idx.oid, &type, 2792 - &sz); 2792 + src->data = odb_read_object(the_repository->objects, 2793 + &src_entry->idx.oid, &type, 2794 + &sz); 2793 2795 packing_data_unlock(&to_pack); 2794 2796 if (!src->data) { 2795 2797 if (src_entry->preferred_base) { ··· 4197 4199 * Quietly ignore ALL missing objects. This avoids problems with 4198 4200 * staging them now and getting an odd error later. 4199 4201 */ 4200 - if (!has_object(the_repository, &obj->oid, 0)) 4202 + if (!odb_has_object(the_repository->objects, &obj->oid, 0)) 4201 4203 return; 4202 4204 4203 4205 show_object(obj, name, data); ··· 4211 4213 * Quietly ignore EXPECTED missing objects. This avoids problems with 4212 4214 * staging them now and getting an odd error later. 4213 4215 */ 4214 - if (!has_object(the_repository, &obj->oid, 0) && 4216 + if (!odb_has_object(the_repository->objects, &obj->oid, 0) && 4215 4217 is_promisor_object(to_pack.repo, &obj->oid)) 4216 4218 return; 4217 4219 ··· 4294 4296 static int add_loose_object(const struct object_id *oid, const char *path, 4295 4297 void *data UNUSED) 4296 4298 { 4297 - enum object_type type = oid_object_info(the_repository, oid, NULL); 4299 + enum object_type type = odb_read_object_info(the_repository->objects, oid, NULL); 4298 4300 4299 4301 if (type < 0) { 4300 4302 warning(_("loose object at %s could not be examined"), path); ··· 4771 4773 static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED) 4772 4774 { 4773 4775 struct object_info info = OBJECT_INFO_INIT; 4774 - if (oid_object_info_extended(the_repository, &obj->oid, &info, 0)) 4776 + if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0)) 4775 4777 BUG("should_include_obj should only be called on existing objects"); 4776 4778 return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor; 4777 4779 }
+1 -1
builtin/pack-redundant.c
··· 13 13 #include "hex.h" 14 14 15 15 #include "packfile.h" 16 - #include "object-store.h" 16 + #include "odb.h" 17 17 #include "strbuf.h" 18 18 19 19 #define BLKSIZE 512
+3 -3
builtin/prune.c
··· 17 17 #include "replace-object.h" 18 18 #include "object-file.h" 19 19 #include "object-name.h" 20 - #include "object-store.h" 20 + #include "odb.h" 21 21 #include "shallow.h" 22 22 23 23 static const char * const prune_usage[] = { ··· 99 99 if (st.st_mtime > expire) 100 100 return 0; 101 101 if (show_only || verbose) { 102 - enum object_type type = oid_object_info(the_repository, oid, 103 - NULL); 102 + enum object_type type = odb_read_object_info(the_repository->objects, 103 + oid, NULL); 104 104 printf("%s %s\n", oid_to_hex(oid), 105 105 (type > 0) ? type_name(type) : "unknown"); 106 106 }
+5 -4
builtin/receive-pack.c
··· 33 33 #include "packfile.h" 34 34 #include "object-file.h" 35 35 #include "object-name.h" 36 - #include "object-store.h" 36 + #include "odb.h" 37 37 #include "path.h" 38 38 #include "protocol.h" 39 39 #include "commit-reach.h" ··· 359 359 360 360 refs_for_each_fullref_in(get_main_ref_store(the_repository), "", 361 361 exclude_patterns, show_ref_cb, &seen); 362 - for_each_alternate_ref(show_one_alternate_ref, &seen); 362 + odb_for_each_alternate_ref(the_repository->objects, 363 + show_one_alternate_ref, &seen); 363 364 364 365 oidset_clear(&seen); 365 366 strvec_clear(&excludes_vector); ··· 1508 1509 } 1509 1510 1510 1511 if (!is_null_oid(new_oid) && 1511 - !has_object(the_repository, new_oid, 1512 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 1512 + !odb_has_object(the_repository->objects, new_oid, 1513 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 1513 1514 error("unpack should have generated %s, " 1514 1515 "but I can't find it!", oid_to_hex(new_oid)); 1515 1516 ret = "bad pack";
+3 -3
builtin/remote.c
··· 14 14 #include "rebase.h" 15 15 #include "refs.h" 16 16 #include "refspec.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 #include "strvec.h" 19 19 #include "commit-reach.h" 20 20 #include "progress.h" ··· 454 454 info->status = PUSH_STATUS_UPTODATE; 455 455 else if (is_null_oid(&ref->old_oid)) 456 456 info->status = PUSH_STATUS_CREATE; 457 - else if (has_object(the_repository, &ref->old_oid, 458 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) && 457 + else if (odb_has_object(the_repository->objects, &ref->old_oid, 458 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) && 459 459 ref_newer(&ref->new_oid, &ref->old_oid)) 460 460 info->status = PUSH_STATUS_FASTFORWARD; 461 461 else
+4 -3
builtin/repack.c
··· 17 17 #include "midx.h" 18 18 #include "packfile.h" 19 19 #include "prune-packed.h" 20 - #include "object-store.h" 20 + #include "odb.h" 21 21 #include "promisor-remote.h" 22 22 #include "shallow.h" 23 23 #include "pack.h" ··· 710 710 if (oidset_insert(&data->seen, oid)) 711 711 return 0; /* already seen */ 712 712 713 - if (oid_object_info(the_repository, oid, NULL) != OBJ_COMMIT) 713 + if (odb_read_object_info(the_repository->objects, oid, NULL) != OBJ_COMMIT) 714 714 return 0; 715 715 716 716 fprintf(data->f->fp, "%s%s\n", data->preferred ? "+" : "", ··· 1261 1261 if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx) 1262 1262 die(_(incremental_bitmap_conflict_error)); 1263 1263 1264 - if (write_bitmaps && po_args.local && has_alt_odb(the_repository)) { 1264 + if (write_bitmaps && po_args.local && 1265 + odb_has_alternates(the_repository->objects)) { 1265 1266 /* 1266 1267 * When asked to do a local repack, but we have 1267 1268 * packfiles that are inherited from an alternate, then
+6 -6
builtin/replace.c
··· 19 19 #include "run-command.h" 20 20 #include "object-file.h" 21 21 #include "object-name.h" 22 - #include "object-store.h" 22 + #include "odb.h" 23 23 #include "replace-object.h" 24 24 #include "tag.h" 25 25 #include "wildmatch.h" ··· 65 65 if (repo_get_oid(data->repo, refname, &object)) 66 66 return error(_("failed to resolve '%s' as a valid ref"), refname); 67 67 68 - obj_type = oid_object_info(data->repo, &object, NULL); 69 - repl_type = oid_object_info(data->repo, oid, NULL); 68 + obj_type = odb_read_object_info(data->repo->objects, &object, NULL); 69 + repl_type = odb_read_object_info(data->repo->objects, oid, NULL); 70 70 71 71 printf("%s (%s) -> %s (%s)\n", refname, type_name(obj_type), 72 72 oid_to_hex(oid), type_name(repl_type)); ··· 185 185 struct strbuf err = STRBUF_INIT; 186 186 int res = 0; 187 187 188 - obj_type = oid_object_info(the_repository, object, NULL); 189 - repl_type = oid_object_info(the_repository, repl, NULL); 188 + obj_type = odb_read_object_info(the_repository->objects, object, NULL); 189 + repl_type = odb_read_object_info(the_repository->objects, repl, NULL); 190 190 if (!force && obj_type != repl_type) 191 191 return error(_("Objects must be of the same type.\n" 192 192 "'%s' points to a replaced object of type '%s'\n" ··· 334 334 if (repo_get_oid(the_repository, object_ref, &old_oid) < 0) 335 335 return error(_("not a valid object name: '%s'"), object_ref); 336 336 337 - type = oid_object_info(the_repository, &old_oid, NULL); 337 + type = odb_read_object_info(the_repository->objects, &old_oid, NULL); 338 338 if (type < 0) 339 339 return error(_("unable to get object type for %s"), 340 340 oid_to_hex(&old_oid));
+5 -3
builtin/rev-list.c
··· 14 14 #include "object.h" 15 15 #include "object-name.h" 16 16 #include "object-file.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 #include "pack-bitmap.h" 19 19 #include "parse-options.h" 20 20 #include "log-tree.h" ··· 110 110 off_t size; 111 111 struct object_info oi = OBJECT_INFO_INIT; 112 112 oi.disk_sizep = &size; 113 - if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0) 113 + if (odb_read_object_info_extended(the_repository->objects, 114 + &obj->oid, &oi, 0) < 0) 114 115 die(_("unable to get disk usage of %s"), oid_to_hex(&obj->oid)); 115 116 return size; 116 117 } ··· 346 347 static int finish_object(struct object *obj, const char *name, void *cb_data) 347 348 { 348 349 struct rev_list_info *info = cb_data; 349 - if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) { 350 + if (odb_read_object_info_extended(the_repository->objects, 351 + &obj->oid, NULL, 0) < 0) { 350 352 finish_object__ma(obj, name); 351 353 return 1; 352 354 }
+3 -3
builtin/show-ref.c
··· 5 5 #include "hex.h" 6 6 #include "refs/refs-internal.h" 7 7 #include "object-name.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "object.h" 10 10 #include "string-list.h" 11 11 #include "parse-options.h" ··· 35 35 const char *hex; 36 36 struct object_id peeled; 37 37 38 - if (!has_object(the_repository, oid, 39 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 38 + if (!odb_has_object(the_repository->objects, oid, 39 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 40 40 die("git show-ref: bad ref %s (%s)", refname, 41 41 oid_to_hex(oid)); 42 42
+6 -5
builtin/submodule--helper.c
··· 28 28 #include "diff.h" 29 29 #include "object-file.h" 30 30 #include "object-name.h" 31 - #include "object-store.h" 31 + #include "odb.h" 32 32 #include "advice.h" 33 33 #include "branch.h" 34 34 #include "list-objects-filter-options.h" ··· 1558 1558 ); 1559 1559 1560 1560 static int add_possible_reference_from_superproject( 1561 - struct object_directory *odb, void *sas_cb) 1561 + struct odb_source *alt_odb, void *sas_cb) 1562 1562 { 1563 1563 struct submodule_alternate_setup *sas = sas_cb; 1564 1564 size_t len; ··· 1567 1567 * If the alternate object store is another repository, try the 1568 1568 * standard layout with .git/(modules/<name>)+/objects 1569 1569 */ 1570 - if (strip_suffix(odb->path, "/objects", &len)) { 1570 + if (strip_suffix(alt_odb->path, "/objects", &len)) { 1571 1571 struct repository alternate; 1572 1572 char *sm_alternate; 1573 1573 struct strbuf sb = STRBUF_INIT; 1574 1574 struct strbuf err = STRBUF_INIT; 1575 - strbuf_add(&sb, odb->path, len); 1575 + strbuf_add(&sb, alt_odb->path, len); 1576 1576 1577 1577 if (repo_init(&alternate, sb.buf, NULL) < 0) 1578 1578 die(_("could not get a repository handle for gitdir '%s'"), ··· 1644 1644 die(_("Value '%s' for submodule.alternateErrorStrategy is not recognized"), error_strategy); 1645 1645 1646 1646 if (!strcmp(sm_alternate, "superproject")) 1647 - foreach_alt_odb(add_possible_reference_from_superproject, &sas); 1647 + odb_for_each_alternate(the_repository->objects, 1648 + add_possible_reference_from_superproject, &sas); 1648 1649 else if (!strcmp(sm_alternate, "no")) 1649 1650 ; /* do nothing */ 1650 1651 else
+5 -5
builtin/tag.c
··· 19 19 #include "refs.h" 20 20 #include "object-file.h" 21 21 #include "object-name.h" 22 - #include "object-store.h" 22 + #include "odb.h" 23 23 #include "path.h" 24 24 #include "tag.h" 25 25 #include "parse-options.h" ··· 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)) { ··· 304 304 struct strbuf header = STRBUF_INIT; 305 305 int should_edit; 306 306 307 - type = oid_object_info(the_repository, object, NULL); 307 + type = odb_read_object_info(the_repository->objects, object, NULL); 308 308 if (type <= OBJ_NONE) 309 309 die(_("bad object type.")); 310 310 ··· 401 401 } 402 402 403 403 strbuf_addstr(sb, " ("); 404 - type = oid_object_info(the_repository, oid, NULL); 404 + type = odb_read_object_info(the_repository->objects, oid, NULL); 405 405 switch (type) { 406 406 default: 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 {
+2 -2
builtin/unpack-file.c
··· 4 4 #include "hex.h" 5 5 #include "object-file.h" 6 6 #include "object-name.h" 7 - #include "object-store.h" 7 + #include "odb.h" 8 8 9 9 static char *create_temp_file(struct object_id *oid) 10 10 { ··· 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
+6 -6
builtin/unpack-objects.c
··· 9 9 #include "git-zlib.h" 10 10 #include "hex.h" 11 11 #include "object-file.h" 12 - #include "object-store.h" 12 + #include "odb.h" 13 13 #include "object.h" 14 14 #include "delta.h" 15 15 #include "pack.h" ··· 232 232 233 233 if (!(obj->flags & FLAG_OPEN)) { 234 234 unsigned long size; 235 - int type = oid_object_info(the_repository, &obj->oid, &size); 235 + int type = odb_read_object_info(the_repository->objects, &obj->oid, &size); 236 236 if (type != obj->type || type <= 0) 237 237 die("object of unexpected type"); 238 238 obj->flags |= FLAG_WRITTEN; ··· 449 449 delta_data = get_data(delta_size); 450 450 if (!delta_data) 451 451 return; 452 - if (has_object(the_repository, &base_oid, 453 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 452 + if (odb_has_object(the_repository->objects, &base_oid, 453 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 454 454 ; /* Ok we have this one */ 455 455 else if (resolve_against_held(nr, &base_oid, 456 456 delta_data, delta_size)) ··· 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));
+3 -3
bulk-checkin.c
··· 17 17 #include "tmp-objdir.h" 18 18 #include "packfile.h" 19 19 #include "object-file.h" 20 - #include "object-store.h" 20 + #include "odb.h" 21 21 22 22 static int odb_transaction_nesting; 23 23 ··· 130 130 static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid) 131 131 { 132 132 /* The object may already exist in the repository */ 133 - if (has_object(the_repository, oid, 134 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 133 + if (odb_has_object(the_repository->objects, oid, 134 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 135 135 return 1; 136 136 137 137 /* Might want to keep the list sorted */
+3 -2
bundle-uri.c
··· 14 14 #include "fetch-pack.h" 15 15 #include "remote.h" 16 16 #include "trace2.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 19 19 static struct { 20 20 enum bundle_list_heuristic heuristic; ··· 278 278 * Find a temporary filename that is available. This is briefly 279 279 * racy, but unlikely to collide. 280 280 */ 281 - fd = odb_mkstemp(&name, "bundles/tmp_uri_XXXXXX"); 281 + fd = odb_mkstemp(the_repository->objects, &name, 282 + "bundles/tmp_uri_XXXXXX"); 282 283 if (fd < 0) { 283 284 warning(_("failed to create temporary file")); 284 285 return NULL;
+3 -3
bundle.c
··· 7 7 #include "environment.h" 8 8 #include "gettext.h" 9 9 #include "hex.h" 10 - #include "object-store.h" 10 + #include "odb.h" 11 11 #include "repository.h" 12 12 #include "object.h" 13 13 #include "commit.h" ··· 233 233 .quiet = 1, 234 234 }; 235 235 236 - if (!r || !r->objects || !r->objects->odb) 236 + if (!r || !r->objects || !r->objects->sources) 237 237 return error(_("need a repository to verify a bundle")); 238 238 239 239 for (i = 0; i < p->nr; i++) { ··· 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);
+9 -8
cache-tree.c
··· 10 10 #include "cache-tree.h" 11 11 #include "bulk-checkin.h" 12 12 #include "object-file.h" 13 - #include "object-store.h" 13 + #include "odb.h" 14 14 #include "read-cache-ll.h" 15 15 #include "replace-object.h" 16 16 #include "repository.h" ··· 239 239 if (!it) 240 240 return 0; 241 241 if (it->entry_count < 0 || 242 - has_object(the_repository, &it->oid, 243 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 242 + odb_has_object(the_repository->objects, &it->oid, 243 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 244 244 return 0; 245 245 for (i = 0; i < it->subtree_nr; i++) { 246 246 if (!cache_tree_fully_valid(it->down[i]->cache_tree)) ··· 292 292 } 293 293 294 294 if (0 <= it->entry_count && 295 - has_object(the_repository, &it->oid, 296 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 295 + odb_has_object(the_repository->objects, &it->oid, 296 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 297 297 return it->entry_count; 298 298 299 299 /* ··· 399 399 ce_missing_ok = mode == S_IFGITLINK || missing_ok || 400 400 !must_check_existence(ce); 401 401 if (is_null_oid(oid) || 402 - (!ce_missing_ok && !has_object(the_repository, oid, 403 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) { 402 + (!ce_missing_ok && 403 + !odb_has_object(the_repository->objects, oid, 404 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) { 404 405 strbuf_release(&buffer); 405 406 if (expected_missing) 406 407 return -1; ··· 448 449 struct object_id oid; 449 450 hash_object_file(the_hash_algo, buffer.buf, buffer.len, 450 451 OBJ_TREE, &oid); 451 - if (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED)) 452 + if (odb_has_object(the_repository->objects, &oid, HAS_OBJECT_RECHECK_PACKED)) 452 453 oidcpy(&it->oid, &oid); 453 454 else 454 455 to_invalidate = 1;
+2 -2
combine-diff.c
··· 2 2 #define DISABLE_SIGN_COMPARE_WARNINGS 3 3 4 4 #include "git-compat-util.h" 5 - #include "object-store.h" 5 + #include "odb.h" 6 6 #include "commit.h" 7 7 #include "convert.h" 8 8 #include "diff.h" ··· 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)
+53 -53
commit-graph.c
··· 13 13 #include "refs.h" 14 14 #include "hash-lookup.h" 15 15 #include "commit-graph.h" 16 - #include "object-store.h" 16 + #include "odb.h" 17 17 #include "oid-array.h" 18 18 #include "path.h" 19 19 #include "alloc.h" ··· 37 37 if (git_env_bool(GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS, 0)) 38 38 flags = COMMIT_GRAPH_WRITE_BLOOM_FILTERS; 39 39 40 - if (write_commit_graph_reachable(the_repository->objects->odb, 40 + if (write_commit_graph_reachable(the_repository->objects->sources, 41 41 flags, NULL)) 42 42 die("failed to write commit-graph under GIT_TEST_COMMIT_GRAPH"); 43 43 } ··· 191 191 return 0; 192 192 } 193 193 194 - char *get_commit_graph_filename(struct object_directory *obj_dir) 194 + char *get_commit_graph_filename(struct odb_source *source) 195 195 { 196 - return xstrfmt("%s/info/commit-graph", obj_dir->path); 196 + return xstrfmt("%s/info/commit-graph", source->path); 197 197 } 198 198 199 - static char *get_split_graph_filename(struct object_directory *odb, 199 + static char *get_split_graph_filename(struct odb_source *source, 200 200 const char *oid_hex) 201 201 { 202 - return xstrfmt("%s/info/commit-graphs/graph-%s.graph", odb->path, 202 + return xstrfmt("%s/info/commit-graphs/graph-%s.graph", source->path, 203 203 oid_hex); 204 204 } 205 205 206 - char *get_commit_graph_chain_filename(struct object_directory *odb) 206 + char *get_commit_graph_chain_filename(struct odb_source *source) 207 207 { 208 - return xstrfmt("%s/info/commit-graphs/commit-graph-chain", odb->path); 208 + return xstrfmt("%s/info/commit-graphs/commit-graph-chain", source->path); 209 209 } 210 210 211 211 static struct commit_graph *alloc_commit_graph(void) ··· 250 250 251 251 struct commit_graph *load_commit_graph_one_fd_st(struct repository *r, 252 252 int fd, struct stat *st, 253 - struct object_directory *odb) 253 + struct odb_source *source) 254 254 { 255 255 void *graph_map; 256 256 size_t graph_size; ··· 269 269 ret = parse_commit_graph(&r->settings, graph_map, graph_size); 270 270 271 271 if (ret) 272 - ret->odb = odb; 272 + ret->odb_source = source; 273 273 else 274 274 munmap(graph_map, graph_size); 275 275 ··· 487 487 488 488 static struct commit_graph *load_commit_graph_one(struct repository *r, 489 489 const char *graph_file, 490 - struct object_directory *odb) 490 + struct odb_source *source) 491 491 { 492 492 493 493 struct stat st; ··· 498 498 if (!open_ok) 499 499 return NULL; 500 500 501 - g = load_commit_graph_one_fd_st(r, fd, &st, odb); 501 + g = load_commit_graph_one_fd_st(r, fd, &st, source); 502 502 503 503 if (g) 504 504 g->filename = xstrdup(graph_file); ··· 507 507 } 508 508 509 509 static struct commit_graph *load_commit_graph_v1(struct repository *r, 510 - struct object_directory *odb) 510 + struct odb_source *source) 511 511 { 512 - char *graph_name = get_commit_graph_filename(odb); 513 - struct commit_graph *g = load_commit_graph_one(r, graph_name, odb); 512 + char *graph_name = get_commit_graph_filename(source); 513 + struct commit_graph *g = load_commit_graph_one(r, graph_name, source); 514 514 free(graph_name); 515 515 516 516 return g; ··· 649 649 count = st->st_size / (the_hash_algo->hexsz + 1); 650 650 CALLOC_ARRAY(oids, count); 651 651 652 - prepare_alt_odb(r); 652 + odb_prepare_alternates(r->objects); 653 653 654 654 for (i = 0; i < count; i++) { 655 - struct object_directory *odb; 655 + struct odb_source *source; 656 656 657 657 if (strbuf_getline_lf(&line, fp) == EOF) 658 658 break; ··· 665 665 } 666 666 667 667 valid = 0; 668 - for (odb = r->objects->odb; odb; odb = odb->next) { 669 - char *graph_name = get_split_graph_filename(odb, line.buf); 670 - struct commit_graph *g = load_commit_graph_one(r, graph_name, odb); 668 + for (source = r->objects->sources; source; source = source->next) { 669 + char *graph_name = get_split_graph_filename(source, line.buf); 670 + struct commit_graph *g = load_commit_graph_one(r, graph_name, source); 671 671 672 672 free(graph_name); 673 673 ··· 701 701 } 702 702 703 703 static struct commit_graph *load_commit_graph_chain(struct repository *r, 704 - struct object_directory *odb) 704 + struct odb_source *source) 705 705 { 706 - char *chain_file = get_commit_graph_chain_filename(odb); 706 + char *chain_file = get_commit_graph_chain_filename(source); 707 707 struct stat st; 708 708 int fd; 709 709 struct commit_graph *g = NULL; ··· 719 719 } 720 720 721 721 struct commit_graph *read_commit_graph_one(struct repository *r, 722 - struct object_directory *odb) 722 + struct odb_source *source) 723 723 { 724 - struct commit_graph *g = load_commit_graph_v1(r, odb); 724 + struct commit_graph *g = load_commit_graph_v1(r, source); 725 725 726 726 if (!g) 727 - g = load_commit_graph_chain(r, odb); 727 + g = load_commit_graph_chain(r, source); 728 728 729 729 return g; 730 730 } 731 731 732 732 static void prepare_commit_graph_one(struct repository *r, 733 - struct object_directory *odb) 733 + struct odb_source *source) 734 734 { 735 735 736 736 if (r->objects->commit_graph) 737 737 return; 738 738 739 - r->objects->commit_graph = read_commit_graph_one(r, odb); 739 + r->objects->commit_graph = read_commit_graph_one(r, source); 740 740 } 741 741 742 742 /* ··· 747 747 */ 748 748 static int prepare_commit_graph(struct repository *r) 749 749 { 750 - struct object_directory *odb; 750 + struct odb_source *source; 751 751 752 752 /* 753 753 * Early return if there is no git dir or if the commit graph is ··· 778 778 if (!commit_graph_compatible(r)) 779 779 return 0; 780 780 781 - prepare_alt_odb(r); 782 - for (odb = r->objects->odb; 783 - !r->objects->commit_graph && odb; 784 - odb = odb->next) 785 - prepare_commit_graph_one(r, odb); 781 + odb_prepare_alternates(r->objects); 782 + for (source = r->objects->sources; 783 + !r->objects->commit_graph && source; 784 + source = source->next) 785 + prepare_commit_graph_one(r, source); 786 786 return !!r->objects->commit_graph; 787 787 } 788 788 ··· 829 829 return NULL; 830 830 } 831 831 832 - void close_commit_graph(struct raw_object_store *o) 832 + void close_commit_graph(struct object_database *o) 833 833 { 834 834 if (!o->commit_graph) 835 835 return; ··· 1040 1040 return NULL; 1041 1041 if (!search_commit_pos_in_graph(id, repo->objects->commit_graph, &pos)) 1042 1042 return NULL; 1043 - if (commit_graph_paranoia && !has_object(repo, id, 0)) 1043 + if (commit_graph_paranoia && !odb_has_object(repo->objects, id, 0)) 1044 1044 return NULL; 1045 1045 1046 1046 commit = lookup_commit(repo, id); ··· 1137 1137 1138 1138 struct write_commit_graph_context { 1139 1139 struct repository *r; 1140 - struct object_directory *odb; 1140 + struct odb_source *odb_source; 1141 1141 char *graph_name; 1142 1142 struct oid_array oids; 1143 1143 struct packed_commit_list commits; ··· 1862 1862 1863 1863 if (!peel_iterated_oid(the_repository, oid, &peeled)) 1864 1864 oid = &peeled; 1865 - if (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT) 1865 + if (odb_read_object_info(the_repository->objects, oid, NULL) == OBJ_COMMIT) 1866 1866 oidset_insert(data->commits, oid); 1867 1867 1868 1868 display_progress(data->progress, oidset_size(data->commits)); ··· 1870 1870 return 0; 1871 1871 } 1872 1872 1873 - int write_commit_graph_reachable(struct object_directory *odb, 1873 + int write_commit_graph_reachable(struct odb_source *source, 1874 1874 enum commit_graph_write_flags flags, 1875 1875 const struct commit_graph_opts *opts) 1876 1876 { ··· 1890 1890 1891 1891 stop_progress(&data.progress); 1892 1892 1893 - result = write_commit_graph(odb, NULL, &commits, 1893 + result = write_commit_graph(source, NULL, &commits, 1894 1894 flags, opts); 1895 1895 1896 1896 oidset_clear(&commits); ··· 1906 1906 int dirlen; 1907 1907 int ret = 0; 1908 1908 1909 - strbuf_addf(&packname, "%s/pack/", ctx->odb->path); 1909 + strbuf_addf(&packname, "%s/pack/", ctx->odb_source->path); 1910 1910 dirlen = packname.len; 1911 1911 if (ctx->report_progress) { 1912 1912 strbuf_addf(&progress_title, ··· 2060 2060 2061 2061 strbuf_addf(&tmp_file, 2062 2062 "%s/info/commit-graphs/tmp_graph_XXXXXX", 2063 - ctx->odb->path); 2063 + ctx->odb_source->path); 2064 2064 ctx->graph_name = strbuf_detach(&tmp_file, NULL); 2065 2065 } else { 2066 - ctx->graph_name = get_commit_graph_filename(ctx->odb); 2066 + ctx->graph_name = get_commit_graph_filename(ctx->odb_source); 2067 2067 } 2068 2068 2069 2069 if (safe_create_leading_directories(the_repository, ctx->graph_name)) { ··· 2073 2073 } 2074 2074 2075 2075 if (ctx->split) { 2076 - char *lock_name = get_commit_graph_chain_filename(ctx->odb); 2076 + char *lock_name = get_commit_graph_chain_filename(ctx->odb_source); 2077 2077 2078 2078 hold_lock_file_for_update_mode(&lk, lock_name, 2079 2079 LOCK_DIE_ON_ERROR, 0444); ··· 2161 2161 2162 2162 if (ctx->split && ctx->base_graph_name && ctx->num_commit_graphs_after > 1) { 2163 2163 char *new_base_hash = xstrdup(oid_to_hex(&ctx->new_base_graph->oid)); 2164 - char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb, new_base_hash); 2164 + char *new_base_name = get_split_graph_filename(ctx->new_base_graph->odb_source, new_base_hash); 2165 2165 2166 2166 free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 2]); 2167 2167 free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 2]); ··· 2201 2201 } 2202 2202 } 2203 2203 } else { 2204 - char *graph_name = get_commit_graph_filename(ctx->odb); 2204 + char *graph_name = get_commit_graph_filename(ctx->odb_source); 2205 2205 unlink(graph_name); 2206 2206 free(graph_name); 2207 2207 } 2208 2208 2209 2209 free(ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]); 2210 2210 ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1] = xstrdup(hash_to_hex(file_hash)); 2211 - final_graph_name = get_split_graph_filename(ctx->odb, 2211 + final_graph_name = get_split_graph_filename(ctx->odb_source, 2212 2212 ctx->commit_graph_hash_after[ctx->num_commit_graphs_after - 1]); 2213 2213 free(ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1]); 2214 2214 ctx->commit_graph_filenames_after[ctx->num_commit_graphs_after - 1] = final_graph_name; ··· 2259 2259 flags != COMMIT_GRAPH_SPLIT_REPLACE) { 2260 2260 while (g && (g->num_commits <= st_mult(size_mult, num_commits) || 2261 2261 (max_commits && num_commits > max_commits))) { 2262 - if (g->odb != ctx->odb) 2262 + if (g->odb_source != ctx->odb_source) 2263 2263 break; 2264 2264 2265 2265 if (unsigned_add_overflows(num_commits, g->num_commits)) ··· 2281 2281 "should be 1 with --split=replace"); 2282 2282 2283 2283 if (ctx->num_commit_graphs_after == 2) { 2284 - char *old_graph_name = get_commit_graph_filename(g->odb); 2284 + char *old_graph_name = get_commit_graph_filename(g->odb_source); 2285 2285 2286 2286 if (!strcmp(g->filename, old_graph_name) && 2287 - g->odb != ctx->odb) { 2287 + g->odb_source != ctx->odb_source) { 2288 2288 ctx->num_commit_graphs_after = 1; 2289 2289 ctx->new_base_graph = NULL; 2290 2290 } ··· 2456 2456 if (ctx->opts && ctx->opts->expire_time) 2457 2457 expire_time = ctx->opts->expire_time; 2458 2458 if (!ctx->split) { 2459 - char *chain_file_name = get_commit_graph_chain_filename(ctx->odb); 2459 + char *chain_file_name = get_commit_graph_chain_filename(ctx->odb_source); 2460 2460 unlink(chain_file_name); 2461 2461 free(chain_file_name); 2462 2462 ctx->num_commit_graphs_after = 0; 2463 2463 } 2464 2464 2465 - strbuf_addstr(&path, ctx->odb->path); 2465 + strbuf_addstr(&path, ctx->odb_source->path); 2466 2466 strbuf_addstr(&path, "/info/commit-graphs"); 2467 2467 dir = opendir(path.buf); 2468 2468 ··· 2504 2504 strbuf_release(&path); 2505 2505 } 2506 2506 2507 - int write_commit_graph(struct object_directory *odb, 2507 + int write_commit_graph(struct odb_source *source, 2508 2508 const struct string_list *const pack_indexes, 2509 2509 struct oidset *commits, 2510 2510 enum commit_graph_write_flags flags, ··· 2513 2513 struct repository *r = the_repository; 2514 2514 struct write_commit_graph_context ctx = { 2515 2515 .r = r, 2516 - .odb = odb, 2516 + .odb_source = source, 2517 2517 .append = flags & COMMIT_GRAPH_WRITE_APPEND ? 1 : 0, 2518 2518 .report_progress = flags & COMMIT_GRAPH_WRITE_PROGRESS ? 1 : 0, 2519 2519 .split = flags & COMMIT_GRAPH_WRITE_SPLIT ? 1 : 0,
+10 -10
commit-graph.h
··· 1 1 #ifndef COMMIT_GRAPH_H 2 2 #define COMMIT_GRAPH_H 3 3 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "oidset.h" 6 6 7 7 #define GIT_TEST_COMMIT_GRAPH "GIT_TEST_COMMIT_GRAPH" ··· 26 26 struct commit; 27 27 struct bloom_filter_settings; 28 28 struct repository; 29 - struct raw_object_store; 29 + struct object_database; 30 30 struct string_list; 31 31 32 - char *get_commit_graph_filename(struct object_directory *odb); 33 - char *get_commit_graph_chain_filename(struct object_directory *odb); 32 + char *get_commit_graph_filename(struct odb_source *source); 33 + char *get_commit_graph_chain_filename(struct odb_source *source); 34 34 int open_commit_graph(const char *graph_file, int *fd, struct stat *st); 35 35 int open_commit_graph_chain(const char *chain_file, int *fd, struct stat *st); 36 36 ··· 89 89 uint32_t num_commits; 90 90 struct object_id oid; 91 91 char *filename; 92 - struct object_directory *odb; 92 + struct odb_source *odb_source; 93 93 94 94 uint32_t num_commits_in_base; 95 95 unsigned int read_generation_data; ··· 115 115 116 116 struct commit_graph *load_commit_graph_one_fd_st(struct repository *r, 117 117 int fd, struct stat *st, 118 - struct object_directory *odb); 118 + struct odb_source *source); 119 119 struct commit_graph *load_commit_graph_chain_fd_st(struct repository *r, 120 120 int fd, struct stat *st, 121 121 int *incomplete_chain); 122 122 struct commit_graph *read_commit_graph_one(struct repository *r, 123 - struct object_directory *odb); 123 + struct odb_source *source); 124 124 125 125 struct repo_settings; 126 126 ··· 173 173 * is not compatible with the commit-graph feature, then the 174 174 * methods will return 0 without writing a commit-graph. 175 175 */ 176 - int write_commit_graph_reachable(struct object_directory *odb, 176 + int write_commit_graph_reachable(struct odb_source *source, 177 177 enum commit_graph_write_flags flags, 178 178 const struct commit_graph_opts *opts); 179 - int write_commit_graph(struct object_directory *odb, 179 + int write_commit_graph(struct odb_source *source, 180 180 const struct string_list *pack_indexes, 181 181 struct oidset *commits, 182 182 enum commit_graph_write_flags flags, ··· 186 186 187 187 int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags); 188 188 189 - void close_commit_graph(struct raw_object_store *); 189 + void close_commit_graph(struct object_database *); 190 190 void free_commit_graph(struct commit_graph *); 191 191 192 192 /*
+8 -7
commit.c
··· 9 9 #include "hex.h" 10 10 #include "repository.h" 11 11 #include "object-name.h" 12 - #include "object-store.h" 12 + #include "odb.h" 13 13 #include "utf8.h" 14 14 #include "diff.h" 15 15 #include "revision.h" ··· 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)); ··· 575 575 if (commit_graph_paranoia == -1) 576 576 commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 0); 577 577 578 - if (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) { 578 + if (commit_graph_paranoia && !odb_has_object(r->objects, &item->object.oid, 0)) { 579 579 unparse_commit(r, &item->object.oid); 580 580 return quiet_on_missing ? -1 : 581 581 error(_("commit %s exists in commit-graph but not in the object database"), ··· 585 585 return 0; 586 586 } 587 587 588 - if (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0) 588 + if (odb_read_object_info_extended(r->objects, &item->object.oid, 589 + &oi, flags) < 0) 589 590 return quiet_on_missing ? -1 : 590 591 error("Could not read %s", 591 592 oid_to_hex(&item->object.oid)); ··· 1274 1275 desc = merge_remote_util(parent); 1275 1276 if (!desc || !desc->obj) 1276 1277 return; 1277 - buf = repo_read_object_file(the_repository, &desc->obj->oid, &type, 1278 - &size); 1278 + buf = odb_read_object(the_repository->objects, &desc->obj->oid, 1279 + &type, &size); 1279 1280 if (!buf || type != OBJ_TAG) 1280 1281 goto free_return; 1281 1282 if (!parse_signature(buf, size, &payload, &signature)) ··· 1706 1707 /* Not having i18n.commitencoding is the same as having utf-8 */ 1707 1708 encoding_is_utf8 = is_encoding_utf8(git_commit_encoding); 1708 1709 1709 - assert_oid_type(tree, OBJ_TREE); 1710 + odb_assert_oid_type(the_repository->objects, tree, OBJ_TREE); 1710 1711 1711 1712 if (memchr(msg, '\0', msg_len)) 1712 1713 return error("a NUL byte in commit log message not allowed.");
+2 -2
config.c
··· 31 31 #include "hashmap.h" 32 32 #include "string-list.h" 33 33 #include "object-name.h" 34 - #include "object-store.h" 34 + #include "odb.h" 35 35 #include "pager.h" 36 36 #include "path.h" 37 37 #include "utf8.h" ··· 1937 1937 unsigned long size; 1938 1938 int ret; 1939 1939 1940 - buf = repo_read_object_file(repo, oid, &type, &size); 1940 + buf = odb_read_object(repo->objects, oid, &type, &size); 1941 1941 if (!buf) 1942 1942 return error(_("unable to load config blob object '%s'"), name); 1943 1943 if (type != OBJ_BLOB) {
+1 -1
connected.c
··· 3 3 #include "git-compat-util.h" 4 4 #include "gettext.h" 5 5 #include "hex.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 #include "run-command.h" 8 8 #include "sigchain.h" 9 9 #include "connected.h"
+1 -1
contrib/coccinelle/the_repository.cocci
··· 77 77 | 78 78 - diff_setup 79 79 + repo_diff_setup 80 - // object-store.h 80 + // odb.h 81 81 | 82 82 - read_object_file 83 83 + repo_read_object_file
+6 -6
diagnose.c
··· 7 7 #include "gettext.h" 8 8 #include "hex.h" 9 9 #include "strvec.h" 10 - #include "object-store.h" 10 + #include "odb.h" 11 11 #include "packfile.h" 12 12 #include "parse-options.h" 13 13 #include "repository.h" ··· 59 59 (uintmax_t)st.st_size); 60 60 } 61 61 62 - static int dir_file_stats(struct object_directory *object_dir, void *data) 62 + static int dir_file_stats(struct odb_source *source, void *data) 63 63 { 64 64 struct strbuf *buf = data; 65 65 66 - strbuf_addf(buf, "Contents of %s:\n", object_dir->path); 66 + strbuf_addf(buf, "Contents of %s:\n", source->path); 67 67 68 - for_each_file_in_pack_dir(object_dir->path, dir_file_stats_objects, 68 + for_each_file_in_pack_dir(source->path, dir_file_stats_objects, 69 69 data); 70 70 71 71 return 0; ··· 228 228 229 229 strbuf_reset(&buf); 230 230 strbuf_addstr(&buf, "--add-virtual-file=packs-local.txt:"); 231 - dir_file_stats(r->objects->odb, &buf); 232 - foreach_alt_odb(dir_file_stats, &buf); 231 + dir_file_stats(r->objects->sources, &buf); 232 + odb_for_each_alternate(r->objects, dir_file_stats, &buf); 233 233 strvec_push(&archiver_args, buf.buf); 234 234 235 235 strbuf_reset(&buf);
+10 -10
diff.c
··· 23 23 #include "color.h" 24 24 #include "run-command.h" 25 25 #include "utf8.h" 26 - #include "object-store.h" 26 + #include "odb.h" 27 27 #include "userdiff.h" 28 28 #include "submodule.h" 29 29 #include "hashmap.h" ··· 4230 4230 info.contentp = &s->data; 4231 4231 4232 4232 if (options && options->missing_object_cb) { 4233 - if (!oid_object_info_extended(r, &s->oid, &info, 4234 - OBJECT_INFO_LOOKUP_REPLACE | 4235 - OBJECT_INFO_SKIP_FETCH_OBJECT)) 4233 + if (!odb_read_object_info_extended(r->objects, &s->oid, &info, 4234 + OBJECT_INFO_LOOKUP_REPLACE | 4235 + OBJECT_INFO_SKIP_FETCH_OBJECT)) 4236 4236 goto object_read; 4237 4237 options->missing_object_cb(options->missing_object_data); 4238 4238 } 4239 - if (oid_object_info_extended(r, &s->oid, &info, 4240 - OBJECT_INFO_LOOKUP_REPLACE)) 4239 + if (odb_read_object_info_extended(r->objects, &s->oid, &info, 4240 + OBJECT_INFO_LOOKUP_REPLACE)) 4241 4241 die("unable to read %s", oid_to_hex(&s->oid)); 4242 4242 4243 4243 object_read: ··· 4252 4252 } 4253 4253 if (!info.contentp) { 4254 4254 info.contentp = &s->data; 4255 - if (oid_object_info_extended(r, &s->oid, &info, 4256 - OBJECT_INFO_LOOKUP_REPLACE)) 4255 + if (odb_read_object_info_extended(r->objects, &s->oid, &info, 4256 + OBJECT_INFO_LOOKUP_REPLACE)) 4257 4257 die("unable to read %s", oid_to_hex(&s->oid)); 4258 4258 } 4259 4259 s->should_free = 1; ··· 7019 7019 { 7020 7020 if (filespec && filespec->oid_valid && 7021 7021 !S_ISGITLINK(filespec->mode) && 7022 - oid_object_info_extended(r, &filespec->oid, NULL, 7023 - OBJECT_INFO_FOR_PREFETCH)) 7022 + odb_read_object_info_extended(r->objects, &filespec->oid, NULL, 7023 + OBJECT_INFO_FOR_PREFETCH)) 7024 7024 oid_array_append(to_fetch, &filespec->oid); 7025 7025 } 7026 7026
+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;
+3 -3
entry.c
··· 1 1 #define USE_THE_REPOSITORY_VARIABLE 2 2 3 3 #include "git-compat-util.h" 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "dir.h" 6 6 #include "environment.h" 7 7 #include "gettext.h" ··· 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) {
+9 -8
fetch-pack.c
··· 24 24 #include "oid-array.h" 25 25 #include "oidset.h" 26 26 #include "packfile.h" 27 - #include "object-store.h" 27 + #include "odb.h" 28 28 #include "path.h" 29 29 #include "connected.h" 30 30 #include "fetch-negotiator.h" ··· 115 115 size_t i; 116 116 117 117 if (!initialized) { 118 - for_each_alternate_ref(cache_one_alternate, &cache); 118 + odb_for_each_alternate_ref(the_repository->objects, 119 + cache_one_alternate, &cache); 119 120 initialized = 1; 120 121 } 121 122 ··· 141 142 commit = lookup_commit_in_graph(the_repository, oid); 142 143 if (commit) { 143 144 if (mark_tags_complete_and_check_obj_db) { 144 - if (!has_object(the_repository, oid, 0)) 145 + if (!odb_has_object(the_repository->objects, oid, 0)) 145 146 die_in_commit_graph_only(oid); 146 147 } 147 148 return commit; 148 149 } 149 150 150 151 while (1) { 151 - if (oid_object_info_extended(the_repository, oid, &info, 152 - OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)) 152 + if (odb_read_object_info_extended(the_repository->objects, oid, &info, 153 + OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)) 153 154 return NULL; 154 155 if (type == OBJ_TAG) { 155 156 struct tag *tag = (struct tag *) ··· 769 770 if (!commit) { 770 771 struct object *o; 771 772 772 - if (!has_object(the_repository, &ref->old_oid, 0)) 773 + if (!odb_has_object(the_repository->objects, &ref->old_oid, 0)) 773 774 continue; 774 775 o = parse_object(the_repository, &ref->old_oid); 775 776 if (!o || o->type != OBJ_COMMIT) ··· 1983 1984 struct oid_array extra = OID_ARRAY_INIT; 1984 1985 struct object_id *oid = si->shallow->oid; 1985 1986 for (i = 0; i < si->shallow->nr; i++) 1986 - if (has_object(the_repository, &oid[i], 1987 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 1987 + if (odb_has_object(the_repository->objects, &oid[i], 1988 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 1988 1989 oid_array_append(&extra, &oid[i]); 1989 1990 if (extra.nr) { 1990 1991 setup_alternate_shallow(&shallow_lock,
+3 -3
fmt-merge-msg.c
··· 6 6 #include "environment.h" 7 7 #include "refs.h" 8 8 #include "object-name.h" 9 - #include "object-store.h" 9 + #include "odb.h" 10 10 #include "diff.h" 11 11 #include "diff-merges.h" 12 12 #include "hex.h" ··· 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 };
+2 -2
fsck.c
··· 4 4 #include "date.h" 5 5 #include "dir.h" 6 6 #include "hex.h" 7 - #include "object-store.h" 7 + #include "odb.h" 8 8 #include "path.h" 9 9 #include "repository.h" 10 10 #include "object.h" ··· 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;
+3 -3
grep.c
··· 5 5 #include "gettext.h" 6 6 #include "grep.h" 7 7 #include "hex.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "pretty.h" 10 10 #include "userdiff.h" 11 11 #include "xdiff-interface.h" ··· 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,
+1 -1
http-backend.c
··· 18 18 #include "url.h" 19 19 #include "strvec.h" 20 20 #include "packfile.h" 21 - #include "object-store.h" 21 + #include "odb.h" 22 22 #include "protocol.h" 23 23 #include "date.h" 24 24 #include "write-or-die.h"
+11 -9
http-push.c
··· 20 20 #include "url.h" 21 21 #include "packfile.h" 22 22 #include "object-file.h" 23 - #include "object-store.h" 23 + #include "odb.h" 24 24 #include "commit-reach.h" 25 25 26 26 #ifdef EXPAT_NEEDS_XMLPARSE_H ··· 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 */ ··· 1447 1447 * may be required for updating server info later. 1448 1448 */ 1449 1449 if (repo->can_update_info_refs && 1450 - !has_object(the_repository, &ref->old_oid, 1451 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 1450 + !odb_has_object(the_repository->objects, &ref->old_oid, 1451 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 1452 1452 obj = lookup_unknown_object(the_repository, &ref->old_oid); 1453 1453 fprintf(stderr, " fetch %s for %s\n", 1454 1454 oid_to_hex(&ref->old_oid), refname); ··· 1653 1653 return error("Remote HEAD symrefs too deep"); 1654 1654 if (is_null_oid(&head_oid)) 1655 1655 return error("Unable to resolve remote HEAD"); 1656 - if (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 1656 + if (!odb_has_object(the_repository->objects, &head_oid, 1657 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 1657 1658 return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid)); 1658 1659 1659 1660 /* Remote branch must resolve to a known object */ 1660 1661 if (is_null_oid(&remote_ref->old_oid)) 1661 1662 return error("Unable to resolve remote branch %s", 1662 1663 remote_ref->name); 1663 - if (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 1664 + if (!odb_has_object(the_repository->objects, &remote_ref->old_oid, 1665 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 1664 1666 return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid)); 1665 1667 1666 1668 /* Remote branch must be an ancestor of remote HEAD */ ··· 1881 1883 if (!force_all && 1882 1884 !is_null_oid(&ref->old_oid) && 1883 1885 !ref->force) { 1884 - if (!has_object(the_repository, &ref->old_oid, 1885 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) || 1886 + if (!odb_has_object(the_repository->objects, &ref->old_oid, 1887 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) || 1886 1888 !ref_newer(&ref->peer_ref->new_oid, 1887 1889 &ref->old_oid)) { 1888 1890 /*
+6 -6
http-walker.c
··· 10 10 #include "transport.h" 11 11 #include "packfile.h" 12 12 #include "object-file.h" 13 - #include "object-store.h" 13 + #include "odb.h" 14 14 15 15 struct alt_base { 16 16 char *base; ··· 138 138 list_for_each_safe(pos, tmp, head) { 139 139 obj_req = list_entry(pos, struct object_request, node); 140 140 if (obj_req->state == WAITING) { 141 - if (has_object(the_repository, &obj_req->oid, 142 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 141 + if (odb_has_object(the_repository->objects, &obj_req->oid, 142 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 143 143 obj_req->state = COMPLETE; 144 144 else { 145 145 start_object_request(obj_req); ··· 497 497 if (!obj_req) 498 498 return error("Couldn't find request for %s in the queue", hex); 499 499 500 - if (has_object(the_repository, &obj_req->oid, 501 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 500 + if (odb_has_object(the_repository->objects, &obj_req->oid, 501 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 502 502 if (obj_req->req) 503 503 abort_http_object_request(&obj_req->req); 504 504 abort_object_request(obj_req); ··· 543 543 ret = error("File %s has bad hash", hex); 544 544 } else if (req->rename < 0) { 545 545 struct strbuf buf = STRBUF_INIT; 546 - odb_loose_path(the_repository->objects->odb, &buf, &req->oid); 546 + odb_loose_path(the_repository->objects->sources, &buf, &req->oid); 547 547 ret = error("unable to write sha1 filename %s", buf.buf); 548 548 strbuf_release(&buf); 549 549 }
+3 -3
http.c
··· 19 19 #include "packfile.h" 20 20 #include "string-list.h" 21 21 #include "object-file.h" 22 - #include "object-store.h" 22 + #include "odb.h" 23 23 #include "tempfile.h" 24 24 25 25 static struct trace_key trace_curl = TRACE_KEY_INIT(CURL); ··· 2662 2662 oidcpy(&freq->oid, oid); 2663 2663 freq->localfile = -1; 2664 2664 2665 - odb_loose_path(the_repository->objects->odb, &filename, oid); 2665 + odb_loose_path(the_repository->objects->sources, &filename, oid); 2666 2666 strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf); 2667 2667 2668 2668 strbuf_addf(&prevfile, "%s.prev", filename.buf); ··· 2814 2814 unlink_or_warn(freq->tmpfile.buf); 2815 2815 return -1; 2816 2816 } 2817 - odb_loose_path(the_repository->objects->odb, &filename, &freq->oid); 2817 + odb_loose_path(the_repository->objects->sources, &filename, &freq->oid); 2818 2818 freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf); 2819 2819 strbuf_release(&filename); 2820 2820
+2 -2
list-objects-filter.c
··· 12 12 #include "oidmap.h" 13 13 #include "oidset.h" 14 14 #include "object-name.h" 15 - #include "object-store.h" 15 + #include "odb.h" 16 16 17 17 /* Remember to update object flag allocation in object.h */ 18 18 /* ··· 310 310 assert(obj->type == OBJ_BLOB); 311 311 assert((obj->flags & SEEN) == 0); 312 312 313 - t = oid_object_info(r, &obj->oid, &object_length); 313 + t = odb_read_object_info(r->objects, &obj->oid, &object_length); 314 314 if (t != OBJ_BLOB) { /* probably OBJ_NONE */ 315 315 /* 316 316 * We DO NOT have the blob locally, so we cannot
+3 -3
list-objects.c
··· 14 14 #include "list-objects-filter.h" 15 15 #include "list-objects-filter-options.h" 16 16 #include "packfile.h" 17 - #include "object-store.h" 17 + #include "odb.h" 18 18 #include "trace.h" 19 19 #include "environment.h" 20 20 ··· 74 74 * of missing objects. 75 75 */ 76 76 if (ctx->revs->exclude_promisor_objects && 77 - !has_object(the_repository, &obj->oid, 78 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) && 77 + !odb_has_object(the_repository->objects, &obj->oid, 78 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) && 79 79 is_promisor_object(ctx->revs->repo, &obj->oid)) 80 80 return; 81 81
+1 -1
log-tree.c
··· 176 176 return 0; 177 177 } 178 178 179 - objtype = oid_object_info(the_repository, oid, NULL); 179 + objtype = odb_read_object_info(the_repository->objects, oid, NULL); 180 180 if (objtype < 0) 181 181 return 0; 182 182 obj = lookup_object_by_type(the_repository, oid, objtype);
+23 -23
loose.c
··· 1 1 #include "git-compat-util.h" 2 2 #include "hash.h" 3 3 #include "path.h" 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "hex.h" 6 6 #include "repository.h" 7 7 #include "wrapper.h" ··· 44 44 return 1; 45 45 } 46 46 47 - static int insert_loose_map(struct object_directory *odb, 47 + static int insert_loose_map(struct odb_source *source, 48 48 const struct object_id *oid, 49 49 const struct object_id *compat_oid) 50 50 { 51 - struct loose_object_map *map = odb->loose_map; 51 + struct loose_object_map *map = source->loose_map; 52 52 int inserted = 0; 53 53 54 54 inserted |= insert_oid_pair(map->to_compat, oid, compat_oid); 55 55 inserted |= insert_oid_pair(map->to_storage, compat_oid, oid); 56 56 if (inserted) 57 - oidtree_insert(odb->loose_objects_cache, compat_oid); 57 + oidtree_insert(source->loose_objects_cache, compat_oid); 58 58 59 59 return inserted; 60 60 } 61 61 62 - static int load_one_loose_object_map(struct repository *repo, struct object_directory *dir) 62 + static int load_one_loose_object_map(struct repository *repo, struct odb_source *source) 63 63 { 64 64 struct strbuf buf = STRBUF_INIT, path = STRBUF_INIT; 65 65 FILE *fp; 66 66 67 - if (!dir->loose_map) 68 - loose_object_map_init(&dir->loose_map); 69 - if (!dir->loose_objects_cache) { 70 - ALLOC_ARRAY(dir->loose_objects_cache, 1); 71 - oidtree_init(dir->loose_objects_cache); 67 + if (!source->loose_map) 68 + loose_object_map_init(&source->loose_map); 69 + if (!source->loose_objects_cache) { 70 + ALLOC_ARRAY(source->loose_objects_cache, 1); 71 + oidtree_init(source->loose_objects_cache); 72 72 } 73 73 74 - insert_loose_map(dir, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree); 75 - insert_loose_map(dir, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob); 76 - insert_loose_map(dir, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid); 74 + insert_loose_map(source, repo->hash_algo->empty_tree, repo->compat_hash_algo->empty_tree); 75 + insert_loose_map(source, repo->hash_algo->empty_blob, repo->compat_hash_algo->empty_blob); 76 + insert_loose_map(source, repo->hash_algo->null_oid, repo->compat_hash_algo->null_oid); 77 77 78 78 repo_common_path_replace(repo, &path, "objects/loose-object-idx"); 79 79 fp = fopen(path.buf, "rb"); ··· 93 93 parse_oid_hex_algop(p, &compat_oid, &p, repo->compat_hash_algo) || 94 94 p != buf.buf + buf.len) 95 95 goto err; 96 - insert_loose_map(dir, &oid, &compat_oid); 96 + insert_loose_map(source, &oid, &compat_oid); 97 97 } 98 98 99 99 strbuf_release(&buf); ··· 107 107 108 108 int repo_read_loose_object_map(struct repository *repo) 109 109 { 110 - struct object_directory *dir; 110 + struct odb_source *source; 111 111 112 112 if (!should_use_loose_object_map(repo)) 113 113 return 0; 114 114 115 - prepare_alt_odb(repo); 115 + odb_prepare_alternates(repo->objects); 116 116 117 - for (dir = repo->objects->odb; dir; dir = dir->next) { 118 - if (load_one_loose_object_map(repo, dir) < 0) { 117 + for (source = repo->objects->sources; source; source = source->next) { 118 + if (load_one_loose_object_map(repo, source) < 0) { 119 119 return -1; 120 120 } 121 121 } ··· 124 124 125 125 int repo_write_loose_object_map(struct repository *repo) 126 126 { 127 - kh_oid_map_t *map = repo->objects->odb->loose_map->to_compat; 127 + kh_oid_map_t *map = repo->objects->sources->loose_map->to_compat; 128 128 struct lock_file lock; 129 129 int fd; 130 130 khiter_t iter; ··· 212 212 if (!should_use_loose_object_map(repo)) 213 213 return 0; 214 214 215 - inserted = insert_loose_map(repo->objects->odb, oid, compat_oid); 215 + inserted = insert_loose_map(repo->objects->sources, oid, compat_oid); 216 216 if (inserted) 217 217 return write_one_object(repo, oid, compat_oid); 218 218 return 0; ··· 223 223 const struct git_hash_algo *to, 224 224 struct object_id *dest) 225 225 { 226 - struct object_directory *dir; 226 + struct odb_source *source; 227 227 kh_oid_map_t *map; 228 228 khiter_t pos; 229 229 230 - for (dir = repo->objects->odb; dir; dir = dir->next) { 231 - struct loose_object_map *loose_map = dir->loose_map; 230 + for (source = repo->objects->sources; source; source = source->next) { 231 + struct loose_object_map *loose_map = source->loose_map; 232 232 if (!loose_map) 233 233 continue; 234 234 map = (to == repo->compat_hash_algo) ?
+2 -2
mailmap.c
··· 6 6 #include "string-list.h" 7 7 #include "mailmap.h" 8 8 #include "object-name.h" 9 - #include "object-store.h" 9 + #include "odb.h" 10 10 #include "setup.h" 11 11 12 12 char *git_mailmap_file; ··· 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) {
+3 -3
match-trees.c
··· 7 7 #include "tree.h" 8 8 #include "tree-walk.h" 9 9 #include "object-file.h" 10 - #include "object-store.h" 10 + #include "odb.h" 11 11 #include "repository.h" 12 12 13 13 static int score_missing(unsigned mode) ··· 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);
+5 -5
merge-blobs.c
··· 4 4 #include "merge-ll.h" 5 5 #include "blob.h" 6 6 #include "merge-blobs.h" 7 - #include "object-store.h" 7 + #include "odb.h" 8 8 9 9 static int fill_mmfile_blob(mmfile_t *f, struct blob *obj) 10 10 { ··· 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)
+4 -4
merge-ort.c
··· 39 39 #include "mem-pool.h" 40 40 #include "object-file.h" 41 41 #include "object-name.h" 42 - #include "object-store.h" 42 + #include "odb.h" 43 43 #include "oid-array.h" 44 44 #include "path.h" 45 45 #include "promisor-remote.h" ··· 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, ··· 4385 4385 4386 4386 if ((ci->filemask & side_mask) && 4387 4387 S_ISREG(vi->mode) && 4388 - oid_object_info_extended(opt->repo, &vi->oid, NULL, 4389 - OBJECT_INFO_FOR_PREFETCH)) 4388 + odb_read_object_info_extended(opt->repo->objects, &vi->oid, NULL, 4389 + OBJECT_INFO_FOR_PREFETCH)) 4390 4390 oid_array_append(&to_fetch, &vi->oid); 4391 4391 } 4392 4392 }
+1 -1
meson.build
··· 396 396 'object-file-convert.c', 397 397 'object-file.c', 398 398 'object-name.c', 399 - 'object-store.c', 400 399 'object.c', 400 + 'odb.c', 401 401 'oid-array.c', 402 402 'oidmap.c', 403 403 'oidset.c',
+1 -1
midx-write.c
··· 922 922 struct strbuf cur_path_real = STRBUF_INIT; 923 923 924 924 /* Ensure the given object_dir is local, or a known alternate. */ 925 - find_odb(r, obj_dir_real); 925 + odb_find_source(r->objects, obj_dir_real); 926 926 927 927 for (cur = get_multi_pack_index(r); cur; cur = cur->next) { 928 928 strbuf_realpath(&cur_path_real, cur->object_dir, 1);
+3 -3
midx.c
··· 832 832 { 833 833 struct strbuf midx = STRBUF_INIT; 834 834 835 - get_midx_filename(r->hash_algo, &midx, r->objects->odb->path); 835 + get_midx_filename(r->hash_algo, &midx, r->objects->sources->path); 836 836 837 837 if (r->objects && r->objects->multi_pack_index) { 838 838 close_midx(r->objects->multi_pack_index); ··· 842 842 if (remove_path(midx.buf)) 843 843 die(_("failed to clear multi-pack-index at %s"), midx.buf); 844 844 845 - clear_midx_files_ext(r->objects->odb->path, MIDX_EXT_BITMAP, NULL); 846 - clear_midx_files_ext(r->objects->odb->path, MIDX_EXT_REV, NULL); 845 + clear_midx_files_ext(r->objects->sources->path, MIDX_EXT_BITMAP, NULL); 846 + clear_midx_files_ext(r->objects->sources->path, MIDX_EXT_REV, NULL); 847 847 848 848 strbuf_release(&midx); 849 849 }
+2 -2
notes-cache.c
··· 3 3 #include "git-compat-util.h" 4 4 #include "notes-cache.h" 5 5 #include "object-file.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 #include "pretty.h" 8 8 #include "repository.h" 9 9 #include "commit.h" ··· 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;
+2 -2
notes-merge.c
··· 8 8 #include "refs.h" 9 9 #include "object-file.h" 10 10 #include "object-name.h" 11 - #include "object-store.h" 11 + #include "odb.h" 12 12 #include "path.h" 13 13 #include "repository.h" 14 14 #include "diff.h" ··· 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",
+10 -9
notes.c
··· 8 8 #include "notes.h" 9 9 #include "object-file.h" 10 10 #include "object-name.h" 11 - #include "object-store.h" 11 + #include "odb.h" 12 12 #include "utf8.h" 13 13 #include "strbuf.h" 14 14 #include "tree-walk.h" ··· 794 794 struct note_delete_list **l = (struct note_delete_list **) cb_data; 795 795 struct note_delete_list *n; 796 796 797 - if (has_object(the_repository, object_oid, 798 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 797 + if (odb_has_object(the_repository->objects, object_oid, 798 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 799 799 return 0; /* nothing to do for this note */ 800 800 801 801 /* failed to find object => prune this note */ ··· 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 }
+47 -47
object-file.c
··· 21 21 #include "loose.h" 22 22 #include "object-file-convert.h" 23 23 #include "object-file.h" 24 - #include "object-store.h" 24 + #include "odb.h" 25 25 #include "oidtree.h" 26 26 #include "pack.h" 27 27 #include "packfile.h" ··· 55 55 } 56 56 } 57 57 58 - const char *odb_loose_path(struct object_directory *odb, 58 + const char *odb_loose_path(struct odb_source *source, 59 59 struct strbuf *buf, 60 60 const struct object_id *oid) 61 61 { 62 62 strbuf_reset(buf); 63 - strbuf_addstr(buf, odb->path); 63 + strbuf_addstr(buf, source->path); 64 64 strbuf_addch(buf, '/'); 65 65 fill_loose_path(buf, oid); 66 66 return buf->buf; ··· 88 88 return 1; 89 89 } 90 90 91 - static int check_and_freshen_odb(struct object_directory *odb, 91 + static int check_and_freshen_odb(struct odb_source *source, 92 92 const struct object_id *oid, 93 93 int freshen) 94 94 { 95 95 static struct strbuf path = STRBUF_INIT; 96 - odb_loose_path(odb, &path, oid); 96 + odb_loose_path(source, &path, oid); 97 97 return check_and_freshen_file(path.buf, freshen); 98 98 } 99 99 100 100 static int check_and_freshen_local(const struct object_id *oid, int freshen) 101 101 { 102 - return check_and_freshen_odb(the_repository->objects->odb, oid, freshen); 102 + return check_and_freshen_odb(the_repository->objects->sources, oid, freshen); 103 103 } 104 104 105 105 static int check_and_freshen_nonlocal(const struct object_id *oid, int freshen) 106 106 { 107 - struct object_directory *odb; 107 + struct odb_source *source; 108 108 109 - prepare_alt_odb(the_repository); 110 - for (odb = the_repository->objects->odb->next; odb; odb = odb->next) { 111 - if (check_and_freshen_odb(odb, oid, freshen)) 109 + odb_prepare_alternates(the_repository->objects); 110 + for (source = the_repository->objects->sources->next; source; source = source->next) { 111 + if (check_and_freshen_odb(source, oid, freshen)) 112 112 return 1; 113 113 } 114 114 return 0; ··· 202 202 static int stat_loose_object(struct repository *r, const struct object_id *oid, 203 203 struct stat *st, const char **path) 204 204 { 205 - struct object_directory *odb; 205 + struct odb_source *source; 206 206 static struct strbuf buf = STRBUF_INIT; 207 207 208 - prepare_alt_odb(r); 209 - for (odb = r->objects->odb; odb; odb = odb->next) { 210 - *path = odb_loose_path(odb, &buf, oid); 208 + odb_prepare_alternates(r->objects); 209 + for (source = r->objects->sources; source; source = source->next) { 210 + *path = odb_loose_path(source, &buf, oid); 211 211 if (!lstat(*path, st)) 212 212 return 0; 213 213 } ··· 223 223 const struct object_id *oid, const char **path) 224 224 { 225 225 int fd; 226 - struct object_directory *odb; 226 + struct odb_source *source; 227 227 int most_interesting_errno = ENOENT; 228 228 static struct strbuf buf = STRBUF_INIT; 229 229 230 - prepare_alt_odb(r); 231 - for (odb = r->objects->odb; odb; odb = odb->next) { 232 - *path = odb_loose_path(odb, &buf, oid); 230 + odb_prepare_alternates(r->objects); 231 + for (source = r->objects->sources; source; source = source->next) { 232 + *path = odb_loose_path(source, &buf, oid); 233 233 fd = git_open(*path); 234 234 if (fd >= 0) 235 235 return fd; ··· 244 244 static int quick_has_loose(struct repository *r, 245 245 const struct object_id *oid) 246 246 { 247 - struct object_directory *odb; 247 + struct odb_source *source; 248 248 249 - prepare_alt_odb(r); 250 - for (odb = r->objects->odb; odb; odb = odb->next) { 251 - if (oidtree_contains(odb_loose_cache(odb, oid), oid)) 249 + odb_prepare_alternates(r->objects); 250 + for (source = r->objects->sources; source; source = source->next) { 251 + if (oidtree_contains(odb_loose_cache(source, oid), oid)) 252 252 return 1; 253 253 } 254 254 return 0; ··· 694 694 /* Finalize a file on disk, and close it. */ 695 695 static void close_loose_object(int fd, const char *filename) 696 696 { 697 - if (the_repository->objects->odb->will_destroy) 697 + if (the_repository->objects->sources->will_destroy) 698 698 goto out; 699 699 700 700 if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT)) ··· 876 876 if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT)) 877 877 prepare_loose_object_bulk_checkin(); 878 878 879 - odb_loose_path(the_repository->objects->odb, &filename, oid); 879 + odb_loose_path(the_repository->objects->sources, &filename, oid); 880 880 881 881 fd = start_loose_object_common(&tmp_file, filename.buf, flags, 882 882 &stream, compressed, sizeof(compressed), ··· 1023 1023 goto cleanup; 1024 1024 } 1025 1025 1026 - odb_loose_path(the_repository->objects->odb, &filename, oid); 1026 + odb_loose_path(the_repository->objects->sources, &filename, oid); 1027 1027 1028 1028 /* We finally know the object path, and create the missing dir. */ 1029 1029 dirlen = directory_size(filename.buf); ··· 1108 1108 oi.typep = &type; 1109 1109 oi.sizep = &len; 1110 1110 oi.contentp = &buf; 1111 - if (oid_object_info_extended(the_repository, oid, &oi, 0)) 1111 + if (odb_read_object_info_extended(the_repository->objects, oid, &oi, 0)) 1112 1112 return error(_("cannot read object for %s"), oid_to_hex(oid)); 1113 1113 if (compat) { 1114 1114 if (repo_oid_to_algop(repo, oid, compat, &compat_oid)) ··· 1437 1437 int for_each_loose_object(each_loose_object_fn cb, void *data, 1438 1438 enum for_each_object_flags flags) 1439 1439 { 1440 - struct object_directory *odb; 1440 + struct odb_source *source; 1441 1441 1442 - prepare_alt_odb(the_repository); 1443 - for (odb = the_repository->objects->odb; odb; odb = odb->next) { 1444 - int r = for_each_loose_file_in_objdir(odb->path, cb, NULL, 1442 + odb_prepare_alternates(the_repository->objects); 1443 + for (source = the_repository->objects->sources; source; source = source->next) { 1444 + int r = for_each_loose_file_in_objdir(source->path, cb, NULL, 1445 1445 NULL, data); 1446 1446 if (r) 1447 1447 return r; ··· 1461 1461 return 0; 1462 1462 } 1463 1463 1464 - struct oidtree *odb_loose_cache(struct object_directory *odb, 1465 - const struct object_id *oid) 1464 + struct oidtree *odb_loose_cache(struct odb_source *source, 1465 + const struct object_id *oid) 1466 1466 { 1467 1467 int subdir_nr = oid->hash[0]; 1468 1468 struct strbuf buf = STRBUF_INIT; 1469 - size_t word_bits = bitsizeof(odb->loose_objects_subdir_seen[0]); 1469 + size_t word_bits = bitsizeof(source->loose_objects_subdir_seen[0]); 1470 1470 size_t word_index = subdir_nr / word_bits; 1471 1471 size_t mask = (size_t)1u << (subdir_nr % word_bits); 1472 1472 uint32_t *bitmap; 1473 1473 1474 1474 if (subdir_nr < 0 || 1475 - subdir_nr >= bitsizeof(odb->loose_objects_subdir_seen)) 1475 + subdir_nr >= bitsizeof(source->loose_objects_subdir_seen)) 1476 1476 BUG("subdir_nr out of range"); 1477 1477 1478 - bitmap = &odb->loose_objects_subdir_seen[word_index]; 1478 + bitmap = &source->loose_objects_subdir_seen[word_index]; 1479 1479 if (*bitmap & mask) 1480 - return odb->loose_objects_cache; 1481 - if (!odb->loose_objects_cache) { 1482 - ALLOC_ARRAY(odb->loose_objects_cache, 1); 1483 - oidtree_init(odb->loose_objects_cache); 1480 + return source->loose_objects_cache; 1481 + if (!source->loose_objects_cache) { 1482 + ALLOC_ARRAY(source->loose_objects_cache, 1); 1483 + oidtree_init(source->loose_objects_cache); 1484 1484 } 1485 - strbuf_addstr(&buf, odb->path); 1485 + strbuf_addstr(&buf, source->path); 1486 1486 for_each_file_in_obj_subdir(subdir_nr, &buf, 1487 1487 append_loose_object, 1488 1488 NULL, NULL, 1489 - odb->loose_objects_cache); 1489 + source->loose_objects_cache); 1490 1490 *bitmap |= mask; 1491 1491 strbuf_release(&buf); 1492 - return odb->loose_objects_cache; 1492 + return source->loose_objects_cache; 1493 1493 } 1494 1494 1495 - void odb_clear_loose_cache(struct object_directory *odb) 1495 + void odb_clear_loose_cache(struct odb_source *source) 1496 1496 { 1497 - oidtree_clear(odb->loose_objects_cache); 1498 - FREE_AND_NULL(odb->loose_objects_cache); 1499 - memset(&odb->loose_objects_subdir_seen, 0, 1500 - sizeof(odb->loose_objects_subdir_seen)); 1497 + oidtree_clear(source->loose_objects_cache); 1498 + FREE_AND_NULL(source->loose_objects_cache); 1499 + memset(&source->loose_objects_subdir_seen, 0, 1500 + sizeof(source->loose_objects_subdir_seen)); 1501 1501 } 1502 1502 1503 1503 static int check_stream_oid(git_zstream *stream,
+6 -6
object-file.h
··· 3 3 4 4 #include "git-zlib.h" 5 5 #include "object.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 8 8 struct index_state; 9 9 10 10 /* 11 - * Set this to 0 to prevent oid_object_info_extended() from fetching missing 11 + * Set this to 0 to prevent odb_read_object_info_extended() from fetching missing 12 12 * blobs. This has a difference only if extensions.partialClone is set. 13 13 * 14 14 * Its default value is 1. ··· 24 24 int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags); 25 25 int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags); 26 26 27 - struct object_directory; 27 + struct odb_source; 28 28 29 29 /* 30 30 * Populate and return the loose object cache array corresponding to the 31 31 * given object ID. 32 32 */ 33 - struct oidtree *odb_loose_cache(struct object_directory *odb, 33 + struct oidtree *odb_loose_cache(struct odb_source *source, 34 34 const struct object_id *oid); 35 35 36 36 /* Empty the loose object cache for the specified object directory. */ 37 - void odb_clear_loose_cache(struct object_directory *odb); 37 + void odb_clear_loose_cache(struct odb_source *source); 38 38 39 39 /* 40 40 * Put in `buf` the name of the file in the local object database that 41 41 * would be used to store a loose object with the specified oid. 42 42 */ 43 - const char *odb_loose_path(struct object_directory *odb, 43 + const char *odb_loose_path(struct odb_source *source, 44 44 struct strbuf *buf, 45 45 const struct object_id *oid); 46 46
+12 -12
object-name.c
··· 112 112 113 113 static void find_short_object_filename(struct disambiguate_state *ds) 114 114 { 115 - struct object_directory *odb; 115 + struct odb_source *source; 116 116 117 - for (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next) 118 - oidtree_each(odb_loose_cache(odb, &ds->bin_pfx), 117 + for (source = ds->repo->objects->sources; source && !ds->ambiguous; source = source->next) 118 + oidtree_each(odb_loose_cache(source, &ds->bin_pfx), 119 119 &ds->bin_pfx, ds->len, match_prefix, ds); 120 120 } 121 121 ··· 251 251 const struct object_id *oid, 252 252 void *cb_data UNUSED) 253 253 { 254 - int kind = oid_object_info(r, oid, NULL); 254 + int kind = odb_read_object_info(r->objects, oid, NULL); 255 255 return kind == OBJ_COMMIT; 256 256 } 257 257 ··· 262 262 struct object *obj; 263 263 int kind; 264 264 265 - kind = oid_object_info(r, oid, NULL); 265 + kind = odb_read_object_info(r->objects, oid, NULL); 266 266 if (kind == OBJ_COMMIT) 267 267 return 1; 268 268 if (kind != OBJ_TAG) ··· 279 279 const struct object_id *oid, 280 280 void *cb_data UNUSED) 281 281 { 282 - int kind = oid_object_info(r, oid, NULL); 282 + int kind = odb_read_object_info(r->objects, oid, NULL); 283 283 return kind == OBJ_TREE; 284 284 } 285 285 ··· 290 290 struct object *obj; 291 291 int kind; 292 292 293 - kind = oid_object_info(r, oid, NULL); 293 + kind = odb_read_object_info(r->objects, oid, NULL); 294 294 if (kind == OBJ_TREE || kind == OBJ_COMMIT) 295 295 return 1; 296 296 if (kind != OBJ_TAG) ··· 307 307 const struct object_id *oid, 308 308 void *cb_data UNUSED) 309 309 { 310 - int kind = oid_object_info(r, oid, NULL); 310 + int kind = odb_read_object_info(r->objects, oid, NULL); 311 311 return kind == OBJ_BLOB; 312 312 } 313 313 ··· 376 376 ds->hex_pfx[len] = '\0'; 377 377 ds->repo = r; 378 378 ds->bin_pfx.algo = algo ? hash_algo_by_ptr(algo) : GIT_HASH_UNKNOWN; 379 - prepare_alt_odb(r); 379 + odb_prepare_alternates(r->objects); 380 380 return 0; 381 381 } 382 382 ··· 399 399 return 0; 400 400 401 401 hash = repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV); 402 - type = oid_object_info(ds->repo, oid, NULL); 402 + type = odb_read_object_info(ds->repo->objects, oid, NULL); 403 403 404 404 if (type < 0) { 405 405 /* ··· 514 514 { 515 515 struct repository *sort_ambiguous_repo = ctx; 516 516 const struct object_id *a = va, *b = vb; 517 - int a_type = oid_object_info(sort_ambiguous_repo, a, NULL); 518 - int b_type = oid_object_info(sort_ambiguous_repo, b, NULL); 517 + int a_type = odb_read_object_info(sort_ambiguous_repo->objects, a, NULL); 518 + int b_type = odb_read_object_info(sort_ambiguous_repo->objects, b, NULL); 519 519 int a_type_sort; 520 520 int b_type_sort; 521 521
+223 -190
object-store.c odb.c
··· 1 - #define USE_THE_REPOSITORY_VARIABLE 2 - 3 1 #include "git-compat-util.h" 4 2 #include "abspath.h" 5 3 #include "commit-graph.h" ··· 13 11 #include "loose.h" 14 12 #include "object-file-convert.h" 15 13 #include "object-file.h" 16 - #include "object-store.h" 14 + #include "odb.h" 17 15 #include "packfile.h" 18 16 #include "path.h" 19 17 #include "promisor-remote.h" ··· 24 22 #include "strbuf.h" 25 23 #include "strvec.h" 26 24 #include "submodule.h" 25 + #include "trace2.h" 27 26 #include "write-or-die.h" 28 27 29 28 KHASH_INIT(odb_path_map, const char * /* key: odb_path */, 30 - struct object_directory *, 1, fspathhash, fspatheq) 29 + struct odb_source *, 1, fspathhash, fspatheq) 31 30 32 31 /* 33 32 * This is meant to hold a *small* number of objects that you would 34 - * 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 35 34 * to write them into the object store (e.g. a browse-only 36 35 * application). 37 36 */ ··· 44 43 } value; 45 44 }; 46 45 47 - static const struct cached_object *find_cached_object(struct raw_object_store *object_store, 46 + static const struct cached_object *find_cached_object(struct object_database *object_store, 48 47 const struct object_id *oid) 49 48 { 50 49 static const struct cached_object empty_tree = { ··· 63 62 return NULL; 64 63 } 65 64 66 - int odb_mkstemp(struct strbuf *temp_filename, const char *pattern) 65 + int odb_mkstemp(struct object_database *odb, 66 + struct strbuf *temp_filename, const char *pattern) 67 67 { 68 68 int fd; 69 69 /* ··· 71 71 * restrictive except to remove write permission. 72 72 */ 73 73 int mode = 0444; 74 - repo_git_path_replace(the_repository, temp_filename, "objects/%s", pattern); 74 + repo_git_path_replace(odb->repo, temp_filename, "objects/%s", pattern); 75 75 fd = git_mkstemp_mode(temp_filename->buf, mode); 76 76 if (0 <= fd) 77 77 return fd; 78 78 79 79 /* slow path */ 80 80 /* some mkstemp implementations erase temp_filename on failure */ 81 - repo_git_path_replace(the_repository, temp_filename, "objects/%s", pattern); 82 - safe_create_leading_directories(the_repository, temp_filename->buf); 81 + repo_git_path_replace(odb->repo, temp_filename, "objects/%s", pattern); 82 + safe_create_leading_directories(odb->repo, temp_filename->buf); 83 83 return xmkstemp_mode(temp_filename->buf, mode); 84 84 } 85 85 86 86 /* 87 87 * Return non-zero iff the path is usable as an alternate object database. 88 88 */ 89 - static int alt_odb_usable(struct raw_object_store *o, 89 + static int alt_odb_usable(struct object_database *o, 90 90 struct strbuf *path, 91 91 const char *normalized_objdir, khiter_t *pos) 92 92 { ··· 104 104 * Prevent the common mistake of listing the same 105 105 * thing twice, or object directory itself. 106 106 */ 107 - if (!o->odb_by_path) { 107 + if (!o->source_by_path) { 108 108 khiter_t p; 109 109 110 - o->odb_by_path = kh_init_odb_path_map(); 111 - assert(!o->odb->next); 112 - p = kh_put_odb_path_map(o->odb_by_path, o->odb->path, &r); 110 + o->source_by_path = kh_init_odb_path_map(); 111 + assert(!o->sources->next); 112 + p = kh_put_odb_path_map(o->source_by_path, o->sources->path, &r); 113 113 assert(r == 1); /* never used */ 114 - kh_value(o->odb_by_path, p) = o->odb; 114 + kh_value(o->source_by_path, p) = o->sources; 115 115 } 116 116 if (fspatheq(path->buf, normalized_objdir)) 117 117 return 0; 118 - *pos = kh_put_odb_path_map(o->odb_by_path, path->buf, &r); 118 + *pos = kh_put_odb_path_map(o->source_by_path, path->buf, &r); 119 119 /* r: 0 = exists, 1 = never used, 2 = deleted */ 120 120 return r == 0 ? 0 : 1; 121 121 } ··· 124 124 * Prepare alternate object database registry. 125 125 * 126 126 * The variable alt_odb_list points at the list of struct 127 - * object_directory. The elements on this list come from 127 + * odb_source. The elements on this list come from 128 128 * non-empty elements from colon separated ALTERNATE_DB_ENVIRONMENT 129 129 * environment variable, and $GIT_OBJECT_DIRECTORY/info/alternates, 130 130 * whose contents is similar to that environment variable but can be ··· 135 135 * of the object ID, an extra slash for the first level indirection, and 136 136 * the terminating NUL. 137 137 */ 138 - static void read_info_alternates(struct repository *r, 138 + static void read_info_alternates(struct object_database *odb, 139 139 const char *relative_base, 140 140 int depth); 141 - static int link_alt_odb_entry(struct repository *r, const struct strbuf *entry, 142 - const char *relative_base, int depth, const char *normalized_objdir) 141 + 142 + static int link_alt_odb_entry(struct object_database *odb, 143 + const struct strbuf *entry, 144 + const char *relative_base, 145 + int depth, 146 + const char *normalized_objdir) 143 147 { 144 - struct object_directory *ent; 148 + struct odb_source *alternate; 145 149 struct strbuf pathbuf = STRBUF_INIT; 146 150 struct strbuf tmp = STRBUF_INIT; 147 151 khiter_t pos; ··· 167 171 while (pathbuf.len && pathbuf.buf[pathbuf.len - 1] == '/') 168 172 strbuf_setlen(&pathbuf, pathbuf.len - 1); 169 173 170 - if (!alt_odb_usable(r->objects, &pathbuf, normalized_objdir, &pos)) 174 + if (!alt_odb_usable(odb, &pathbuf, normalized_objdir, &pos)) 171 175 goto error; 172 176 173 - CALLOC_ARRAY(ent, 1); 174 - /* pathbuf.buf is already in r->objects->odb_by_path */ 175 - ent->path = strbuf_detach(&pathbuf, NULL); 177 + CALLOC_ARRAY(alternate, 1); 178 + alternate->odb = odb; 179 + /* pathbuf.buf is already in r->objects->source_by_path */ 180 + alternate->path = strbuf_detach(&pathbuf, NULL); 176 181 177 182 /* add the alternate entry */ 178 - *r->objects->odb_tail = ent; 179 - r->objects->odb_tail = &(ent->next); 180 - ent->next = NULL; 181 - assert(r->objects->odb_by_path); 182 - kh_value(r->objects->odb_by_path, pos) = ent; 183 + *odb->sources_tail = alternate; 184 + odb->sources_tail = &(alternate->next); 185 + alternate->next = NULL; 186 + assert(odb->source_by_path); 187 + kh_value(odb->source_by_path, pos) = alternate; 183 188 184 189 /* recursively add alternates */ 185 - read_info_alternates(r, ent->path, depth + 1); 190 + read_info_alternates(odb, alternate->path, depth + 1); 186 191 ret = 0; 187 192 error: 188 193 strbuf_release(&tmp); ··· 219 224 return end; 220 225 } 221 226 222 - static void link_alt_odb_entries(struct repository *r, const char *alt, 227 + static void link_alt_odb_entries(struct object_database *odb, const char *alt, 223 228 int sep, const char *relative_base, int depth) 224 229 { 225 230 struct strbuf objdirbuf = STRBUF_INIT; ··· 234 239 return; 235 240 } 236 241 237 - strbuf_realpath(&objdirbuf, r->objects->odb->path, 1); 242 + strbuf_realpath(&objdirbuf, odb->sources->path, 1); 238 243 239 244 while (*alt) { 240 245 alt = parse_alt_odb_entry(alt, sep, &entry); 241 246 if (!entry.len) 242 247 continue; 243 - link_alt_odb_entry(r, &entry, 248 + link_alt_odb_entry(odb, &entry, 244 249 relative_base, depth, objdirbuf.buf); 245 250 } 246 251 strbuf_release(&entry); 247 252 strbuf_release(&objdirbuf); 248 253 } 249 254 250 - static void read_info_alternates(struct repository *r, 255 + static void read_info_alternates(struct object_database *odb, 251 256 const char *relative_base, 252 257 int depth) 253 258 { ··· 261 266 return; 262 267 } 263 268 264 - link_alt_odb_entries(r, buf.buf, '\n', relative_base, depth); 269 + link_alt_odb_entries(odb, buf.buf, '\n', relative_base, depth); 265 270 strbuf_release(&buf); 266 271 free(path); 267 272 } 268 273 269 - void add_to_alternates_file(const char *reference) 274 + void odb_add_to_alternates_file(struct object_database *odb, 275 + const char *reference) 270 276 { 271 277 struct lock_file lock = LOCK_INIT; 272 - char *alts = repo_git_path(the_repository, "objects/info/alternates"); 278 + char *alts = repo_git_path(odb->repo, "objects/info/alternates"); 273 279 FILE *in, *out; 274 280 int found = 0; 275 281 ··· 302 308 fprintf_or_die(out, "%s\n", reference); 303 309 if (commit_lock_file(&lock)) 304 310 die_errno(_("unable to move new alternates file into place")); 305 - if (the_repository->objects->loaded_alternates) 306 - link_alt_odb_entries(the_repository, reference, 311 + if (odb->loaded_alternates) 312 + link_alt_odb_entries(odb, reference, 307 313 '\n', NULL, 0); 308 314 } 309 315 free(alts); 310 316 } 311 317 312 - void add_to_alternates_memory(const char *reference) 318 + void odb_add_to_alternates_memory(struct object_database *odb, 319 + const char *reference) 313 320 { 314 321 /* 315 322 * Make sure alternates are initialized, or else our entry may be 316 323 * overwritten when they are. 317 324 */ 318 - prepare_alt_odb(the_repository); 325 + odb_prepare_alternates(odb); 319 326 320 - link_alt_odb_entries(the_repository, reference, 327 + link_alt_odb_entries(odb, reference, 321 328 '\n', NULL, 0); 322 329 } 323 330 324 - struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy) 331 + struct odb_source *odb_set_temporary_primary_source(struct object_database *odb, 332 + const char *dir, int will_destroy) 325 333 { 326 - struct object_directory *new_odb; 334 + struct odb_source *source; 327 335 328 336 /* 329 337 * Make sure alternates are initialized, or else our entry may be 330 338 * overwritten when they are. 331 339 */ 332 - prepare_alt_odb(the_repository); 340 + odb_prepare_alternates(odb); 333 341 334 342 /* 335 343 * Make a new primary odb and link the old primary ODB in as an 336 344 * alternate 337 345 */ 338 - new_odb = xcalloc(1, sizeof(*new_odb)); 339 - new_odb->path = xstrdup(dir); 346 + source = xcalloc(1, sizeof(*source)); 347 + source->odb = odb; 348 + source->path = xstrdup(dir); 340 349 341 350 /* 342 351 * Disable ref updates while a temporary odb is active, since 343 352 * the objects in the database may roll back. 344 353 */ 345 - new_odb->disable_ref_updates = 1; 346 - new_odb->will_destroy = will_destroy; 347 - new_odb->next = the_repository->objects->odb; 348 - the_repository->objects->odb = new_odb; 349 - return new_odb->next; 354 + source->disable_ref_updates = 1; 355 + source->will_destroy = will_destroy; 356 + source->next = odb->sources; 357 + odb->sources = source; 358 + return source->next; 350 359 } 351 360 352 - static void free_object_directory(struct object_directory *odb) 361 + static void free_object_directory(struct odb_source *source) 353 362 { 354 - free(odb->path); 355 - odb_clear_loose_cache(odb); 356 - loose_object_map_clear(&odb->loose_map); 357 - free(odb); 363 + free(source->path); 364 + odb_clear_loose_cache(source); 365 + loose_object_map_clear(&source->loose_map); 366 + free(source); 358 367 } 359 368 360 - void restore_primary_odb(struct object_directory *restore_odb, const char *old_path) 369 + void odb_restore_primary_source(struct object_database *odb, 370 + struct odb_source *restore_source, 371 + const char *old_path) 361 372 { 362 - struct object_directory *cur_odb = the_repository->objects->odb; 373 + struct odb_source *cur_source = odb->sources; 363 374 364 - if (strcmp(old_path, cur_odb->path)) 375 + if (strcmp(old_path, cur_source->path)) 365 376 BUG("expected %s as primary object store; found %s", 366 - old_path, cur_odb->path); 377 + old_path, cur_source->path); 367 378 368 - if (cur_odb->next != restore_odb) 379 + if (cur_source->next != restore_source) 369 380 BUG("we expect the old primary object store to be the first alternate"); 370 381 371 - the_repository->objects->odb = restore_odb; 372 - free_object_directory(cur_odb); 382 + odb->sources = restore_source; 383 + free_object_directory(cur_source); 373 384 } 374 385 375 - /* 376 - * Compute the exact path an alternate is at and returns it. In case of 377 - * error NULL is returned and the human readable error is added to `err` 378 - * `path` may be relative and should point to $GIT_DIR. 379 - * `err` must not be null. 380 - */ 381 386 char *compute_alternate_path(const char *path, struct strbuf *err) 382 387 { 383 388 char *ref_git = NULL; ··· 442 447 return ref_git; 443 448 } 444 449 445 - struct object_directory *find_odb(struct repository *r, const char *obj_dir) 450 + struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir) 446 451 { 447 - struct object_directory *odb; 452 + struct odb_source *source; 448 453 char *obj_dir_real = real_pathdup(obj_dir, 1); 449 454 struct strbuf odb_path_real = STRBUF_INIT; 450 455 451 - prepare_alt_odb(r); 452 - for (odb = r->objects->odb; odb; odb = odb->next) { 453 - strbuf_realpath(&odb_path_real, odb->path, 1); 456 + odb_prepare_alternates(odb); 457 + for (source = odb->sources; source; source = source->next) { 458 + strbuf_realpath(&odb_path_real, source->path, 1); 454 459 if (!strcmp(obj_dir_real, odb_path_real.buf)) 455 460 break; 456 461 } ··· 458 463 free(obj_dir_real); 459 464 strbuf_release(&odb_path_real); 460 465 461 - if (!odb) 466 + if (!source) 462 467 die(_("could not find object directory matching %s"), obj_dir); 463 - return odb; 468 + return source; 464 469 } 465 470 466 - static void fill_alternate_refs_command(struct child_process *cmd, 471 + void odb_add_submodule_source_by_path(struct object_database *odb, 472 + const char *path) 473 + { 474 + string_list_insert(&odb->submodule_source_paths, path); 475 + } 476 + 477 + static void fill_alternate_refs_command(struct repository *repo, 478 + struct child_process *cmd, 467 479 const char *repo_path) 468 480 { 469 481 const char *value; 470 482 471 - if (!git_config_get_value("core.alternateRefsCommand", &value)) { 483 + if (!repo_config_get_value(repo, "core.alternateRefsCommand", &value)) { 472 484 cmd->use_shell = 1; 473 485 474 486 strvec_push(&cmd->args, value); ··· 480 492 strvec_push(&cmd->args, "for-each-ref"); 481 493 strvec_push(&cmd->args, "--format=%(objectname)"); 482 494 483 - if (!git_config_get_value("core.alternateRefsPrefixes", &value)) { 495 + if (!repo_config_get_value(repo, "core.alternateRefsPrefixes", &value)) { 484 496 strvec_push(&cmd->args, "--"); 485 497 strvec_split(&cmd->args, value); 486 498 } ··· 490 502 cmd->out = -1; 491 503 } 492 504 493 - static void read_alternate_refs(const char *path, 494 - alternate_ref_fn *cb, 495 - void *data) 505 + static void read_alternate_refs(struct repository *repo, 506 + const char *path, 507 + odb_for_each_alternate_ref_fn *cb, 508 + void *payload) 496 509 { 497 510 struct child_process cmd = CHILD_PROCESS_INIT; 498 511 struct strbuf line = STRBUF_INIT; 499 512 FILE *fh; 500 513 501 - fill_alternate_refs_command(&cmd, path); 514 + fill_alternate_refs_command(repo, &cmd, path); 502 515 503 516 if (start_command(&cmd)) 504 517 return; ··· 508 521 struct object_id oid; 509 522 const char *p; 510 523 511 - if (parse_oid_hex(line.buf, &oid, &p) || *p) { 524 + if (parse_oid_hex_algop(line.buf, &oid, &p, repo->hash_algo) || *p) { 512 525 warning(_("invalid line while parsing alternate refs: %s"), 513 526 line.buf); 514 527 break; 515 528 } 516 529 517 - cb(&oid, data); 530 + cb(&oid, payload); 518 531 } 519 532 520 533 fclose(fh); ··· 523 536 } 524 537 525 538 struct alternate_refs_data { 526 - alternate_ref_fn *fn; 527 - void *data; 539 + odb_for_each_alternate_ref_fn *fn; 540 + void *payload; 528 541 }; 529 542 530 - static int refs_from_alternate_cb(struct object_directory *e, 531 - void *data) 543 + static int refs_from_alternate_cb(struct odb_source *alternate, 544 + void *payload) 532 545 { 533 546 struct strbuf path = STRBUF_INIT; 534 547 size_t base_len; 535 - struct alternate_refs_data *cb = data; 548 + struct alternate_refs_data *cb = payload; 536 549 537 - if (!strbuf_realpath(&path, e->path, 0)) 550 + if (!strbuf_realpath(&path, alternate->path, 0)) 538 551 goto out; 539 552 if (!strbuf_strip_suffix(&path, "/objects")) 540 553 goto out; ··· 546 559 goto out; 547 560 strbuf_setlen(&path, base_len); 548 561 549 - read_alternate_refs(path.buf, cb->fn, cb->data); 562 + read_alternate_refs(alternate->odb->repo, path.buf, cb->fn, cb->payload); 550 563 551 564 out: 552 565 strbuf_release(&path); 553 566 return 0; 554 567 } 555 568 556 - void for_each_alternate_ref(alternate_ref_fn fn, void *data) 569 + void odb_for_each_alternate_ref(struct object_database *odb, 570 + odb_for_each_alternate_ref_fn cb, void *payload) 557 571 { 558 - struct alternate_refs_data cb; 559 - cb.fn = fn; 560 - cb.data = data; 561 - foreach_alt_odb(refs_from_alternate_cb, &cb); 572 + struct alternate_refs_data data; 573 + data.fn = cb; 574 + data.payload = payload; 575 + odb_for_each_alternate(odb, refs_from_alternate_cb, &data); 562 576 } 563 577 564 - int foreach_alt_odb(alt_odb_fn fn, void *cb) 578 + int odb_for_each_alternate(struct object_database *odb, 579 + odb_for_each_alternate_fn cb, void *payload) 565 580 { 566 - struct object_directory *ent; 581 + struct odb_source *alternate; 567 582 int r = 0; 568 583 569 - prepare_alt_odb(the_repository); 570 - for (ent = the_repository->objects->odb->next; ent; ent = ent->next) { 571 - r = fn(ent, cb); 584 + odb_prepare_alternates(odb); 585 + for (alternate = odb->sources->next; alternate; alternate = alternate->next) { 586 + r = cb(alternate, payload); 572 587 if (r) 573 588 break; 574 589 } 575 590 return r; 576 591 } 577 592 578 - void prepare_alt_odb(struct repository *r) 593 + void odb_prepare_alternates(struct object_database *odb) 579 594 { 580 - if (r->objects->loaded_alternates) 595 + if (odb->loaded_alternates) 581 596 return; 582 597 583 - link_alt_odb_entries(r, r->objects->alternate_db, PATH_SEP, NULL, 0); 598 + link_alt_odb_entries(odb, odb->alternate_db, PATH_SEP, NULL, 0); 584 599 585 - read_info_alternates(r, r->objects->odb->path, 0); 586 - r->objects->loaded_alternates = 1; 600 + read_info_alternates(odb, odb->sources->path, 0); 601 + odb->loaded_alternates = 1; 587 602 } 588 603 589 - int has_alt_odb(struct repository *r) 604 + int odb_has_alternates(struct object_database *odb) 590 605 { 591 - prepare_alt_odb(r); 592 - return !!r->objects->odb->next; 606 + odb_prepare_alternates(odb); 607 + return !!odb->sources->next; 593 608 } 594 609 595 610 int obj_read_use_lock = 0; ··· 615 630 616 631 int fetch_if_missing = 1; 617 632 618 - static int do_oid_object_info_extended(struct repository *r, 633 + static int register_all_submodule_sources(struct object_database *odb) 634 + { 635 + int ret = odb->submodule_source_paths.nr; 636 + 637 + for (size_t i = 0; i < odb->submodule_source_paths.nr; i++) 638 + odb_add_to_alternates_memory(odb, 639 + odb->submodule_source_paths.items[i].string); 640 + if (ret) { 641 + string_list_clear(&odb->submodule_source_paths, 0); 642 + trace2_data_intmax("submodule", odb->repo, 643 + "register_all_submodule_sources/registered", ret); 644 + if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0)) 645 + BUG("register_all_submodule_sources() called"); 646 + } 647 + return ret; 648 + } 649 + 650 + static int do_oid_object_info_extended(struct object_database *odb, 619 651 const struct object_id *oid, 620 652 struct object_info *oi, unsigned flags) 621 653 { ··· 628 660 629 661 630 662 if (flags & OBJECT_INFO_LOOKUP_REPLACE) 631 - real = lookup_replace_object(r, oid); 663 + real = lookup_replace_object(odb->repo, oid); 632 664 633 665 if (is_null_oid(real)) 634 666 return -1; ··· 636 668 if (!oi) 637 669 oi = &blank_oi; 638 670 639 - co = find_cached_object(r->objects, real); 671 + co = find_cached_object(odb, real); 640 672 if (co) { 641 673 if (oi->typep) 642 674 *(oi->typep) = co->type; ··· 645 677 if (oi->disk_sizep) 646 678 *(oi->disk_sizep) = 0; 647 679 if (oi->delta_base_oid) 648 - oidclr(oi->delta_base_oid, the_repository->hash_algo); 680 + oidclr(oi->delta_base_oid, odb->repo->hash_algo); 649 681 if (oi->contentp) 650 682 *oi->contentp = xmemdupz(co->buf, co->size); 651 683 oi->whence = OI_CACHED; ··· 653 685 } 654 686 655 687 while (1) { 656 - if (find_pack_entry(r, real, &e)) 688 + if (find_pack_entry(odb->repo, real, &e)) 657 689 break; 658 690 659 691 /* Most likely it's a loose object. */ 660 - if (!loose_object_info(r, real, oi, flags)) 692 + if (!loose_object_info(odb->repo, real, oi, flags)) 661 693 return 0; 662 694 663 695 /* Not a loose object; someone else may have just packed it. */ 664 696 if (!(flags & OBJECT_INFO_QUICK)) { 665 - reprepare_packed_git(r); 666 - if (find_pack_entry(r, real, &e)) 697 + reprepare_packed_git(odb->repo); 698 + if (find_pack_entry(odb->repo, real, &e)) 667 699 break; 668 700 } 669 701 670 702 /* 671 - * If r is the_repository, this might be an attempt at 672 - * accessing a submodule object as if it were in the_repository 673 - * (having called add_submodule_odb() on that submodule's ODB). 674 - * If any such ODBs exist, register them and try again. 703 + * This might be an attempt at accessing a submodule object as 704 + * if it were in main object store (having called 705 + * `odb_add_submodule_source_by_path()` on that submodule's 706 + * ODB). If any such ODBs exist, register them and try again. 675 707 */ 676 - if (r == the_repository && 677 - register_all_submodule_odb_as_alternates()) 708 + if (register_all_submodule_sources(odb)) 678 709 /* We added some alternates; retry */ 679 710 continue; 680 711 681 712 /* Check if it is a missing object */ 682 - if (fetch_if_missing && repo_has_promisor_remote(r) && 713 + if (fetch_if_missing && repo_has_promisor_remote(odb->repo) && 683 714 !already_retried && 684 715 !(flags & OBJECT_INFO_SKIP_FETCH_OBJECT)) { 685 - promisor_remote_get_direct(r, real, 1); 716 + promisor_remote_get_direct(odb->repo, real, 1); 686 717 already_retried = 1; 687 718 continue; 688 719 } ··· 692 723 if ((flags & OBJECT_INFO_LOOKUP_REPLACE) && !oideq(real, oid)) 693 724 die(_("replacement %s not found for %s"), 694 725 oid_to_hex(real), oid_to_hex(oid)); 695 - if ((p = has_packed_and_bad(r, real))) 726 + if ((p = has_packed_and_bad(odb->repo, real))) 696 727 die(_("packed object %s (stored in %s) is corrupt"), 697 728 oid_to_hex(real), p->pack_name); 698 729 } ··· 705 736 * information below, so return early. 706 737 */ 707 738 return 0; 708 - rtype = packed_object_info(r, e.p, e.offset, oi); 739 + rtype = packed_object_info(odb->repo, e.p, e.offset, oi); 709 740 if (rtype < 0) { 710 741 mark_bad_packed_object(e.p, real); 711 - return do_oid_object_info_extended(r, real, oi, 0); 742 + return do_oid_object_info_extended(odb, real, oi, 0); 712 743 } else if (oi->whence == OI_PACKED) { 713 744 oi->u.packed.offset = e.offset; 714 745 oi->u.packed.pack = e.p; ··· 732 763 void *content; 733 764 int ret; 734 765 735 - if (repo_oid_to_algop(r, input_oid, the_hash_algo, &oid)) { 766 + if (repo_oid_to_algop(r, input_oid, r->hash_algo, &oid)) { 736 767 if (do_die) 737 768 die(_("missing mapping of %s to %s"), 738 - oid_to_hex(input_oid), the_hash_algo->name); 769 + oid_to_hex(input_oid), r->hash_algo->name); 739 770 return -1; 740 771 } 741 772 ··· 756 787 oi = &new_oi; 757 788 } 758 789 759 - ret = oid_object_info_extended(r, &oid, oi, flags); 790 + ret = odb_read_object_info_extended(r->objects, &oid, oi, flags); 760 791 if (ret) 761 792 return -1; 762 793 if (oi == input_oi) ··· 766 797 struct strbuf outbuf = STRBUF_INIT; 767 798 768 799 if (type != OBJ_BLOB) { 769 - ret = convert_object_file(the_repository, &outbuf, 770 - the_hash_algo, input_algo, 800 + ret = convert_object_file(r, &outbuf, 801 + r->hash_algo, input_algo, 771 802 content, size, type, !do_die); 772 803 free(content); 773 804 if (ret == -1) ··· 799 830 return ret; 800 831 } 801 832 802 - int oid_object_info_extended(struct repository *r, const struct object_id *oid, 803 - struct object_info *oi, unsigned flags) 833 + int odb_read_object_info_extended(struct object_database *odb, 834 + const struct object_id *oid, 835 + struct object_info *oi, 836 + unsigned flags) 804 837 { 805 838 int ret; 806 839 807 - if (oid->algo && (hash_algo_by_ptr(r->hash_algo) != oid->algo)) 808 - return oid_object_info_convert(r, oid, oi, flags); 840 + if (oid->algo && (hash_algo_by_ptr(odb->repo->hash_algo) != oid->algo)) 841 + return oid_object_info_convert(odb->repo, oid, oi, flags); 809 842 810 843 obj_read_lock(); 811 - ret = do_oid_object_info_extended(r, oid, oi, flags); 844 + ret = do_oid_object_info_extended(odb, oid, oi, flags); 812 845 obj_read_unlock(); 813 846 return ret; 814 847 } 815 848 816 849 817 850 /* returns enum object_type or negative */ 818 - int oid_object_info(struct repository *r, 819 - const struct object_id *oid, 820 - unsigned long *sizep) 851 + int odb_read_object_info(struct object_database *odb, 852 + const struct object_id *oid, 853 + unsigned long *sizep) 821 854 { 822 855 enum object_type type; 823 856 struct object_info oi = OBJECT_INFO_INIT; 824 857 825 858 oi.typep = &type; 826 859 oi.sizep = sizep; 827 - if (oid_object_info_extended(r, oid, &oi, 828 - OBJECT_INFO_LOOKUP_REPLACE) < 0) 860 + if (odb_read_object_info_extended(odb, oid, &oi, 861 + OBJECT_INFO_LOOKUP_REPLACE) < 0) 829 862 return -1; 830 863 return type; 831 864 } 832 865 833 - int pretend_object_file(struct repository *repo, 834 - void *buf, unsigned long len, enum object_type type, 835 - struct object_id *oid) 866 + int odb_pretend_object(struct object_database *odb, 867 + void *buf, unsigned long len, enum object_type type, 868 + struct object_id *oid) 836 869 { 837 870 struct cached_object_entry *co; 838 871 char *co_buf; 839 872 840 - hash_object_file(repo->hash_algo, buf, len, type, oid); 841 - if (has_object(repo, oid, 0) || 842 - find_cached_object(repo->objects, oid)) 873 + hash_object_file(odb->repo->hash_algo, buf, len, type, oid); 874 + if (odb_has_object(odb, oid, 0) || 875 + find_cached_object(odb, oid)) 843 876 return 0; 844 877 845 - ALLOC_GROW(repo->objects->cached_objects, 846 - repo->objects->cached_object_nr + 1, repo->objects->cached_object_alloc); 847 - co = &repo->objects->cached_objects[repo->objects->cached_object_nr++]; 878 + ALLOC_GROW(odb->cached_objects, 879 + odb->cached_object_nr + 1, odb->cached_object_alloc); 880 + co = &odb->cached_objects[odb->cached_object_nr++]; 848 881 co->value.size = len; 849 882 co->value.type = type; 850 883 co_buf = xmalloc(len); ··· 854 887 return 0; 855 888 } 856 889 857 - /* 858 - * This function dies on corrupt objects; the callers who want to 859 - * deal with them should arrange to call oid_object_info_extended() and give 860 - * error messages themselves. 861 - */ 862 - void *repo_read_object_file(struct repository *r, 863 - const struct object_id *oid, 864 - enum object_type *type, 865 - 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) 866 894 { 867 895 struct object_info oi = OBJECT_INFO_INIT; 868 896 unsigned flags = OBJECT_INFO_DIE_IF_CORRUPT | OBJECT_INFO_LOOKUP_REPLACE; ··· 871 899 oi.typep = type; 872 900 oi.sizep = size; 873 901 oi.contentp = &data; 874 - if (oid_object_info_extended(r, oid, &oi, flags)) 902 + if (odb_read_object_info_extended(odb, oid, &oi, flags)) 875 903 return NULL; 876 904 877 905 return data; 878 906 } 879 907 880 - void *read_object_with_reference(struct repository *r, 881 - const struct object_id *oid, 882 - enum object_type required_type, 883 - unsigned long *size, 884 - struct object_id *actual_oid_return) 908 + void *odb_read_object_peeled(struct object_database *odb, 909 + const struct object_id *oid, 910 + enum object_type required_type, 911 + unsigned long *size, 912 + struct object_id *actual_oid_return) 885 913 { 886 914 enum object_type type; 887 915 void *buffer; ··· 893 921 int ref_length = -1; 894 922 const char *ref_type = NULL; 895 923 896 - buffer = repo_read_object_file(r, &actual_oid, &type, &isize); 924 + buffer = odb_read_object(odb, &actual_oid, &type, &isize); 897 925 if (!buffer) 898 926 return NULL; 899 927 if (type == required_type) { ··· 913 941 } 914 942 ref_length = strlen(ref_type); 915 943 916 - if (ref_length + the_hash_algo->hexsz > isize || 944 + if (ref_length + odb->repo->hash_algo->hexsz > isize || 917 945 memcmp(buffer, ref_type, ref_length) || 918 - get_oid_hex((char *) buffer + ref_length, &actual_oid)) { 946 + get_oid_hex_algop((char *) buffer + ref_length, &actual_oid, 947 + odb->repo->hash_algo)) { 919 948 free(buffer); 920 949 return NULL; 921 950 } ··· 925 954 } 926 955 } 927 956 928 - int has_object(struct repository *r, const struct object_id *oid, 957 + int odb_has_object(struct object_database *odb, const struct object_id *oid, 929 958 unsigned flags) 930 959 { 931 960 unsigned object_info_flags = 0; ··· 937 966 if (!(flags & HAS_OBJECT_FETCH_PROMISOR)) 938 967 object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT; 939 968 940 - return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0; 969 + return odb_read_object_info_extended(odb, oid, NULL, object_info_flags) >= 0; 941 970 } 942 971 943 - void assert_oid_type(const struct object_id *oid, enum object_type expect) 972 + void odb_assert_oid_type(struct object_database *odb, 973 + const struct object_id *oid, enum object_type expect) 944 974 { 945 - enum object_type type = oid_object_info(the_repository, oid, NULL); 975 + enum object_type type = odb_read_object_info(odb, oid, NULL); 946 976 if (type < 0) 947 977 die(_("%s is not a valid object"), oid_to_hex(oid)); 948 978 if (type != expect) ··· 950 980 type_name(expect)); 951 981 } 952 982 953 - struct raw_object_store *raw_object_store_new(void) 983 + struct object_database *odb_new(struct repository *repo) 954 984 { 955 - struct raw_object_store *o = xmalloc(sizeof(*o)); 985 + struct object_database *o = xmalloc(sizeof(*o)); 956 986 957 987 memset(o, 0, sizeof(*o)); 988 + o->repo = repo; 958 989 INIT_LIST_HEAD(&o->packed_git_mru); 959 990 hashmap_init(&o->pack_map, pack_map_entry_cmp, NULL, 0); 960 991 pthread_mutex_init(&o->replace_mutex, NULL); 992 + string_list_init_dup(&o->submodule_source_paths); 961 993 return o; 962 994 } 963 995 964 - static void free_object_directories(struct raw_object_store *o) 996 + static void free_object_directories(struct object_database *o) 965 997 { 966 - while (o->odb) { 967 - struct object_directory *next; 998 + while (o->sources) { 999 + struct odb_source *next; 968 1000 969 - next = o->odb->next; 970 - free_object_directory(o->odb); 971 - o->odb = next; 1001 + next = o->sources->next; 1002 + free_object_directory(o->sources); 1003 + o->sources = next; 972 1004 } 973 - kh_destroy_odb_path_map(o->odb_by_path); 974 - o->odb_by_path = NULL; 1005 + kh_destroy_odb_path_map(o->source_by_path); 1006 + o->source_by_path = NULL; 975 1007 } 976 1008 977 - void raw_object_store_clear(struct raw_object_store *o) 1009 + void odb_clear(struct object_database *o) 978 1010 { 979 1011 FREE_AND_NULL(o->alternate_db); 980 1012 ··· 986 1018 o->commit_graph_attempted = 0; 987 1019 988 1020 free_object_directories(o); 989 - o->odb_tail = NULL; 1021 + o->sources_tail = NULL; 990 1022 o->loaded_alternates = 0; 991 1023 992 1024 for (size_t i = 0; i < o->cached_object_nr; i++) ··· 1007 1039 o->packed_git = NULL; 1008 1040 1009 1041 hashmap_clear(&o->pack_map); 1042 + string_list_clear(&o->submodule_source_paths, 0); 1010 1043 }
-338
object-store.h
··· 1 - #ifndef OBJECT_STORE_H 2 - #define OBJECT_STORE_H 3 - 4 - #include "hashmap.h" 5 - #include "object.h" 6 - #include "list.h" 7 - #include "oidset.h" 8 - #include "oidmap.h" 9 - #include "thread-utils.h" 10 - 11 - struct oidmap; 12 - struct oidtree; 13 - struct strbuf; 14 - struct repository; 15 - 16 - struct object_directory { 17 - struct object_directory *next; 18 - 19 - /* 20 - * Used to store the results of readdir(3) calls when we are OK 21 - * sacrificing accuracy due to races for speed. That includes 22 - * object existence with OBJECT_INFO_QUICK, as well as 23 - * our search for unique abbreviated hashes. Don't use it for tasks 24 - * requiring greater accuracy! 25 - * 26 - * Be sure to call odb_load_loose_cache() before using. 27 - */ 28 - uint32_t loose_objects_subdir_seen[8]; /* 256 bits */ 29 - struct oidtree *loose_objects_cache; 30 - 31 - /* Map between object IDs for loose objects. */ 32 - struct loose_object_map *loose_map; 33 - 34 - /* 35 - * This is a temporary object store created by the tmp_objdir 36 - * facility. Disable ref updates since the objects in the store 37 - * might be discarded on rollback. 38 - */ 39 - int disable_ref_updates; 40 - 41 - /* 42 - * This object store is ephemeral, so there is no need to fsync. 43 - */ 44 - int will_destroy; 45 - 46 - /* 47 - * Path to the alternative object store. If this is a relative path, 48 - * it is relative to the current working directory. 49 - */ 50 - char *path; 51 - }; 52 - 53 - void prepare_alt_odb(struct repository *r); 54 - int has_alt_odb(struct repository *r); 55 - char *compute_alternate_path(const char *path, struct strbuf *err); 56 - struct object_directory *find_odb(struct repository *r, const char *obj_dir); 57 - typedef int alt_odb_fn(struct object_directory *, void *); 58 - int foreach_alt_odb(alt_odb_fn, void*); 59 - typedef void alternate_ref_fn(const struct object_id *oid, void *); 60 - void for_each_alternate_ref(alternate_ref_fn, void *); 61 - 62 - /* 63 - * Add the directory to the on-disk alternates file; the new entry will also 64 - * take effect in the current process. 65 - */ 66 - void add_to_alternates_file(const char *dir); 67 - 68 - /* 69 - * Add the directory to the in-memory list of alternates (along with any 70 - * recursive alternates it points to), but do not modify the on-disk alternates 71 - * file. 72 - */ 73 - void add_to_alternates_memory(const char *dir); 74 - 75 - /* 76 - * Replace the current writable object directory with the specified temporary 77 - * object directory; returns the former primary object directory. 78 - */ 79 - struct object_directory *set_temporary_primary_odb(const char *dir, int will_destroy); 80 - 81 - /* 82 - * Restore a previous ODB replaced by set_temporary_main_odb. 83 - */ 84 - void restore_primary_odb(struct object_directory *restore_odb, const char *old_path); 85 - 86 - struct packed_git; 87 - struct multi_pack_index; 88 - struct cached_object_entry; 89 - 90 - struct raw_object_store { 91 - /* 92 - * Set of all object directories; the main directory is first (and 93 - * cannot be NULL after initialization). Subsequent directories are 94 - * alternates. 95 - */ 96 - struct object_directory *odb; 97 - struct object_directory **odb_tail; 98 - struct kh_odb_path_map *odb_by_path; 99 - 100 - int loaded_alternates; 101 - 102 - /* 103 - * A list of alternate object directories loaded from the environment; 104 - * this should not generally need to be accessed directly, but will 105 - * populate the "odb" list when prepare_alt_odb() is run. 106 - */ 107 - char *alternate_db; 108 - 109 - /* 110 - * Objects that should be substituted by other objects 111 - * (see git-replace(1)). 112 - */ 113 - struct oidmap replace_map; 114 - unsigned replace_map_initialized : 1; 115 - pthread_mutex_t replace_mutex; /* protect object replace functions */ 116 - 117 - struct commit_graph *commit_graph; 118 - unsigned commit_graph_attempted : 1; /* if loading has been attempted */ 119 - 120 - /* 121 - * private data 122 - * 123 - * should only be accessed directly by packfile.c and midx.c 124 - */ 125 - struct multi_pack_index *multi_pack_index; 126 - 127 - /* 128 - * private data 129 - * 130 - * should only be accessed directly by packfile.c 131 - */ 132 - 133 - struct packed_git *packed_git; 134 - /* A most-recently-used ordered version of the packed_git list. */ 135 - struct list_head packed_git_mru; 136 - 137 - struct { 138 - struct packed_git **packs; 139 - unsigned flags; 140 - } kept_pack_cache; 141 - 142 - /* 143 - * This is meant to hold a *small* number of objects that you would 144 - * want repo_read_object_file() to be able to return, but yet you do not want 145 - * to write them into the object store (e.g. a browse-only 146 - * application). 147 - */ 148 - struct cached_object_entry *cached_objects; 149 - size_t cached_object_nr, cached_object_alloc; 150 - 151 - /* 152 - * A map of packfiles to packed_git structs for tracking which 153 - * packs have been loaded already. 154 - */ 155 - struct hashmap pack_map; 156 - 157 - /* 158 - * A fast, rough count of the number of objects in the repository. 159 - * These two fields are not meant for direct access. Use 160 - * repo_approximate_object_count() instead. 161 - */ 162 - unsigned long approximate_object_count; 163 - unsigned approximate_object_count_valid : 1; 164 - 165 - /* 166 - * Whether packed_git has already been populated with this repository's 167 - * packs. 168 - */ 169 - unsigned packed_git_initialized : 1; 170 - }; 171 - 172 - struct raw_object_store *raw_object_store_new(void); 173 - void raw_object_store_clear(struct raw_object_store *o); 174 - 175 - /* 176 - * Create a temporary file rooted in the object database directory, or 177 - * die on failure. The filename is taken from "pattern", which should have the 178 - * usual "XXXXXX" trailer, and the resulting filename is written into the 179 - * "template" buffer. Returns the open descriptor. 180 - */ 181 - int odb_mkstemp(struct strbuf *temp_filename, const char *pattern); 182 - 183 - void *repo_read_object_file(struct repository *r, 184 - const struct object_id *oid, 185 - enum object_type *type, 186 - unsigned long *size); 187 - 188 - /* Read and unpack an object file into memory, write memory to an object file */ 189 - int oid_object_info(struct repository *r, const struct object_id *, unsigned long *); 190 - 191 - /* 192 - * Add an object file to the in-memory object store, without writing it 193 - * to disk. 194 - * 195 - * Callers are responsible for calling write_object_file to record the 196 - * object in persistent storage before writing any other new objects 197 - * that reference it. 198 - */ 199 - int pretend_object_file(struct repository *repo, 200 - void *buf, unsigned long len, enum object_type type, 201 - struct object_id *oid); 202 - 203 - struct object_info { 204 - /* Request */ 205 - enum object_type *typep; 206 - unsigned long *sizep; 207 - off_t *disk_sizep; 208 - struct object_id *delta_base_oid; 209 - void **contentp; 210 - 211 - /* Response */ 212 - enum { 213 - OI_CACHED, 214 - OI_LOOSE, 215 - OI_PACKED, 216 - OI_DBCACHED 217 - } whence; 218 - union { 219 - /* 220 - * struct { 221 - * ... Nothing to expose in this case 222 - * } cached; 223 - * struct { 224 - * ... Nothing to expose in this case 225 - * } loose; 226 - */ 227 - struct { 228 - struct packed_git *pack; 229 - off_t offset; 230 - unsigned int is_delta; 231 - } packed; 232 - } u; 233 - }; 234 - 235 - /* 236 - * Initializer for a "struct object_info" that wants no items. You may 237 - * also memset() the memory to all-zeroes. 238 - */ 239 - #define OBJECT_INFO_INIT { 0 } 240 - 241 - /* Invoke lookup_replace_object() on the given hash */ 242 - #define OBJECT_INFO_LOOKUP_REPLACE 1 243 - /* Do not retry packed storage after checking packed and loose storage */ 244 - #define OBJECT_INFO_QUICK 8 245 - /* 246 - * Do not attempt to fetch the object if missing (even if fetch_is_missing is 247 - * nonzero). 248 - */ 249 - #define OBJECT_INFO_SKIP_FETCH_OBJECT 16 250 - /* 251 - * This is meant for bulk prefetching of missing blobs in a partial 252 - * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK 253 - */ 254 - #define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK) 255 - 256 - /* Die if object corruption (not just an object being missing) was detected. */ 257 - #define OBJECT_INFO_DIE_IF_CORRUPT 32 258 - 259 - int oid_object_info_extended(struct repository *r, 260 - const struct object_id *, 261 - struct object_info *, unsigned flags); 262 - 263 - enum { 264 - /* Retry packed storage after checking packed and loose storage */ 265 - HAS_OBJECT_RECHECK_PACKED = (1 << 0), 266 - /* Allow fetching the object in case the repository has a promisor remote. */ 267 - HAS_OBJECT_FETCH_PROMISOR = (1 << 1), 268 - }; 269 - 270 - /* 271 - * Returns 1 if the object exists. This function will not lazily fetch objects 272 - * in a partial clone by default. 273 - */ 274 - int has_object(struct repository *r, const struct object_id *oid, 275 - unsigned flags); 276 - 277 - void assert_oid_type(const struct object_id *oid, enum object_type expect); 278 - 279 - /* 280 - * Enabling the object read lock allows multiple threads to safely call the 281 - * following functions in parallel: repo_read_object_file(), 282 - * read_object_with_reference(), oid_object_info() and oid_object_info_extended(). 283 - * 284 - * obj_read_lock() and obj_read_unlock() may also be used to protect other 285 - * section which cannot execute in parallel with object reading. Since the used 286 - * lock is a recursive mutex, these sections can even contain calls to object 287 - * reading functions. However, beware that in these cases zlib inflation won't 288 - * be performed in parallel, losing performance. 289 - * 290 - * TODO: oid_object_info_extended()'s call stack has a recursive behavior. If 291 - * any of its callees end up calling it, this recursive call won't benefit from 292 - * parallel inflation. 293 - */ 294 - void enable_obj_read_lock(void); 295 - void disable_obj_read_lock(void); 296 - 297 - extern int obj_read_use_lock; 298 - extern pthread_mutex_t obj_read_mutex; 299 - 300 - static inline void obj_read_lock(void) 301 - { 302 - if(obj_read_use_lock) 303 - pthread_mutex_lock(&obj_read_mutex); 304 - } 305 - 306 - static inline void obj_read_unlock(void) 307 - { 308 - if(obj_read_use_lock) 309 - pthread_mutex_unlock(&obj_read_mutex); 310 - } 311 - /* Flags for for_each_*_object(). */ 312 - enum for_each_object_flags { 313 - /* Iterate only over local objects, not alternates. */ 314 - FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0), 315 - 316 - /* Only iterate over packs obtained from the promisor remote. */ 317 - FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1), 318 - 319 - /* 320 - * Visit objects within a pack in packfile order rather than .idx order 321 - */ 322 - FOR_EACH_OBJECT_PACK_ORDER = (1<<2), 323 - 324 - /* Only iterate over packs that are not marked as kept in-core. */ 325 - FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS = (1<<3), 326 - 327 - /* Only iterate over packs that do not have .keep files. */ 328 - FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4), 329 - }; 330 - 331 - 332 - void *read_object_with_reference(struct repository *r, 333 - const struct object_id *oid, 334 - enum object_type required_type, 335 - unsigned long *size, 336 - struct object_id *oid_ret); 337 - 338 - #endif /* OBJECT_STORE_H */
+4 -4
object.c
··· 214 214 struct object *o = lookup_unknown_object(r, name); 215 215 216 216 if (o->type == OBJ_NONE) { 217 - int type = oid_object_info(r, name, NULL); 217 + int type = odb_read_object_info(r->objects, name, NULL); 218 218 if (type < 0 || !object_as_type(o, type, 0)) 219 219 return PEEL_INVALID; 220 220 } ··· 315 315 } 316 316 317 317 if ((!obj || obj->type == OBJ_BLOB) && 318 - oid_object_info(r, oid, NULL) == OBJ_BLOB) { 318 + odb_read_object_info(r->objects, oid, NULL) == OBJ_BLOB) { 319 319 if (!skip_hash && stream_object_signature(r, repl) < 0) { 320 320 error(_("hash mismatch %s"), oid_to_hex(oid)); 321 321 return NULL; ··· 331 331 */ 332 332 if (skip_hash && discard_tree && 333 333 (!obj || obj->type == OBJ_TREE) && 334 - oid_object_info(r, oid, NULL) == OBJ_TREE) { 334 + odb_read_object_info(r->objects, oid, NULL) == OBJ_TREE) { 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) {
+473
odb.h
··· 1 + #ifndef ODB_H 2 + #define ODB_H 3 + 4 + #include "hashmap.h" 5 + #include "object.h" 6 + #include "list.h" 7 + #include "oidset.h" 8 + #include "oidmap.h" 9 + #include "string-list.h" 10 + #include "thread-utils.h" 11 + 12 + struct oidmap; 13 + struct oidtree; 14 + struct strbuf; 15 + struct repository; 16 + 17 + /* 18 + * Compute the exact path an alternate is at and returns it. In case of 19 + * error NULL is returned and the human readable error is added to `err` 20 + * `path` may be relative and should point to $GIT_DIR. 21 + * `err` must not be null. 22 + */ 23 + char *compute_alternate_path(const char *path, struct strbuf *err); 24 + 25 + /* 26 + * The source is the part of the object database that stores the actual 27 + * objects. It thus encapsulates the logic to read and write the specific 28 + * on-disk format. An object database can have multiple sources: 29 + * 30 + * - The primary source, which is typically located in "$GIT_DIR/objects". 31 + * This is where new objects are usually written to. 32 + * 33 + * - Alternate sources, which are configured via "objects/info/alternates" or 34 + * via the GIT_ALTERNATE_OBJECT_DIRECTORIES environment variable. These 35 + * alternate sources are only used to read objects. 36 + */ 37 + struct odb_source { 38 + struct odb_source *next; 39 + 40 + /* Object database that owns this object source. */ 41 + struct object_database *odb; 42 + 43 + /* 44 + * Used to store the results of readdir(3) calls when we are OK 45 + * sacrificing accuracy due to races for speed. That includes 46 + * object existence with OBJECT_INFO_QUICK, as well as 47 + * our search for unique abbreviated hashes. Don't use it for tasks 48 + * requiring greater accuracy! 49 + * 50 + * Be sure to call odb_load_loose_cache() before using. 51 + */ 52 + uint32_t loose_objects_subdir_seen[8]; /* 256 bits */ 53 + struct oidtree *loose_objects_cache; 54 + 55 + /* Map between object IDs for loose objects. */ 56 + struct loose_object_map *loose_map; 57 + 58 + /* 59 + * This is a temporary object store created by the tmp_objdir 60 + * facility. Disable ref updates since the objects in the store 61 + * might be discarded on rollback. 62 + */ 63 + int disable_ref_updates; 64 + 65 + /* 66 + * This object store is ephemeral, so there is no need to fsync. 67 + */ 68 + int will_destroy; 69 + 70 + /* 71 + * Path to the source. If this is a relative path, it is relative to 72 + * the current working directory. 73 + */ 74 + char *path; 75 + }; 76 + 77 + struct packed_git; 78 + struct multi_pack_index; 79 + struct cached_object_entry; 80 + 81 + /* 82 + * The object database encapsulates access to objects in a repository. It 83 + * manages one or more sources that store the actual objects which are 84 + * configured via alternates. 85 + */ 86 + struct object_database { 87 + /* Repository that owns this database. */ 88 + struct repository *repo; 89 + 90 + /* 91 + * Set of all object directories; the main directory is first (and 92 + * cannot be NULL after initialization). Subsequent directories are 93 + * alternates. 94 + */ 95 + struct odb_source *sources; 96 + struct odb_source **sources_tail; 97 + struct kh_odb_path_map *source_by_path; 98 + 99 + int loaded_alternates; 100 + 101 + /* 102 + * A list of alternate object directories loaded from the environment; 103 + * this should not generally need to be accessed directly, but will 104 + * populate the "sources" list when odb_prepare_alternates() is run. 105 + */ 106 + char *alternate_db; 107 + 108 + /* 109 + * Objects that should be substituted by other objects 110 + * (see git-replace(1)). 111 + */ 112 + struct oidmap replace_map; 113 + unsigned replace_map_initialized : 1; 114 + pthread_mutex_t replace_mutex; /* protect object replace functions */ 115 + 116 + struct commit_graph *commit_graph; 117 + unsigned commit_graph_attempted : 1; /* if loading has been attempted */ 118 + 119 + /* 120 + * private data 121 + * 122 + * should only be accessed directly by packfile.c and midx.c 123 + */ 124 + struct multi_pack_index *multi_pack_index; 125 + 126 + /* 127 + * private data 128 + * 129 + * should only be accessed directly by packfile.c 130 + */ 131 + 132 + struct packed_git *packed_git; 133 + /* A most-recently-used ordered version of the packed_git list. */ 134 + struct list_head packed_git_mru; 135 + 136 + struct { 137 + struct packed_git **packs; 138 + unsigned flags; 139 + } kept_pack_cache; 140 + 141 + /* 142 + * This is meant to hold a *small* number of objects that you would 143 + * want odb_read_object() to be able to return, but yet you do not want 144 + * to write them into the object store (e.g. a browse-only 145 + * application). 146 + */ 147 + struct cached_object_entry *cached_objects; 148 + size_t cached_object_nr, cached_object_alloc; 149 + 150 + /* 151 + * A map of packfiles to packed_git structs for tracking which 152 + * packs have been loaded already. 153 + */ 154 + struct hashmap pack_map; 155 + 156 + /* 157 + * A fast, rough count of the number of objects in the repository. 158 + * These two fields are not meant for direct access. Use 159 + * repo_approximate_object_count() instead. 160 + */ 161 + unsigned long approximate_object_count; 162 + unsigned approximate_object_count_valid : 1; 163 + 164 + /* 165 + * Whether packed_git has already been populated with this repository's 166 + * packs. 167 + */ 168 + unsigned packed_git_initialized : 1; 169 + 170 + /* 171 + * Submodule source paths that will be added as additional sources to 172 + * allow lookup of submodule objects via the main object database. 173 + */ 174 + struct string_list submodule_source_paths; 175 + }; 176 + 177 + struct object_database *odb_new(struct repository *repo); 178 + void odb_clear(struct object_database *o); 179 + 180 + /* 181 + * Find source by its object directory path. Dies in case the source couldn't 182 + * be found. 183 + */ 184 + struct odb_source *odb_find_source(struct object_database *odb, const char *obj_dir); 185 + 186 + /* 187 + * Replace the current writable object directory with the specified temporary 188 + * object directory; returns the former primary source. 189 + */ 190 + struct odb_source *odb_set_temporary_primary_source(struct object_database *odb, 191 + const char *dir, int will_destroy); 192 + 193 + /* 194 + * Restore the primary source that was previously replaced by 195 + * `odb_set_temporary_primary_source()`. 196 + */ 197 + void odb_restore_primary_source(struct object_database *odb, 198 + struct odb_source *restore_source, 199 + const char *old_path); 200 + 201 + /* 202 + * Call odb_add_submodule_source_by_path() to add the submodule at the given 203 + * path to a list. The object stores of all submodules in that list will be 204 + * added as additional sources in the object store when looking up objects. 205 + */ 206 + void odb_add_submodule_source_by_path(struct object_database *odb, 207 + const char *path); 208 + 209 + /* 210 + * Iterate through all alternates of the database and execute the provided 211 + * callback function for each of them. Stop iterating once the callback 212 + * function returns a non-zero value, in which case the value is bubbled up 213 + * from the callback. 214 + */ 215 + typedef int odb_for_each_alternate_fn(struct odb_source *, void *); 216 + int odb_for_each_alternate(struct object_database *odb, 217 + odb_for_each_alternate_fn cb, void *payload); 218 + 219 + /* 220 + * Iterate through all alternates of the database and yield their respective 221 + * references. 222 + */ 223 + typedef void odb_for_each_alternate_ref_fn(const struct object_id *oid, void *); 224 + void odb_for_each_alternate_ref(struct object_database *odb, 225 + odb_for_each_alternate_ref_fn cb, void *payload); 226 + 227 + /* 228 + * Create a temporary file rooted in the primary alternate's directory, or die 229 + * on failure. The filename is taken from "pattern", which should have the 230 + * usual "XXXXXX" trailer, and the resulting filename is written into the 231 + * "template" buffer. Returns the open descriptor. 232 + */ 233 + int odb_mkstemp(struct object_database *odb, 234 + struct strbuf *temp_filename, const char *pattern); 235 + 236 + /* 237 + * Prepare alternate object sources for the given database by reading 238 + * "objects/info/alternates" and opening the respective sources. 239 + */ 240 + void odb_prepare_alternates(struct object_database *odb); 241 + 242 + /* 243 + * Check whether the object database has any alternates. The primary object 244 + * source does not count as alternate. 245 + */ 246 + int odb_has_alternates(struct object_database *odb); 247 + 248 + /* 249 + * Add the directory to the on-disk alternates file; the new entry will also 250 + * take effect in the current process. 251 + */ 252 + void odb_add_to_alternates_file(struct object_database *odb, 253 + const char *dir); 254 + 255 + /* 256 + * Add the directory to the in-memory list of alternate sources (along with any 257 + * recursive alternates it points to), but do not modify the on-disk alternates 258 + * file. 259 + */ 260 + void odb_add_to_alternates_memory(struct object_database *odb, 261 + const char *dir); 262 + 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); 276 + 277 + void *odb_read_object_peeled(struct object_database *odb, 278 + const struct object_id *oid, 279 + enum object_type required_type, 280 + unsigned long *size, 281 + struct object_id *oid_ret); 282 + 283 + /* 284 + * Add an object file to the in-memory object store, without writing it 285 + * to disk. 286 + * 287 + * Callers are responsible for calling write_object_file to record the 288 + * object in persistent storage before writing any other new objects 289 + * that reference it. 290 + */ 291 + int odb_pretend_object(struct object_database *odb, 292 + void *buf, unsigned long len, enum object_type type, 293 + struct object_id *oid); 294 + 295 + struct object_info { 296 + /* Request */ 297 + enum object_type *typep; 298 + unsigned long *sizep; 299 + off_t *disk_sizep; 300 + struct object_id *delta_base_oid; 301 + void **contentp; 302 + 303 + /* Response */ 304 + enum { 305 + OI_CACHED, 306 + OI_LOOSE, 307 + OI_PACKED, 308 + OI_DBCACHED 309 + } whence; 310 + union { 311 + /* 312 + * struct { 313 + * ... Nothing to expose in this case 314 + * } cached; 315 + * struct { 316 + * ... Nothing to expose in this case 317 + * } loose; 318 + */ 319 + struct { 320 + struct packed_git *pack; 321 + off_t offset; 322 + unsigned int is_delta; 323 + } packed; 324 + } u; 325 + }; 326 + 327 + /* 328 + * Initializer for a "struct object_info" that wants no items. You may 329 + * also memset() the memory to all-zeroes. 330 + */ 331 + #define OBJECT_INFO_INIT { 0 } 332 + 333 + /* Invoke lookup_replace_object() on the given hash */ 334 + #define OBJECT_INFO_LOOKUP_REPLACE 1 335 + /* Do not retry packed storage after checking packed and loose storage */ 336 + #define OBJECT_INFO_QUICK 8 337 + /* 338 + * Do not attempt to fetch the object if missing (even if fetch_is_missing is 339 + * nonzero). 340 + */ 341 + #define OBJECT_INFO_SKIP_FETCH_OBJECT 16 342 + /* 343 + * This is meant for bulk prefetching of missing blobs in a partial 344 + * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK 345 + */ 346 + #define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK) 347 + 348 + /* Die if object corruption (not just an object being missing) was detected. */ 349 + #define OBJECT_INFO_DIE_IF_CORRUPT 32 350 + 351 + /* 352 + * Read object info from the object database and populate the `object_info` 353 + * structure. Returns 0 on success, a negative error code otherwise. 354 + */ 355 + int odb_read_object_info_extended(struct object_database *odb, 356 + const struct object_id *oid, 357 + struct object_info *oi, 358 + unsigned flags); 359 + 360 + /* 361 + * Read a subset of object info for the given object ID. Returns an `enum 362 + * object_type` on success, a negative error code otherwise. If successful and 363 + * `sizep` is non-NULL, then the size of the object will be written to the 364 + * pointer. 365 + */ 366 + int odb_read_object_info(struct object_database *odb, 367 + const struct object_id *oid, 368 + unsigned long *sizep); 369 + 370 + enum { 371 + /* Retry packed storage after checking packed and loose storage */ 372 + HAS_OBJECT_RECHECK_PACKED = (1 << 0), 373 + /* Allow fetching the object in case the repository has a promisor remote. */ 374 + HAS_OBJECT_FETCH_PROMISOR = (1 << 1), 375 + }; 376 + 377 + /* 378 + * Returns 1 if the object exists. This function will not lazily fetch objects 379 + * in a partial clone by default. 380 + */ 381 + int odb_has_object(struct object_database *odb, 382 + const struct object_id *oid, 383 + unsigned flags); 384 + 385 + void odb_assert_oid_type(struct object_database *odb, 386 + const struct object_id *oid, enum object_type expect); 387 + 388 + /* 389 + * Enabling the object read lock allows multiple threads to safely call the 390 + * following functions in parallel: odb_read_object(), 391 + * odb_read_object_peeled(), odb_read_object_info() and odb(). 392 + * 393 + * obj_read_lock() and obj_read_unlock() may also be used to protect other 394 + * section which cannot execute in parallel with object reading. Since the used 395 + * lock is a recursive mutex, these sections can even contain calls to object 396 + * reading functions. However, beware that in these cases zlib inflation won't 397 + * be performed in parallel, losing performance. 398 + * 399 + * TODO: odb_read_object_info_extended()'s call stack has a recursive behavior. If 400 + * any of its callees end up calling it, this recursive call won't benefit from 401 + * parallel inflation. 402 + */ 403 + void enable_obj_read_lock(void); 404 + void disable_obj_read_lock(void); 405 + 406 + extern int obj_read_use_lock; 407 + extern pthread_mutex_t obj_read_mutex; 408 + 409 + static inline void obj_read_lock(void) 410 + { 411 + if(obj_read_use_lock) 412 + pthread_mutex_lock(&obj_read_mutex); 413 + } 414 + 415 + static inline void obj_read_unlock(void) 416 + { 417 + if(obj_read_use_lock) 418 + pthread_mutex_unlock(&obj_read_mutex); 419 + } 420 + /* Flags for for_each_*_object(). */ 421 + enum for_each_object_flags { 422 + /* Iterate only over local objects, not alternates. */ 423 + FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0), 424 + 425 + /* Only iterate over packs obtained from the promisor remote. */ 426 + FOR_EACH_OBJECT_PROMISOR_ONLY = (1<<1), 427 + 428 + /* 429 + * Visit objects within a pack in packfile order rather than .idx order 430 + */ 431 + FOR_EACH_OBJECT_PACK_ORDER = (1<<2), 432 + 433 + /* Only iterate over packs that are not marked as kept in-core. */ 434 + FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS = (1<<3), 435 + 436 + /* Only iterate over packs that do not have .keep files. */ 437 + FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4), 438 + }; 439 + 440 + /* Compatibility wrappers, to be removed once Git 2.51 has been released. */ 441 + #include "repository.h" 442 + 443 + static inline int oid_object_info_extended(struct repository *r, 444 + const struct object_id *oid, 445 + struct object_info *oi, 446 + unsigned flags) 447 + { 448 + return odb_read_object_info_extended(r->objects, oid, oi, flags); 449 + } 450 + 451 + static inline int oid_object_info(struct repository *r, 452 + const struct object_id *oid, 453 + unsigned long *sizep) 454 + { 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); 464 + } 465 + 466 + static inline int has_object(struct repository *r, 467 + const struct object_id *oid, 468 + unsigned flags) 469 + { 470 + return odb_has_object(r->objects, oid, flags); 471 + } 472 + 473 + #endif /* ODB_H */
+1 -1
oss-fuzz/fuzz-pack-idx.c
··· 1 1 #include "git-compat-util.h" 2 - #include "object-store.h" 2 + #include "odb.h" 3 3 #include "packfile.h" 4 4 5 5 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+5 -4
pack-bitmap-write.c
··· 4 4 #include "environment.h" 5 5 #include "gettext.h" 6 6 #include "hex.h" 7 - #include "object-store.h" 7 + #include "odb.h" 8 8 #include "commit.h" 9 9 #include "diff.h" 10 10 #include "revision.h" ··· 144 144 break; 145 145 146 146 default: 147 - real_type = oid_object_info(writer->to_pack->repo, 148 - &entry->idx.oid, NULL); 147 + real_type = odb_read_object_info(writer->to_pack->repo->objects, 148 + &entry->idx.oid, NULL); 149 149 break; 150 150 } 151 151 ··· 1052 1052 1053 1053 struct bitmap_disk_header header; 1054 1054 1055 - int fd = odb_mkstemp(&tmp_file, "pack/tmp_bitmap_XXXXXX"); 1055 + int fd = odb_mkstemp(writer->repo->objects, &tmp_file, 1056 + "pack/tmp_bitmap_XXXXXX"); 1056 1057 1057 1058 if (writer->pseudo_merges_nr) 1058 1059 options |= BITMAP_OPT_PSEUDO_MERGES;
+5 -5
pack-bitmap.c
··· 17 17 #include "packfile.h" 18 18 #include "repository.h" 19 19 #include "trace2.h" 20 - #include "object-store.h" 20 + #include "odb.h" 21 21 #include "list-objects-filter-options.h" 22 22 #include "midx.h" 23 23 #include "config.h" ··· 1868 1868 size_t eindex_pos = pos - bitmap_num_objects_total(bitmap_git); 1869 1869 struct eindex *eindex = &bitmap_git->ext_index; 1870 1870 struct object *obj = eindex->objects[eindex_pos]; 1871 - if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid, 1872 - &oi, 0) < 0) 1871 + if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, &obj->oid, 1872 + &oi, 0) < 0) 1873 1873 die(_("unable to get size of %s"), oid_to_hex(&obj->oid)); 1874 1874 } 1875 1875 ··· 3220 3220 i))) 3221 3221 continue; 3222 3222 3223 - if (oid_object_info_extended(bitmap_repo(bitmap_git), &obj->oid, 3224 - &oi, 0) < 0) 3223 + if (odb_read_object_info_extended(bitmap_repo(bitmap_git)->objects, 3224 + &obj->oid, &oi, 0) < 0) 3225 3225 die(_("unable to get disk usage of '%s'"), 3226 3226 oid_to_hex(&obj->oid)); 3227 3227
+1 -1
pack-check.c
··· 8 8 #include "progress.h" 9 9 #include "packfile.h" 10 10 #include "object-file.h" 11 - #include "object-store.h" 11 + #include "odb.h" 12 12 13 13 struct idx_entry { 14 14 off_t offset;
+1 -1
pack-mtimes.c
··· 1 1 #include "git-compat-util.h" 2 2 #include "gettext.h" 3 3 #include "pack-mtimes.h" 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "packfile.h" 6 6 #include "strbuf.h" 7 7
+1 -1
pack-objects.h
··· 1 1 #ifndef PACK_OBJECTS_H 2 2 #define PACK_OBJECTS_H 3 3 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "thread-utils.h" 6 6 #include "pack.h" 7 7 #include "packfile.h"
+1 -1
pack-revindex.c
··· 1 1 #include "git-compat-util.h" 2 2 #include "gettext.h" 3 3 #include "pack-revindex.h" 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "packfile.h" 6 6 #include "strbuf.h" 7 7 #include "trace2.h"
+6 -4
pack-write.c
··· 84 84 } else { 85 85 if (!index_name) { 86 86 struct strbuf tmp_file = STRBUF_INIT; 87 - fd = odb_mkstemp(&tmp_file, "pack/tmp_idx_XXXXXX"); 87 + fd = odb_mkstemp(repo->objects, &tmp_file, 88 + "pack/tmp_idx_XXXXXX"); 88 89 index_name = strbuf_detach(&tmp_file, NULL); 89 90 } else { 90 91 unlink(index_name); ··· 259 260 if (flags & WRITE_REV) { 260 261 if (!rev_name) { 261 262 struct strbuf tmp_file = STRBUF_INIT; 262 - fd = odb_mkstemp(&tmp_file, "pack/tmp_rev_XXXXXX"); 263 + fd = odb_mkstemp(repo->objects, &tmp_file, 264 + "pack/tmp_rev_XXXXXX"); 263 265 path = strbuf_detach(&tmp_file, NULL); 264 266 } else { 265 267 unlink(rev_name); ··· 342 344 if (!to_pack) 343 345 BUG("cannot call write_mtimes_file with NULL packing_data"); 344 346 345 - fd = odb_mkstemp(&tmp_file, "pack/tmp_mtimes_XXXXXX"); 347 + fd = odb_mkstemp(repo->objects, &tmp_file, "pack/tmp_mtimes_XXXXXX"); 346 348 mtimes_name = strbuf_detach(&tmp_file, NULL); 347 349 f = hashfd(repo->hash_algo, fd, mtimes_name); 348 350 ··· 531 533 struct strbuf tmpname = STRBUF_INIT; 532 534 int fd; 533 535 534 - fd = odb_mkstemp(&tmpname, "pack/tmp_pack_XXXXXX"); 536 + fd = odb_mkstemp(repo->objects, &tmpname, "pack/tmp_pack_XXXXXX"); 535 537 *pack_tmp_name = strbuf_detach(&tmpname, NULL); 536 538 return hashfd(repo->hash_algo, fd, *pack_tmp_name); 537 539 }
+15 -14
packfile.c
··· 19 19 #include "tree-walk.h" 20 20 #include "tree.h" 21 21 #include "object-file.h" 22 - #include "object-store.h" 22 + #include "odb.h" 23 23 #include "midx.h" 24 24 #include "commit-graph.h" 25 25 #include "pack-revindex.h" ··· 359 359 oidset_clear(&p->bad_objects); 360 360 } 361 361 362 - void close_object_store(struct raw_object_store *o) 362 + void close_object_store(struct object_database *o) 363 363 { 364 364 struct packed_git *p; 365 365 ··· 1029 1029 1030 1030 static void prepare_packed_git(struct repository *r) 1031 1031 { 1032 - struct object_directory *odb; 1032 + struct odb_source *source; 1033 1033 1034 1034 if (r->objects->packed_git_initialized) 1035 1035 return; 1036 1036 1037 - prepare_alt_odb(r); 1038 - for (odb = r->objects->odb; odb; odb = odb->next) { 1039 - int local = (odb == r->objects->odb); 1040 - prepare_multi_pack_index_one(r, odb->path, local); 1041 - prepare_packed_git_one(r, odb->path, local); 1037 + odb_prepare_alternates(r->objects); 1038 + for (source = r->objects->sources; source; source = source->next) { 1039 + int local = (source == r->objects->sources); 1040 + prepare_multi_pack_index_one(r, source->path, local); 1041 + prepare_packed_git_one(r, source->path, local); 1042 1042 } 1043 1043 rearrange_packed_git(r); 1044 1044 ··· 1048 1048 1049 1049 void reprepare_packed_git(struct repository *r) 1050 1050 { 1051 - struct object_directory *odb; 1051 + struct odb_source *source; 1052 1052 1053 1053 obj_read_lock(); 1054 1054 ··· 1059 1059 * the lifetime of the process. 1060 1060 */ 1061 1061 r->objects->loaded_alternates = 0; 1062 - prepare_alt_odb(r); 1062 + odb_prepare_alternates(r->objects); 1063 1063 1064 - for (odb = r->objects->odb; odb; odb = odb->next) 1065 - odb_clear_loose_cache(odb); 1064 + for (source = r->objects->sources; source; source = source->next) 1065 + odb_clear_loose_cache(source); 1066 1066 1067 1067 r->objects->approximate_object_count_valid = 0; 1068 1068 r->objects->packed_git_initialized = 0; ··· 1321 1321 return OBJ_BAD; 1322 1322 nth_packed_object_id(&oid, p, pack_pos_to_index(p, pos)); 1323 1323 mark_bad_packed_object(p, &oid); 1324 - type = oid_object_info(r, &oid, NULL); 1324 + type = odb_read_object_info(r->objects, &oid, NULL); 1325 1325 if (type <= OBJ_NONE) 1326 1326 return OBJ_BAD; 1327 1327 return type; ··· 1849 1849 oi.typep = &type; 1850 1850 oi.sizep = &base_size; 1851 1851 oi.contentp = &base; 1852 - if (oid_object_info_extended(r, &base_oid, &oi, 0) < 0) 1852 + if (odb_read_object_info_extended(r->objects, &base_oid, 1853 + &oi, 0) < 0) 1853 1854 base = NULL; 1854 1855 1855 1856 external_base = base;
+4 -4
packfile.h
··· 3 3 4 4 #include "list.h" 5 5 #include "object.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 #include "oidset.h" 8 8 9 - /* in object-store.h */ 9 + /* in odb.h */ 10 10 struct object_info; 11 11 12 12 struct packed_git { ··· 183 183 184 184 uint32_t get_pack_fanout(struct packed_git *p, uint32_t value); 185 185 186 - struct raw_object_store; 186 + struct object_database; 187 187 188 188 unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *); 189 189 void close_pack_windows(struct packed_git *); 190 190 void close_pack(struct packed_git *); 191 - void close_object_store(struct raw_object_store *o); 191 + void close_object_store(struct object_database *o); 192 192 void unuse_pack(struct pack_window **); 193 193 void clear_delta_base_cache(void); 194 194 struct packed_git *add_packed_git(struct repository *r, const char *path,
+2 -2
path.c
··· 15 15 #include "submodule-config.h" 16 16 #include "path.h" 17 17 #include "packfile.h" 18 - #include "object-store.h" 18 + #include "odb.h" 19 19 #include "lockfile.h" 20 20 #include "exec-cmd.h" 21 21 ··· 397 397 strbuf_splice(buf, 0, buf->len, 398 398 repo->index_file, strlen(repo->index_file)); 399 399 else if (dir_prefix(base, "objects")) 400 - replace_dir(buf, git_dir_len + 7, repo->objects->odb->path); 400 + replace_dir(buf, git_dir_len + 7, repo->objects->sources->path); 401 401 else if (repo_settings_get_hooks_path(repo) && dir_prefix(base, "hooks")) 402 402 replace_dir(buf, git_dir_len + 5, repo_settings_get_hooks_path(repo)); 403 403 else if (repo->different_commondir)
+3 -3
promisor-remote.c
··· 3 3 #include "git-compat-util.h" 4 4 #include "gettext.h" 5 5 #include "hex.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 #include "promisor-remote.h" 8 8 #include "config.h" 9 9 #include "trace2.h" ··· 245 245 struct object_id *new_oids; 246 246 247 247 for (i = 0; i < oid_nr; i++) 248 - if (oid_object_info_extended(repo, &old_oids[i], NULL, 249 - OBJECT_INFO_SKIP_FETCH_OBJECT)) { 248 + if (odb_read_object_info_extended(repo->objects, &old_oids[i], NULL, 249 + OBJECT_INFO_SKIP_FETCH_OBJECT)) { 250 250 remaining[i] = 1; 251 251 remaining_nr++; 252 252 }
+2 -2
protocol-caps.c
··· 6 6 #include "hash.h" 7 7 #include "hex.h" 8 8 #include "object.h" 9 - #include "object-store.h" 9 + #include "odb.h" 10 10 #include "repository.h" 11 11 #include "string-list.h" 12 12 #include "strbuf.h" ··· 64 64 strbuf_addstr(&send_buffer, oid_str); 65 65 66 66 if (info->size) { 67 - if (oid_object_info(r, &oid, &object_size) < 0) { 67 + if (odb_read_object_info(r->objects, &oid, &object_size) < 0) { 68 68 strbuf_addstr(&send_buffer, " "); 69 69 } else { 70 70 strbuf_addf(&send_buffer, " %lu", object_size);
+1 -1
reachable.c
··· 211 211 * later processing, and the revision machinery expects 212 212 * commits and tags to have been parsed. 213 213 */ 214 - type = oid_object_info(the_repository, oid, NULL); 214 + type = odb_read_object_info(the_repository->objects, oid, NULL); 215 215 if (type < 0) 216 216 die("unable to get object info for %s", oid_to_hex(oid)); 217 217
+7 -7
read-cache.c
··· 20 20 #include "refs.h" 21 21 #include "dir.h" 22 22 #include "object-file.h" 23 - #include "object-store.h" 23 + #include "odb.h" 24 24 #include "oid-array.h" 25 25 #include "tree.h" 26 26 #include "commit.h" ··· 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; ··· 3729 3729 3730 3730 if (S_ISGITLINK(ce->ce_mode) || !must_prefetch(ce)) 3731 3731 continue; 3732 - if (!oid_object_info_extended(the_repository, &ce->oid, 3733 - NULL, 3734 - OBJECT_INFO_FOR_PREFETCH)) 3732 + if (!odb_read_object_info_extended(the_repository->objects, 3733 + &ce->oid, NULL, 3734 + OBJECT_INFO_FOR_PREFETCH)) 3735 3735 continue; 3736 3736 oid_array_append(&to_fetch, &ce->oid); 3737 3737 }
+3 -3
ref-filter.c
··· 12 12 #include "refs.h" 13 13 #include "wildmatch.h" 14 14 #include "object-name.h" 15 - #include "object-store.h" 15 + #include "odb.h" 16 16 #include "oid-array.h" 17 17 #include "repo-settings.h" 18 18 #include "repository.h" ··· 2302 2302 oi->info.sizep = &oi->size; 2303 2303 oi->info.typep = &oi->type; 2304 2304 } 2305 - if (oid_object_info_extended(the_repository, &oi->oid, &oi->info, 2306 - OBJECT_INFO_LOOKUP_REPLACE)) 2305 + if (odb_read_object_info_extended(the_repository->objects, &oi->oid, &oi->info, 2306 + OBJECT_INFO_LOOKUP_REPLACE)) 2307 2307 return strbuf_addf_ret(err, -1, _("missing object %s for %s"), 2308 2308 oid_to_hex(&oi->oid), ref->refname); 2309 2309 if (oi->info.disk_sizep && oi->disk_size < 0)
+4 -4
reflog.c
··· 5 5 #include "config.h" 6 6 #include "gettext.h" 7 7 #include "parse-options.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "reflog.h" 10 10 #include "refs.h" 11 11 #include "revision.h" ··· 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; ··· 152 152 init_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size); 153 153 complete = 1; 154 154 while (tree_entry(&desc, &entry)) { 155 - if (!has_object(the_repository, &entry.oid, 155 + if (!odb_has_object(the_repository->objects, &entry.oid, 156 156 HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) || 157 157 (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) { 158 158 tree->object.flags |= INCOMPLETE;
+4 -3
refs.c
··· 19 19 #include "run-command.h" 20 20 #include "hook.h" 21 21 #include "object-name.h" 22 - #include "object-store.h" 22 + #include "odb.h" 23 23 #include "object.h" 24 24 #include "path.h" 25 25 #include "submodule.h" ··· 376 376 { 377 377 if (flags & REF_ISBROKEN) 378 378 return 0; 379 - if (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 379 + if (!odb_has_object(repo->objects, oid, 380 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 380 381 error(_("%s does not point to a valid object!"), refname); 381 382 return 0; 382 383 } ··· 2477 2478 break; 2478 2479 } 2479 2480 2480 - if (refs->repo->objects->odb->disable_ref_updates) { 2481 + if (refs->repo->objects->sources->disable_ref_updates) { 2481 2482 strbuf_addstr(err, 2482 2483 _("ref updates forbidden inside quarantine environment")); 2483 2484 return -1;
+5 -4
remote.c
··· 12 12 #include "refs.h" 13 13 #include "refspec.h" 14 14 #include "object-name.h" 15 - #include "object-store.h" 15 + #include "odb.h" 16 16 #include "path.h" 17 17 #include "commit.h" 18 18 #include "diff.h" ··· 1196 1196 BUG("'%s' is not a valid object, " 1197 1197 "match_explicit_lhs() should catch this!", 1198 1198 matched_src_name); 1199 - type = oid_object_info(the_repository, &oid, NULL); 1199 + type = odb_read_object_info(the_repository->objects, &oid, NULL); 1200 1200 if (type == OBJ_COMMIT) { 1201 1201 advise(_("The <src> part of the refspec is a commit object.\n" 1202 1202 "Did you mean to create a new branch by pushing to\n" ··· 1426 1426 continue; /* not a tag */ 1427 1427 if (string_list_has_string(&dst_tag, ref->name)) 1428 1428 continue; /* they already have it */ 1429 - if (oid_object_info(the_repository, &ref->new_oid, NULL) != OBJ_TAG) 1429 + if (odb_read_object_info(the_repository->objects, 1430 + &ref->new_oid, NULL) != OBJ_TAG) 1430 1431 continue; /* be conservative */ 1431 1432 item = string_list_append(&src_tag, ref->name); 1432 1433 item->util = ref; ··· 1716 1717 if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) { 1717 1718 if (starts_with(ref->name, "refs/tags/")) 1718 1719 reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS; 1719 - else if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED)) 1720 + else if (!odb_has_object(the_repository->objects, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED)) 1720 1721 reject_reason = REF_STATUS_REJECT_FETCH_FIRST; 1721 1722 else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) || 1722 1723 !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1))
+1 -1
replace-object.c
··· 2 2 #include "gettext.h" 3 3 #include "hex.h" 4 4 #include "oidmap.h" 5 - #include "object-store.h" 5 + #include "odb.h" 6 6 #include "replace-object.h" 7 7 #include "refs.h" 8 8 #include "repository.h"
+1 -1
replace-object.h
··· 3 3 4 4 #include "oidmap.h" 5 5 #include "repository.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 8 8 struct replace_object { 9 9 struct oidmap_entry original;
+11 -10
repository.c
··· 1 1 #include "git-compat-util.h" 2 2 #include "abspath.h" 3 3 #include "repository.h" 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "config.h" 6 6 #include "object.h" 7 7 #include "lockfile.h" ··· 52 52 53 53 void initialize_repository(struct repository *repo) 54 54 { 55 - repo->objects = raw_object_store_new(); 55 + repo->objects = odb_new(repo); 56 56 repo->remote_state = remote_state_new(); 57 57 repo->parsed_objects = parsed_object_pool_new(repo); 58 58 ALLOC_ARRAY(repo->index, 1); ··· 107 107 108 108 const char *repo_get_object_directory(struct repository *repo) 109 109 { 110 - if (!repo->objects->odb) 110 + if (!repo->objects->sources) 111 111 BUG("repository hasn't been set up"); 112 - return repo->objects->odb->path; 112 + return repo->objects->sources->path; 113 113 } 114 114 115 115 const char *repo_get_index_file(struct repository *repo) ··· 165 165 166 166 repo_set_commondir(repo, o->commondir); 167 167 168 - if (!repo->objects->odb) { 169 - CALLOC_ARRAY(repo->objects->odb, 1); 170 - repo->objects->odb_tail = &repo->objects->odb->next; 168 + if (!repo->objects->sources) { 169 + CALLOC_ARRAY(repo->objects->sources, 1); 170 + repo->objects->sources->odb = repo->objects; 171 + repo->objects->sources_tail = &repo->objects->sources->next; 171 172 } 172 - expand_base_dir(&repo->objects->odb->path, o->object_dir, 173 + expand_base_dir(&repo->objects->sources->path, o->object_dir, 173 174 repo->commondir, "objects"); 174 175 175 - repo->objects->odb->disable_ref_updates = o->disable_ref_updates; 176 + repo->objects->sources->disable_ref_updates = o->disable_ref_updates; 176 177 177 178 free(repo->objects->alternate_db); 178 179 repo->objects->alternate_db = xstrdup_or_null(o->alternate_db); ··· 374 375 FREE_AND_NULL(repo->worktree); 375 376 FREE_AND_NULL(repo->submodule_prefix); 376 377 377 - raw_object_store_clear(repo->objects); 378 + odb_clear(repo->objects); 378 379 FREE_AND_NULL(repo->objects); 379 380 380 381 parsed_object_pool_clear(repo->parsed_objects);
+2 -2
repository.h
··· 9 9 struct index_state; 10 10 struct lock_file; 11 11 struct pathspec; 12 - struct raw_object_store; 12 + struct object_database; 13 13 struct submodule_cache; 14 14 struct promisor_remote_config; 15 15 struct remote_state; ··· 47 47 /* 48 48 * Holds any information related to accessing the raw object content. 49 49 */ 50 - struct raw_object_store *objects; 50 + struct object_database *objects; 51 51 52 52 /* 53 53 * All objects in this repository that have been parsed. This structure
+3 -4
rerere.c
··· 18 18 #include "path.h" 19 19 #include "pathspec.h" 20 20 #include "object-file.h" 21 - #include "object-store.h" 21 + #include "odb.h" 22 22 #include "strmap.h" 23 23 24 24 #define RESOLVED 0 ··· 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));
+3 -2
revision.c
··· 8 8 #include "hex.h" 9 9 #include "object-name.h" 10 10 #include "object-file.h" 11 - #include "object-store.h" 11 + #include "odb.h" 12 12 #include "oidset.h" 13 13 #include "tag.h" 14 14 #include "blob.h" ··· 1907 1907 struct add_alternate_refs_data data; 1908 1908 data.revs = revs; 1909 1909 data.flags = flags; 1910 - for_each_alternate_ref(add_one_alternate_ref, &data); 1910 + odb_for_each_alternate_ref(the_repository->objects, 1911 + add_one_alternate_ref, &data); 1911 1912 } 1912 1913 1913 1914 static int add_parents_only(struct rev_info *revs, const char *arg_, int flags,
+2 -2
send-pack.c
··· 4 4 #include "date.h" 5 5 #include "gettext.h" 6 6 #include "hex.h" 7 - #include "object-store.h" 7 + #include "odb.h" 8 8 #include "pkt-line.h" 9 9 #include "sideband.h" 10 10 #include "run-command.h" ··· 45 45 static void feed_object(struct repository *r, 46 46 const struct object_id *oid, FILE *fh, int negative) 47 47 { 48 - if (negative && !has_object(r, oid, 0)) 48 + if (negative && !odb_has_object(r->objects, oid, 0)) 49 49 return; 50 50 51 51 if (negative)
+3 -4
sequencer.c
··· 13 13 #include "dir.h" 14 14 #include "object-file.h" 15 15 #include "object-name.h" 16 - #include "object-store.h" 16 + #include "odb.h" 17 17 #include "object.h" 18 18 #include "pager.h" 19 19 #include "commit.h" ··· 5505 5505 5506 5506 if (!repo_get_oid(r, name, &oid)) { 5507 5507 if (!lookup_commit_reference_gently(r, &oid, 1)) { 5508 - enum object_type type = oid_object_info(r, 5509 - &oid, 5510 - NULL); 5508 + enum object_type type = odb_read_object_info(r->objects, 5509 + &oid, NULL); 5511 5510 res = error(_("%s: can't cherry-pick a %s"), 5512 5511 name, type_name(type)); 5513 5512 goto out;
+1 -1
server-info.c
··· 11 11 #include "packfile.h" 12 12 #include "path.h" 13 13 #include "object-file.h" 14 - #include "object-store.h" 14 + #include "odb.h" 15 15 #include "server-info.h" 16 16 #include "strbuf.h" 17 17 #include "tempfile.h"
+7 -7
shallow.c
··· 5 5 #include "repository.h" 6 6 #include "tempfile.h" 7 7 #include "lockfile.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "commit.h" 10 10 #include "tag.h" 11 11 #include "pkt-line.h" ··· 310 310 if (graft->nr_parent != -1) 311 311 return 0; 312 312 if (data->flags & QUICK) { 313 - if (!has_object(the_repository, &graft->oid, 314 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 313 + if (!odb_has_object(the_repository->objects, &graft->oid, 314 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 315 315 return 0; 316 316 } else if (data->flags & SEEN_ONLY) { 317 317 struct commit *c = lookup_commit(the_repository, &graft->oid); ··· 477 477 ALLOC_ARRAY(info->ours, sa->nr); 478 478 ALLOC_ARRAY(info->theirs, sa->nr); 479 479 for (size_t i = 0; i < sa->nr; i++) { 480 - if (has_object(the_repository, sa->oid + i, 481 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 480 + if (odb_has_object(the_repository->objects, sa->oid + i, 481 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 482 482 struct commit_graft *graft; 483 483 graft = lookup_commit_graft(the_repository, 484 484 &sa->oid[i]); ··· 515 515 for (i = dst = 0; i < info->nr_theirs; i++) { 516 516 if (i != dst) 517 517 info->theirs[dst] = info->theirs[i]; 518 - if (has_object(the_repository, oid + info->theirs[i], 519 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 518 + if (odb_has_object(the_repository->objects, oid + info->theirs[i], 519 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) 520 520 dst++; 521 521 } 522 522 info->nr_theirs = dst;
+5 -5
streaming.c
··· 10 10 #include "streaming.h" 11 11 #include "repository.h" 12 12 #include "object-file.h" 13 - #include "object-store.h" 13 + #include "odb.h" 14 14 #include "replace-object.h" 15 15 #include "packfile.h" 16 16 ··· 44 44 45 45 union { 46 46 struct { 47 - char *buf; /* from oid_object_info_extended() */ 47 + char *buf; /* from odb_read_object_info_extended() */ 48 48 unsigned long read_ptr; 49 49 } incore; 50 50 ··· 403 403 oi.typep = type; 404 404 oi.sizep = &st->size; 405 405 oi.contentp = (void **)&st->u.incore.buf; 406 - return oid_object_info_extended(r, oid, &oi, 407 - OBJECT_INFO_DIE_IF_CORRUPT); 406 + return odb_read_object_info_extended(r->objects, oid, &oi, 407 + OBJECT_INFO_DIE_IF_CORRUPT); 408 408 } 409 409 410 410 /***************************************************************************** ··· 422 422 423 423 oi.typep = type; 424 424 oi.sizep = &size; 425 - status = oid_object_info_extended(r, oid, &oi, 0); 425 + status = odb_read_object_info_extended(r->objects, oid, &oi, 0); 426 426 if (status < 0) 427 427 return status; 428 428
+5 -4
submodule-config.c
··· 13 13 #include "submodule.h" 14 14 #include "strbuf.h" 15 15 #include "object-name.h" 16 - #include "object-store.h" 16 + #include "odb.h" 17 17 #include "parse-options.h" 18 18 #include "thread-utils.h" 19 19 #include "tree-walk.h" ··· 731 731 if (submodule) 732 732 goto out; 733 733 734 - config = repo_read_object_file(the_repository, &oid, &type, 735 - &config_size); 734 + config = odb_read_object(the_repository->objects, &oid, 735 + &type, &config_size); 736 736 if (!config || type != OBJ_BLOB) 737 737 goto out; 738 738 ··· 798 798 repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) { 799 799 config_source.blob = oidstr = xstrdup(oid_to_hex(&oid)); 800 800 if (repo != the_repository) 801 - add_submodule_odb_by_path(repo->objects->odb->path); 801 + odb_add_submodule_source_by_path(the_repository->objects, 802 + repo->objects->sources->path); 802 803 } else { 803 804 goto out; 804 805 }
+3 -29
submodule.c
··· 27 27 #include "parse-options.h" 28 28 #include "object-file.h" 29 29 #include "object-name.h" 30 - #include "object-store.h" 30 + #include "odb.h" 31 31 #include "commit-reach.h" 32 32 #include "read-cache-ll.h" 33 33 #include "setup.h" 34 - #include "trace2.h" 35 34 36 35 static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; 37 36 static int initialized_fetch_ref_tips; ··· 176 175 die(_("staging updated .gitmodules failed")); 177 176 } 178 177 179 - static struct string_list added_submodule_odb_paths = STRING_LIST_INIT_DUP; 180 - 181 - void add_submodule_odb_by_path(const char *path) 182 - { 183 - string_list_insert(&added_submodule_odb_paths, path); 184 - } 185 - 186 - int register_all_submodule_odb_as_alternates(void) 187 - { 188 - int i; 189 - int ret = added_submodule_odb_paths.nr; 190 - 191 - for (i = 0; i < added_submodule_odb_paths.nr; i++) 192 - add_to_alternates_memory(added_submodule_odb_paths.items[i].string); 193 - if (ret) { 194 - string_list_clear(&added_submodule_odb_paths, 0); 195 - trace2_data_intmax("submodule", the_repository, 196 - "register_all_submodule_odb_as_alternates/registered", ret); 197 - if (git_env_bool("GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB", 0)) 198 - BUG("register_all_submodule_odb_as_alternates() called"); 199 - } 200 - return ret; 201 - } 202 - 203 178 void set_diffopt_flags_from_submodule_config(struct diff_options *diffopt, 204 179 const char *path) 205 180 { ··· 993 968 return 0; 994 969 } 995 970 996 - type = oid_object_info(&subrepo, oid, NULL); 971 + type = odb_read_object_info(subrepo.objects, oid, NULL); 997 972 998 973 switch (type) { 999 974 case OBJ_COMMIT: ··· 1777 1752 static int commit_missing_in_sub(const struct object_id *oid, void *data) 1778 1753 { 1779 1754 struct repository *subrepo = data; 1780 - 1781 - enum object_type type = oid_object_info(subrepo, oid, NULL); 1755 + enum object_type type = odb_read_object_info(subrepo->objects, oid, NULL); 1782 1756 1783 1757 return type != OBJ_COMMIT; 1784 1758 }
-9
submodule.h
··· 105 105 int bad_to_remove_submodule(const char *path, unsigned flags); 106 106 107 107 /* 108 - * Call add_submodule_odb_by_path() to add the submodule at the given 109 - * path to a list. When register_all_submodule_odb_as_alternates() is 110 - * called, the object stores of all submodules in that list will be 111 - * added as alternates in the_repository. 112 - */ 113 - void add_submodule_odb_by_path(const char *path); 114 - int register_all_submodule_odb_as_alternates(void); 115 - 116 - /* 117 108 * Checks if there are submodule changes in a..b. If a is the null OID, 118 109 * checks b and all its ancestors instead. 119 110 */
+1 -1
t/helper/test-find-pack.c
··· 2 2 3 3 #include "test-tool.h" 4 4 #include "object-name.h" 5 - #include "object-store.h" 5 + #include "odb.h" 6 6 #include "packfile.h" 7 7 #include "parse-options.h" 8 8 #include "setup.h"
+1 -1
t/helper/test-pack-mtimes.c
··· 3 3 #include "test-tool.h" 4 4 #include "hex.h" 5 5 #include "strbuf.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 #include "packfile.h" 8 8 #include "pack-mtimes.h" 9 9 #include "setup.h"
+2 -2
t/helper/test-partial-clone.c
··· 1 1 #include "test-tool.h" 2 2 #include "hex.h" 3 3 #include "repository.h" 4 - #include "object-store.h" 4 + #include "odb.h" 5 5 #include "setup.h" 6 6 7 7 /* ··· 23 23 die("could not init repo"); 24 24 if (parse_oid_hex_algop(oid_hex, &oid, &p, r.hash_algo)) 25 25 die("could not parse oid"); 26 - if (oid_object_info_extended(&r, &oid, &oi, 0)) 26 + if (odb_read_object_info_extended(r.objects, &oid, &oi, 0)) 27 27 die("could not obtain object info"); 28 28 printf("%d\n", (int) size); 29 29
+4 -4
t/helper/test-read-graph.c
··· 3 3 #include "test-tool.h" 4 4 #include "commit-graph.h" 5 5 #include "repository.h" 6 - #include "object-store.h" 6 + #include "odb.h" 7 7 #include "bloom.h" 8 8 #include "setup.h" 9 9 ··· 73 73 int cmd__read_graph(int argc, const char **argv) 74 74 { 75 75 struct commit_graph *graph = NULL; 76 - struct object_directory *odb; 76 + struct odb_source *source; 77 77 int ret = 0; 78 78 79 79 setup_git_directory(); 80 - odb = the_repository->objects->odb; 80 + source = the_repository->objects->sources; 81 81 82 82 prepare_repo_settings(the_repository); 83 83 84 - graph = read_commit_graph_one(the_repository, odb); 84 + graph = read_commit_graph_one(the_repository, source); 85 85 if (!graph) { 86 86 ret = 1; 87 87 goto done;
+1 -1
t/helper/test-read-midx.c
··· 4 4 #include "hex.h" 5 5 #include "midx.h" 6 6 #include "repository.h" 7 - #include "object-store.h" 7 + #include "odb.h" 8 8 #include "pack-bitmap.h" 9 9 #include "packfile.h" 10 10 #include "setup.h"
+2 -2
t/helper/test-ref-store.c
··· 5 5 #include "refs.h" 6 6 #include "setup.h" 7 7 #include "worktree.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "path.h" 10 10 #include "repository.h" 11 11 #include "strbuf.h" ··· 79 79 if (!repo_submodule_path_append(the_repository, 80 80 &sb, gitdir, "objects/")) 81 81 die("computing submodule path failed"); 82 - add_to_alternates_memory(sb.buf); 82 + odb_add_to_alternates_memory(the_repository->objects, sb.buf); 83 83 strbuf_release(&sb); 84 84 85 85 *refs = repo_get_submodule_ref_store(the_repository, gitdir);
+5 -5
tag.c
··· 5 5 #include "environment.h" 6 6 #include "tag.h" 7 7 #include "object-name.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "commit.h" 10 10 #include "tree.h" 11 11 #include "blob.h" ··· 52 52 unsigned long size; 53 53 int ret; 54 54 55 - type = oid_object_info(the_repository, oid, NULL); 55 + type = odb_read_object_info(the_repository->objects, oid, NULL); 56 56 if (type != OBJ_TAG) 57 57 return error("%s: cannot verify a non-tag object of type %s.", 58 58 name_to_report ? ··· 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));
+16 -14
tmp-objdir.c
··· 10 10 #include "strbuf.h" 11 11 #include "strvec.h" 12 12 #include "quote.h" 13 - #include "object-store.h" 13 + #include "odb.h" 14 14 #include "repository.h" 15 15 16 16 struct tmp_objdir { 17 17 struct repository *repo; 18 18 struct strbuf path; 19 19 struct strvec env; 20 - struct object_directory *prev_odb; 20 + struct odb_source *prev_source; 21 21 int will_destroy; 22 22 }; 23 23 ··· 46 46 if (t == the_tmp_objdir) 47 47 the_tmp_objdir = NULL; 48 48 49 - if (t->prev_odb) 50 - restore_primary_odb(t->prev_odb, t->path.buf); 49 + if (t->prev_source) 50 + odb_restore_primary_source(t->repo->objects, t->prev_source, t->path.buf); 51 51 52 52 err = remove_dir_recursively(&t->path, 0); 53 53 ··· 276 276 if (!t) 277 277 return 0; 278 278 279 - if (t->prev_odb) { 280 - if (t->repo->objects->odb->will_destroy) 279 + if (t->prev_source) { 280 + if (t->repo->objects->sources->will_destroy) 281 281 BUG("migrating an ODB that was marked for destruction"); 282 - restore_primary_odb(t->prev_odb, t->path.buf); 283 - t->prev_odb = NULL; 282 + odb_restore_primary_source(t->repo->objects, t->prev_source, t->path.buf); 283 + t->prev_source = NULL; 284 284 } 285 285 286 286 strbuf_addbuf(&src, &t->path); ··· 304 304 305 305 void tmp_objdir_add_as_alternate(const struct tmp_objdir *t) 306 306 { 307 - add_to_alternates_memory(t->path.buf); 307 + odb_add_to_alternates_memory(t->repo->objects, t->path.buf); 308 308 } 309 309 310 310 void tmp_objdir_replace_primary_odb(struct tmp_objdir *t, int will_destroy) 311 311 { 312 - if (t->prev_odb) 312 + if (t->prev_source) 313 313 BUG("the primary object database is already replaced"); 314 - t->prev_odb = set_temporary_primary_odb(t->path.buf, will_destroy); 314 + t->prev_source = odb_set_temporary_primary_source(t->repo->objects, 315 + t->path.buf, will_destroy); 315 316 t->will_destroy = will_destroy; 316 317 } 317 318 318 319 struct tmp_objdir *tmp_objdir_unapply_primary_odb(void) 319 320 { 320 - if (!the_tmp_objdir || !the_tmp_objdir->prev_odb) 321 + if (!the_tmp_objdir || !the_tmp_objdir->prev_source) 321 322 return NULL; 322 323 323 - restore_primary_odb(the_tmp_objdir->prev_odb, the_tmp_objdir->path.buf); 324 - the_tmp_objdir->prev_odb = NULL; 324 + odb_restore_primary_source(the_tmp_objdir->repo->objects, 325 + the_tmp_objdir->prev_source, the_tmp_objdir->path.buf); 326 + the_tmp_objdir->prev_source = NULL; 325 327 return the_tmp_objdir; 326 328 } 327 329
+8 -10
tree-walk.c
··· 6 6 #include "gettext.h" 7 7 #include "hex.h" 8 8 #include "object-file.h" 9 - #include "object-store.h" 9 + #include "odb.h" 10 10 #include "trace2.h" 11 11 #include "tree.h" 12 12 #include "pathspec.h" ··· 90 90 void *buf = NULL; 91 91 92 92 if (oid) { 93 - buf = read_object_with_reference(r, oid, OBJ_TREE, &size, NULL); 93 + buf = odb_read_object_peeled(r->objects, oid, OBJ_TREE, &size, NULL); 94 94 if (!buf) 95 95 die(_("unable to read tree (%s)"), oid_to_hex(oid)); 96 96 } ··· 611 611 unsigned long size; 612 612 struct object_id root; 613 613 614 - tree = read_object_with_reference(r, tree_oid, OBJ_TREE, &size, &root); 614 + tree = odb_read_object_peeled(r->objects, tree_oid, OBJ_TREE, &size, &root); 615 615 if (!tree) 616 616 return -1; 617 617 ··· 681 681 void *tree; 682 682 struct object_id root; 683 683 unsigned long size; 684 - tree = read_object_with_reference(r, 685 - &current_tree_oid, 686 - OBJ_TREE, &size, 687 - &root); 684 + tree = odb_read_object_peeled(r->objects, &current_tree_oid, 685 + OBJ_TREE, &size, &root); 688 686 if (!tree) 689 687 goto done; 690 688 ··· 795 793 */ 796 794 retval = DANGLING_SYMLINK; 797 795 798 - contents = repo_read_object_file(r, 799 - &current_tree_oid, &type, 800 - &link_len); 796 + contents = odb_read_object(r->objects, 797 + &current_tree_oid, &type, 798 + &link_len); 801 799 802 800 if (!contents) 803 801 goto done;
+3 -3
tree.c
··· 4 4 #include "hex.h" 5 5 #include "tree.h" 6 6 #include "object-name.h" 7 - #include "object-store.h" 7 + #include "odb.h" 8 8 #include "commit.h" 9 9 #include "alloc.h" 10 10 #include "tree-walk.h" ··· 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
unpack-trees.c
··· 26 26 #include "symlinks.h" 27 27 #include "trace2.h" 28 28 #include "fsmonitor.h" 29 - #include "object-store.h" 29 + #include "odb.h" 30 30 #include "promisor-remote.h" 31 31 #include "entry.h" 32 32 #include "parallel-checkout.h"
+2 -2
upload-pack.c
··· 10 10 #include "pkt-line.h" 11 11 #include "sideband.h" 12 12 #include "repository.h" 13 - #include "object-store.h" 13 + #include "odb.h" 14 14 #include "oid-array.h" 15 15 #include "object.h" 16 16 #include "commit.h" ··· 509 509 { 510 510 if (get_oid_hex(hex, oid)) 511 511 die("git upload-pack: expected SHA1 object, got '%s'", hex); 512 - if (!has_object(the_repository, oid, 0)) 512 + if (!odb_has_object(the_repository->objects, oid, 0)) 513 513 return -1; 514 514 return do_got_oid(data, oid); 515 515 }
+3 -3
walker.c
··· 5 5 #include "hex.h" 6 6 #include "walker.h" 7 7 #include "repository.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "commit.h" 10 10 #include "strbuf.h" 11 11 #include "tree.h" ··· 150 150 return 0; 151 151 obj->flags |= SEEN; 152 152 153 - if (has_object(the_repository, &obj->oid, 154 - HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 153 + if (odb_has_object(the_repository->objects, &obj->oid, 154 + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { 155 155 /* We already have it, so we should scan it now. */ 156 156 obj->flags |= TO_SCAN; 157 157 }
+2 -2
xdiff-interface.c
··· 5 5 #include "gettext.h" 6 6 #include "config.h" 7 7 #include "hex.h" 8 - #include "object-store.h" 8 + #include "odb.h" 9 9 #include "strbuf.h" 10 10 #include "xdiff-interface.h" 11 11 #include "xdiff/xtypes.h" ··· 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;