Skip to content

Commit f3f520c

Browse files
committed
Merge branch 'ps/object-file-cleanup' into jch
* ps/object-file-cleanup: object-store: merge "object-store-ll.h" and "object-store.h" object-store: remove global array of cached objects object: split out functions relating to object store subsystem object-file: split out functions relating to index subsystem object-file: split up concerns of `HASH_*` flags object-file: split out functions relating to object store subsystem object-file: move `xmmap()` into "wrapper.c" object-file: move `git_open_cloexec()` to "compat/open.c" object-file: move `safe_create_leading_directories()` into "dir.c"
2 parents a0105d1 + 80c7c79 commit f3f520c

File tree

146 files changed

+2297
-2225
lines changed

Some content is hidden

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

146 files changed

+2297
-2225
lines changed

Diff for: Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,7 @@ LIB_OBJS += common-exit.o
991991
LIB_OBJS += common-init.o
992992
LIB_OBJS += compat/nonblock.o
993993
LIB_OBJS += compat/obstack.o
994+
LIB_OBJS += compat/open.o
994995
LIB_OBJS += compat/terminal.o
995996
LIB_OBJS += compiler-tricks/not-constant.o
996997
LIB_OBJS += config.o
@@ -1082,6 +1083,7 @@ LIB_OBJS += notes.o
10821083
LIB_OBJS += object-file-convert.o
10831084
LIB_OBJS += object-file.o
10841085
LIB_OBJS += object-name.o
1086+
LIB_OBJS += object-store.o
10851087
LIB_OBJS += object.o
10861088
LIB_OBJS += oid-array.o
10871089
LIB_OBJS += oidmap.o
@@ -1809,7 +1811,6 @@ ifdef FREAD_READS_DIRECTORIES
18091811
endif
18101812
ifdef OPEN_RETURNS_EINTR
18111813
COMPAT_CFLAGS += -DOPEN_RETURNS_EINTR
1812-
COMPAT_OBJS += compat/open.o
18131814
endif
18141815
ifdef NO_SYMLINK_HEAD
18151816
BASIC_CFLAGS += -DNO_SYMLINK_HEAD

Diff for: apply.c

+1-1
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-ll.h"
17+
#include "object-store.h"
1818
#include "delta.h"
1919
#include "diff.h"
2020
#include "dir.h"

Diff for: archive-tar.c

+1-1
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-ll.h"
14+
#include "object-store.h"
1515
#include "strbuf.h"
1616
#include "streaming.h"
1717
#include "run-command.h"

Diff for: archive-zip.c

+1-1
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-ll.h"
15+
#include "object-store.h"
1616
#include "strbuf.h"
1717
#include "userdiff.h"
1818
#include "write-or-die.h"

Diff for: archive.c

+1-1
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-ll.h"
17+
#include "object-store.h"
1818
#include "commit.h"
1919
#include "tree.h"
2020
#include "tree-walk.h"

Diff for: attr.c

+1-1
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-ll.h"
25+
#include "object-store.h"
2626
#include "setup.h"
2727
#include "thread-utils.h"
2828
#include "tree-walk.h"

Diff for: bisect.c

+1-1
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-ll.h"
23+
#include "object-store.h"
2424
#include "path.h"
2525
#include "dir.h"
2626

Diff for: blame.c

