Skip to content

Commit 5396ca5

Browse files
committed
Merge branch 'ps/object-store' into jch
Code clean-up around object access API. Comments? * 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`
2 parents 78ec93c + 367aadf commit 5396ca5

File tree

140 files changed

+1453
-1298
lines changed

Some content is hidden

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

140 files changed

+1453
-1298
lines changed

Documentation/user-manual.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4301,11 +4301,11 @@ Now, for the meat:
43014301

43024302
-----------------------------------------------------------------------------
43034303
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);
43054305
-----------------------------------------------------------------------------
43064306

43074307
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
43094309
works, find the source code for it (something like `git grep
43104310
read_object_with | grep ":[a-z]"` in the Git repository), and read
43114311
the source.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,8 +1085,8 @@ LIB_OBJS += notes.o
10851085
LIB_OBJS += object-file-convert.o
10861086
LIB_OBJS += object-file.o
10871087
LIB_OBJS += object-name.o
1088-
LIB_OBJS += object-store.o
10891088
LIB_OBJS += object.o
1089+
LIB_OBJS += odb.o
10901090
LIB_OBJS += oid-array.o
10911091
LIB_OBJS += oidmap.o
10921092
LIB_OBJS += oidset.o

apply.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "abspath.h"
1515
#include "base85.h"
1616
#include "config.h"
17-
#include "object-store.h"
17+
#include "odb.h"
1818
#include "delta.h"
1919
#include "diff.h"
2020
#include "dir.h"
@@ -3204,14 +3204,14 @@ static int apply_binary(struct apply_state *state,
32043204
return 0; /* deletion patch */
32053205
}
32063206

3207-
if (has_object(the_repository, &oid, 0)) {
3207+
if (odb_has_object(the_repository->objects, &oid, 0)) {
32083208
/* We already have the postimage */
32093209
enum object_type type;
32103210
unsigned long size;
32113211
char *result;
32123212

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

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

35043504
image_clear(image);
35053505

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

archive-tar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "hex.h"
1212
#include "tar.h"
1313
#include "archive.h"
14-
#include "object-store.h"
14+
#include "odb.h"
1515
#include "strbuf.h"
1616
#include "streaming.h"
1717
#include "run-command.h"

archive-zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "hex.h"
1313
#include "streaming.h"
1414
#include "utf8.h"
15-
#include "object-store.h"
15+
#include "odb.h"
1616
#include "strbuf.h"
1717
#include "userdiff.h"
1818
#include "write-or-die.h"

archive.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "pretty.h"
1515
#include "setup.h"
1616
#include "refs.h"
17-
#include "object-store.h"
17+
#include "odb.h"
1818
#include "commit.h"
1919
#include "tree.h"
2020
#include "tree-walk.h"
@@ -98,7 +98,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
9898
(args->tree ? &args->tree->object.oid : NULL), oid);
9999

100100
path += args->baselen;
101-
buffer = repo_read_object_file(the_repository, oid, type, sizep);
101+
buffer = odb_read_object(the_repository->objects, oid, type, sizep);
102102
if (buffer && S_ISREG(mode)) {
103103
struct strbuf buf = STRBUF_INIT;
104104
size_t size = 0;
@@ -215,7 +215,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
215215

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

attr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "read-cache-ll.h"
2323
#include "refs.h"
2424
#include "revision.h"
25-
#include "object-store.h"
25+
#include "odb.h"
2626
#include "setup.h"
2727
#include "thread-utils.h"
2828
#include "tree-walk.h"
@@ -779,7 +779,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,
779779
if (get_tree_entry(istate->repo, tree_oid, path, &oid, &mode))
780780
return NULL;
781781

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

bisect.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "commit-slab.h"
2121
#include "commit-reach.h"
2222
#include "object-name.h"
23-
#include "object-store.h"
23+
#include "odb.h"
2424
#include "path.h"
2525
#include "dir.h"
2626

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

blame.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "git-compat-util.h"
55
#include "refs.h"
6-
#include "object-store.h"
6+
#include "odb.h"
77
#include "cache-tree.h"
88
#include "mergesort.h"
99
#include "commit.h"
@@ -116,7 +116,7 @@ static void verify_working_tree_path(struct repository *r,
116116
unsigned short mode;
117117

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

@@ -277,7 +277,8 @@ static struct commit *fake_working_tree_commit(struct repository *r,
277277
convert_to_git(r->index, path, buf.buf, buf.len, &buf, 0);
278278
origin->file.ptr = buf.buf;
279279
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);
281282

282283
/*
283284
* Read the current index, replace the path entry with
@@ -1041,9 +1042,9 @@ static void fill_origin_blob(struct diff_options *opt,
10411042
&o->blob_oid, 1, &file->ptr, &file_size))
10421043
;
10431044
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);
10471048
file->size = file_size;
10481049

10491050
if (!file->ptr)
@@ -1245,7 +1246,7 @@ static int fill_blob_sha1_and_mode(struct repository *r,
12451246
return 0;
12461247
if (get_tree_entry(r, &origin->commit->object.oid, origin->path, &origin->blob_oid, &origin->mode))
12471248
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)
12491250
goto error_out;
12501251
return 0;
12511252
error_out:
@@ -2869,10 +2870,9 @@ void setup_scoreboard(struct blame_scoreboard *sb,
28692870
&sb->final_buf_size))
28702871
;
28712872
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);
28762876

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

builtin/backfill.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "tree.h"
1414
#include "tree-walk.h"
1515
#include "object.h"
16-
#include "object-store.h"
16+
#include "odb.h"
1717
#include "oid-array.h"
1818
#include "oidset.h"
1919
#include "promisor-remote.h"
@@ -67,8 +67,8 @@ static int fill_missing_blobs(const char *path UNUSED,
6767
return 0;
6868

6969
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))
7272
oid_array_append(&ctx->current_batch, &list->oid[i]);
7373
}
7474

0 commit comments

Comments
 (0)