+2-2
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-ll.h"
6+
#include "object-store.h"
77
#include "cache-tree.h"
88
#include "mergesort.h"
99
#include "commit.h"
@@ -277,7 +277,7 @@ 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(buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
280+
pretend_object_file(the_repository, buf.buf, buf.len, OBJ_BLOB, &origin->blob_oid);
281281

282282
/*
283283
* Read the current index, replace the path entry with

Diff for: builtin/backfill.c

+1-1
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-ll.h"
16+
#include "object-store.h"
1717
#include "oid-array.h"
1818
#include "oidset.h"
1919
#include "promisor-remote.h"

Diff for: builtin/blame.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "line-log.h"
2929
#include "progress.h"
3030
#include "object-name.h"
31-
#include "object-store-ll.h"
31+
#include "object-store.h"
3232
#include "pager.h"
3333
#include "blame.h"
3434
#include "refs.h"

Diff for: builtin/bugreport.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#define USE_THE_REPOSITORY_VARIABLE
22
#include "builtin.h"
33
#include "abspath.h"
4+
#include "dir.h"
45
#include "editor.h"
56
#include "gettext.h"
67
#include "parse-options.h"
@@ -10,7 +11,6 @@
1011
#include "hook.h"
1112
#include "hook-list.h"
1213
#include "diagnose.h"
13-
#include "object-file.h"
1414
#include "setup.h"
1515
#include "version.h"
1616

Diff for: builtin/cat-file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "pack-bitmap.h"
2525
#include "object-file.h"
2626
#include "object-name.h"
27-
#include "object-store-ll.h"
27+
#include "object-store.h"
2828
#include "replace-object.h"
2929
#include "promisor-remote.h"
3030
#include "mailmap.h"

Diff for: builtin/checkout.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
#include "lockfile.h"
1919
#include "mem-pool.h"
2020
#include "merge-ort-wrappers.h"
21+
#include "object-file.h"
2122
#include "object-name.h"
22-
#include "object-store-ll.h"
23+
#include "object-store.h"
2324
#include "parse-options.h"
2425
#include "path.h"
2526
#include "preload-index.h"

Diff for: builtin/clone.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "refs.h"
2626
#include "refspec.h"
2727
#include "object-file.h"
28-
#include "object-store-ll.h"
28+
#include "object-store.h"
2929
#include "tree.h"
3030
#include "tree-walk.h"
3131
#include "unpack-trees.h"

Diff for: builtin/commit-graph.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "hex.h"
77
#include "parse-options.h"
88
#include "commit-graph.h"
9-
#include "object-store-ll.h"
9+
#include "object-store.h"
1010
#include "progress.h"
1111
#include "replace-object.h"
1212
#include "strbuf.h"

Diff for: builtin/commit-tree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "gettext.h"
1010
#include "hex.h"
1111
#include "object-name.h"
12-
#include "object-store-ll.h"
12+
#include "object-store.h"
1313

1414
#include "commit.h"
1515
#include "parse-options.h"

Diff for: builtin/count-objects.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "parse-options.h"
1313
#include "quote.h"
1414
#include "packfile.h"
15-
#include "object-store-ll.h"
15+
#include "object-store.h"
1616

1717
static unsigned long garbage;
1818
static off_t size_garbage;

Diff for: builtin/credential-cache--daemon.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#define USE_THE_REPOSITORY_VARIABLE
22
#include "builtin.h"
33
#include "abspath.h"
4+
#include "dir.h"
45
#include "gettext.h"
5-
#include "object-file.h"
66
#include "parse-options.h"
77

88
#ifndef NO_UNIX_SOCKETS

Diff for: builtin/describe.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "setup.h"
2020
#include "strvec.h"
2121
#include "run-command.h"
22-
#include "object-store-ll.h"
22+
#include "object-store.h"
2323
#include "list-objects.h"
2424
#include "commit-slab.h"
2525
#include "wildmatch.h"

Diff for: builtin/diagnose.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
#include "builtin.h"
44
#include "abspath.h"
5+
#include "dir.h"
56
#include "gettext.h"
6-
#include "object-file.h"
77
#include "parse-options.h"
88
#include "diagnose.h"
99

Diff for: builtin/difftool.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
#include "gettext.h"
2323
#include "hex.h"
2424
#include "parse-options.h"
25-
#include "read-cache-ll.h"
25+
#include "read-cache.h"
2626
#include "repository.h"
2727
#include "sparse-index.h"
2828
#include "strvec.h"
2929
#include "strbuf.h"
3030
#include "lockfile.h"
3131
#include "object-file.h"
32-
#include "object-store-ll.h"
32+
#include "object-store.h"
3333
#include "dir.h"
3434
#include "entry.h"
3535
#include "setup.h"

Diff for: builtin/fast-export.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "refs.h"
1515
#include "refspec.h"
1616
#include "object-file.h"
17-
#include "object-store-ll.h"
17+
#include "object-store.h"
1818
#include "commit.h"
1919
#include "object.h"
2020
#include "tag.h"

Diff for: builtin/fast-import.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include "packfile.h"
2525
#include "object-file.h"
2626
#include "object-name.h"
27-
#include "object-store-ll.h"
27+
#include "object-store.h"
2828
#include "mem-pool.h"
2929
#include "commit-reach.h"
3030
#include "khash.h"

Diff for: builtin/fetch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "refs.h"
1515
#include "refspec.h"
1616
#include "object-name.h"
17-
#include "object-store-ll.h"
17+
#include "object-store.h"
1818
#include "oidset.h"
1919
#include "oid-array.h"
2020
#include "commit.h"

Diff for: builtin/fsck.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#define USE_THE_REPOSITORY_VARIABLE
22
#include "builtin.h"
3+
#include "dir.h"
34
#include "gettext.h"
45
#include "hex.h"
56
#include "config.h"
@@ -17,7 +18,7 @@
1718
#include "packfile.h"
1819
#include "object-file.h"
1920
#include "object-name.h"
20-
#include "object-store-ll.h"
21+
#include "object-store.h"
2122
#include "path.h"
2223
#include "read-cache-ll.h"
2324
#include "replace-object.h"

Diff for: builtin/gc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "builtin.h"
1717
#include "abspath.h"
1818
#include "date.h"
19+
#include "dir.h"
1920
#include "environment.h"
2021
#include "hex.h"
2122
#include "config.h"
@@ -28,8 +29,7 @@
2829
#include "commit.h"
2930
#include "commit-graph.h"
3031
#include "packfile.h"
31-
#include "object-file.h"
32-
#include "object-store-ll.h"
32+
#include "object-store.h"
3333
#include "pack.h"
3434
#include "pack-objects.h"
3535
#include "path.h"

Diff for: builtin/grep.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "submodule-config.h"
2727
#include "object-file.h"
2828
#include "object-name.h"
29-
#include "object-store-ll.h"
29+
#include "object-store.h"
3030
#include "packfile.h"
3131
#include "pager.h"
3232
#include "path.h"

Diff for: builtin/hash-object.c

+19-7
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111
#include "gettext.h"
1212
#include "hex.h"
1313
#include "object-file.h"
14-
#include "object-store-ll.h"
14+
#include "object-store.h"
1515
#include "blob.h"
1616
#include "quote.h"
1717
#include "parse-options.h"
18+
#include "read-cache.h"
1819
#include "setup.h"
1920
#include "strbuf.h"
2021
#include "write-or-die.h"
2122

23+
enum {
24+
HASH_OBJECT_CHECK = (1 << 0),
25+
HASH_OBJECT_WRITE = (1 << 1),
26+
};
27+
2228
/*
2329
* This is to create corrupt objects for debugging and as such it
2430
* needs to bypass the data conversion performed by, and the type
@@ -33,7 +39,7 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig
3339
ret = -1;
3440
else
3541
ret = write_object_file_literally(buf.buf, buf.len, type, oid,
36-
flags);
42+
(flags & HASH_OBJECT_WRITE) ? WRITE_OBJECT_FILE_PERSIST : 0);
3743
close(fd);
3844
strbuf_release(&buf);
3945
return ret;
@@ -42,15 +48,21 @@ static int hash_literally(struct object_id *oid, int fd, const char *type, unsig
4248
static void hash_fd(int fd, const char *type, const char *path, unsigned flags,
4349
int literally)
4450
{
51+
unsigned int index_flags = 0;
4552
struct stat st;
4653
struct object_id oid;
4754

55+
if (flags & HASH_OBJECT_WRITE)
56+
index_flags |= INDEX_WRITE_OBJECT;
57+
if (flags & HASH_OBJECT_CHECK)
58+
index_flags |= INDEX_FORMAT_CHECK;
59+
4860
if (fstat(fd, &st) < 0 ||
4961
(literally
5062
? hash_literally(&oid, fd, type, flags)
5163
: index_fd(the_repository->index, &oid, fd, &st,
52-
type_from_string(type), path, flags)))
53-
die((flags & HASH_WRITE_OBJECT)
64+
type_from_string(type), path, index_flags)))
65+
die((flags & HASH_OBJECT_WRITE)
5466
? "Unable to add %s to database"
5567
: "Unable to hash %s", path);
5668
printf("%s\n", oid_to_hex(&oid));
@@ -102,13 +114,13 @@ int cmd_hash_object(int argc,
102114
int no_filters = 0;
103115
int literally = 0;
104116
int nongit = 0;
105-
unsigned flags = HASH_FORMAT_CHECK;
117+
unsigned flags = HASH_OBJECT_CHECK;
106118
const char *vpath = NULL;
107119
char *vpath_free = NULL;
108120
const struct option hash_object_options[] = {
109121
OPT_STRING('t', NULL, &type, N_("type"), N_("object type")),
110122
OPT_BIT('w', NULL, &flags, N_("write the object into the object database"),
111-
HASH_WRITE_OBJECT),
123+
HASH_OBJECT_WRITE),
112124
OPT_COUNTUP( 0 , "stdin", &hashstdin, N_("read the object from stdin")),
113125
OPT_BOOL( 0 , "stdin-paths", &stdin_paths, N_("read file names from stdin")),
114126
OPT_BOOL( 0 , "no-filters", &no_filters, N_("store file as is without filters")),
@@ -122,7 +134,7 @@ int cmd_hash_object(int argc,
122134
argc = parse_options(argc, argv, prefix, hash_object_options,
123135
hash_object_usage, 0);
124136

125-
if (flags & HASH_WRITE_OBJECT)
137+
if (flags & HASH_OBJECT_WRITE)
126138
prefix = setup_git_directory();
127139
else
128140
prefix = setup_git_directory_gently(&nongit);

Diff for: builtin/index-pack.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "packfile.h"
2222
#include "pack-revindex.h"
2323
#include "object-file.h"
24-
#include "object-store-ll.h"
24+
#include "object-store.h"
2525
#include "oid-array.h"
2626
#include "oidset.h"
2727
#include "path.h"

0 commit comments

Comments
 (0)