Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-06-30 02:43:20 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-30 02:43:21 +0300
commita1264a08a1a6e0cd7e510c899cd0ba42dcf1045d (patch)
treed6a22be96e39e1284d9838ce5e8ad58941c5099b /builtin
parentb2166b0d496c2f3df96929da300039a01227e719 (diff)
parent68d686460f58e45f2eb080e0cdf314987eca5ce5 (diff)
Merge branch 'en/header-split-cache-h-part-3'
Header files cleanup. * en/header-split-cache-h-part-3: (28 commits) fsmonitor-ll.h: split this header out of fsmonitor.h hash-ll, hashmap: move oidhash() to hash-ll object-store-ll.h: split this header out of object-store.h khash: name the structs that khash declares merge-ll: rename from ll-merge git-compat-util.h: remove unneccessary include of wildmatch.h builtin.h: remove unneccessary includes list-objects-filter-options.h: remove unneccessary include diff.h: remove unnecessary include of oidset.h repository: remove unnecessary include of path.h log-tree: replace include of revision.h with simple forward declaration cache.h: remove this no-longer-used header read-cache*.h: move declarations for read-cache.c functions from cache.h repository.h: move declaration of the_index from cache.h merge.h: move declarations for merge.c from cache.h diff.h: move declaration for global in diff.c from cache.h preload-index.h: move declarations for preload-index.c from elsewhere sparse-index.h: move declarations for sparse-index.c from cache.h name-hash.h: move declarations for name-hash.c from cache.h run-command.h: move declarations for run-command.c from cache.h ...
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c105
-rw-r--r--builtin/am.c5
-rw-r--r--builtin/apply.c1
-rw-r--r--builtin/archive.c1
-rw-r--r--builtin/bisect.c2
-rw-r--r--builtin/blame.c2
-rw-r--r--builtin/branch.c4
-rw-r--r--builtin/bundle.c1
-rw-r--r--builtin/cat-file.c5
-rw-r--r--builtin/check-attr.c1
-rw-r--r--builtin/check-ignore.c1
-rw-r--r--builtin/check-mailmap.c1
-rw-r--r--builtin/check-ref-format.c3
-rw-r--r--builtin/checkout--worker.c1
-rw-r--r--builtin/checkout-index.c2
-rw-r--r--builtin/checkout.c9
-rw-r--r--builtin/clean.c3
-rw-r--r--builtin/clone.c6
-rw-r--r--builtin/column.c1
-rw-r--r--builtin/commit-graph.c3
-rw-r--r--builtin/commit-tree.c5
-rw-r--r--builtin/commit.c10
-rw-r--r--builtin/config.c1
-rw-r--r--builtin/count-objects.c6
-rw-r--r--builtin/credential-cache.c1
-rw-r--r--builtin/describe.c7
-rw-r--r--builtin/diff-files.c5
-rw-r--r--builtin/diff-index.c6
-rw-r--r--builtin/diff-tree.c5
-rw-r--r--builtin/diff.c5
-rw-r--r--builtin/difftool.c7
-rw-r--r--builtin/fast-export.c3
-rw-r--r--builtin/fast-import.c4
-rw-r--r--builtin/fetch.c6
-rw-r--r--builtin/for-each-ref.c2
-rw-r--r--builtin/for-each-repo.c3
-rw-r--r--builtin/fsck.c6
-rw-r--r--builtin/fsmonitor--daemon.c4
-rw-r--r--builtin/gc.c3
-rw-r--r--builtin/get-tar-commit-id.c3
-rw-r--r--builtin/grep.c7
-rw-r--r--builtin/hash-object.c3
-rw-r--r--builtin/help.c3
-rw-r--r--builtin/hook.c1
-rw-r--r--builtin/index-pack.c3
-rw-r--r--builtin/init-db.c474
-rw-r--r--builtin/interpret-trailers.c1
-rw-r--r--builtin/log.c2
-rw-r--r--builtin/ls-files.c143
-rw-r--r--builtin/ls-remote.c2
-rw-r--r--builtin/ls-tree.c6
-rw-r--r--builtin/mailinfo.c3
-rw-r--r--builtin/mailsplit.c1
-rw-r--r--builtin/merge-base.c1
-rw-r--r--builtin/merge-file.c1
-rw-r--r--builtin/merge-index.c2
-rw-r--r--builtin/merge-ours.c1
-rw-r--r--builtin/merge-recursive.c1
-rw-r--r--builtin/merge-tree.c2
-rw-r--r--builtin/merge.c5
-rw-r--r--builtin/mktag.c3
-rw-r--r--builtin/mktree.c3
-rw-r--r--builtin/multi-pack-index.c4
-rw-r--r--builtin/mv.c2
-rw-r--r--builtin/name-rev.c1
-rw-r--r--builtin/notes.c6
-rw-r--r--builtin/pack-objects.c2
-rw-r--r--builtin/pack-redundant.c2
-rw-r--r--builtin/patch-id.c2
-rw-r--r--builtin/prune.c7
-rw-r--r--builtin/pull.c6
-rw-r--r--builtin/push.c3
-rw-r--r--builtin/range-diff.c2
-rw-r--r--builtin/read-tree.c4
-rw-r--r--builtin/rebase.c1
-rw-r--r--builtin/receive-pack.c3
-rw-r--r--builtin/reflog.c2
-rw-r--r--builtin/remote.c3
-rw-r--r--builtin/repack.c3
-rw-r--r--builtin/replace.c7
-rw-r--r--builtin/rerere.c1
-rw-r--r--builtin/reset.c3
-rw-r--r--builtin/rev-list.c5
-rw-r--r--builtin/rev-parse.c6
-rw-r--r--builtin/revert.c1
-rw-r--r--builtin/rm.c2
-rw-r--r--builtin/shortlog.c2
-rw-r--r--builtin/show-branch.c4
-rw-r--r--builtin/show-index.c1
-rw-r--r--builtin/show-ref.c3
-rw-r--r--builtin/sparse-checkout.c1
-rw-r--r--builtin/stash.c4
-rw-r--r--builtin/stripspace.c1
-rw-r--r--builtin/submodule--helper.c7
-rw-r--r--builtin/symbolic-ref.c1
-rw-r--r--builtin/tag.c6
-rw-r--r--builtin/unpack-file.c2
-rw-r--r--builtin/unpack-objects.c3
-rw-r--r--builtin/update-index.c5
-rw-r--r--builtin/update-ref.c3
-rw-r--r--builtin/update-server-info.c3
-rw-r--r--builtin/upload-archive.c2
-rw-r--r--builtin/upload-pack.c2
-rw-r--r--builtin/verify-commit.c5
-rw-r--r--builtin/verify-pack.c2
-rw-r--r--builtin/verify-tag.c3
-rw-r--r--builtin/worktree.c5
-rw-r--r--builtin/write-tree.c1
108 files changed, 203 insertions, 858 deletions
diff --git a/builtin/add.c b/builtin/add.c
index 6137e7b4ad..b75c59d5a0 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -4,10 +4,9 @@
* Copyright (C) 2006 Linus Torvalds
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "advice.h"
#include "config.h"
-#include "builtin.h"
#include "lockfile.h"
#include "editor.h"
#include "dir.h"
@@ -17,8 +16,12 @@
#include "cache-tree.h"
#include "run-command.h"
#include "parse-options.h"
+#include "path.h"
+#include "preload-index.h"
#include "diff.h"
#include "diffcore.h"
+#include "read-cache.h"
+#include "repository.h"
#include "revision.h"
#include "bulk-checkin.h"
#include "strvec.h"
@@ -36,11 +39,6 @@ static int pathspec_file_nul;
static int include_sparse;
static const char *pathspec_from_file;
-struct update_callback_data {
- int flags;
- int add_errors;
-};
-
static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
{
int i, ret = 0;
@@ -69,95 +67,6 @@ static int chmod_pathspec(struct pathspec *pathspec, char flip, int show_only)
return ret;
}
-static int fix_unmerged_status(struct diff_filepair *p,
- struct update_callback_data *data)
-{
- if (p->status != DIFF_STATUS_UNMERGED)
- return p->status;
- if (!(data->flags & ADD_CACHE_IGNORE_REMOVAL) && !p->two->mode)
- /*
- * This is not an explicit add request, and the
- * path is missing from the working tree (deleted)
- */
- return DIFF_STATUS_DELETED;
- else
- /*
- * Either an explicit add request, or path exists
- * in the working tree. An attempt to explicitly
- * add a path that does not exist in the working tree
- * will be caught as an error by the caller immediately.
- */
- return DIFF_STATUS_MODIFIED;
-}
-
-static void update_callback(struct diff_queue_struct *q,
- struct diff_options *opt UNUSED, void *cbdata)
-{
- int i;
- struct update_callback_data *data = cbdata;
-
- for (i = 0; i < q->nr; i++) {
- struct diff_filepair *p = q->queue[i];
- const char *path = p->one->path;
-
- if (!include_sparse && !path_in_sparse_checkout(path, &the_index))
- continue;
-
- switch (fix_unmerged_status(p, data)) {
- default:
- die(_("unexpected diff status %c"), p->status);
- case DIFF_STATUS_MODIFIED:
- case DIFF_STATUS_TYPE_CHANGED:
- if (add_file_to_index(&the_index, path, data->flags)) {
- if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
- die(_("updating files failed"));
- data->add_errors++;
- }
- break;
- case DIFF_STATUS_DELETED:
- if (data->flags & ADD_CACHE_IGNORE_REMOVAL)
- break;
- if (!(data->flags & ADD_CACHE_PRETEND))
- remove_file_from_index(&the_index, path);
- if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
- printf(_("remove '%s'\n"), path);
- break;
- }
- }
-}
-
-int add_files_to_cache(const char *prefix,
- const struct pathspec *pathspec, int flags)
-{
- struct update_callback_data data;
- struct rev_info rev;
-
- memset(&data, 0, sizeof(data));
- data.flags = flags;
-
- repo_init_revisions(the_repository, &rev, prefix);
- setup_revisions(0, NULL, &rev, NULL);
- if (pathspec)
- copy_pathspec(&rev.prune_data, pathspec);
- rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
- rev.diffopt.format_callback = update_callback;
- rev.diffopt.format_callback_data = &data;
- rev.diffopt.flags.override_submodule_config = 1;
- rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
-
- /*
- * Use an ODB transaction to optimize adding multiple objects.
- * This function is invoked from commands other than 'add', which
- * may not have their own transaction active.
- */
- begin_odb_transaction();
- run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
- end_odb_transaction();
-
- release_revisions(&rev);
- return !!data.add_errors;
-}
-
static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
{
int i, retval = 0;
@@ -640,7 +549,9 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (add_renormalize)
exit_status |= renormalize_tracked_files(&pathspec, flags);
else
- exit_status |= add_files_to_cache(prefix, &pathspec, flags);
+ exit_status |= add_files_to_cache(the_repository, prefix,
+ &pathspec, include_sparse,
+ flags);
if (add_new_files)
exit_status |= add_files(&dir, flags);
diff --git a/builtin/am.c b/builtin/am.c
index 5c83f2e003..a78daa6971 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -4,11 +4,10 @@
* Based on git-am.sh by Junio C Hamano.
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "abspath.h"
#include "advice.h"
#include "config.h"
-#include "builtin.h"
#include "editor.h"
#include "environment.h"
#include "exec-cmd.h"
@@ -29,6 +28,7 @@
#include "unpack-trees.h"
#include "branch.h"
#include "object-name.h"
+#include "preload-index.h"
#include "sequencer.h"
#include "revision.h"
#include "merge-recursive.h"
@@ -41,6 +41,7 @@
#include "string-list.h"
#include "packfile.h"
#include "pager.h"
+#include "path.h"
#include "repository.h"
#include "pretty.h"
#include "wrapper.h"
diff --git a/builtin/apply.c b/builtin/apply.c
index e3ff02a09e..c18b7ea5d3 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1,4 +1,3 @@
-#include "cache.h"
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
diff --git a/builtin/archive.c b/builtin/archive.c
index b0eaa3c14a..90761fdfee 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -2,7 +2,6 @@
* Copyright (c) 2006 Franck Bui-Huu
* Copyright (c) 2006 Rene Scharfe
*/
-#include "cache.h"
#include "builtin.h"
#include "archive.h"
#include "gettext.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 4812450c39..6478df3489 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "copy.h"
#include "environment.h"
#include "gettext.h"
@@ -12,6 +11,7 @@
#include "strvec.h"
#include "run-command.h"
#include "oid-array.h"
+#include "path.h"
#include "prompt.h"
#include "quote.h"
#include "revision.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index 2df6039a6e..e811e7fbfb 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -29,7 +29,7 @@
#include "dir.h"
#include "progress.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "pager.h"
#include "blame.h"
#include "refs.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 075e580d22..b57e4c6e61 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -5,20 +5,20 @@
* Based on git-branch.sh by Junio C Hamano.
*/
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "color.h"
#include "editor.h"
#include "environment.h"
#include "refs.h"
#include "commit.h"
-#include "builtin.h"
#include "gettext.h"
#include "object-name.h"
#include "remote.h"
#include "parse-options.h"
#include "branch.h"
#include "diff.h"
+#include "path.h"
#include "revision.h"
#include "string-list.h"
#include "column.h"
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 44113389d7..3f63631c03 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -6,7 +6,6 @@
#include "parse-options.h"
#include "pkt-line.h"
#include "repository.h"
-#include "cache.h"
#include "bundle.h"
/*
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 7ff56d5a78..ab8ac105e3 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -4,11 +4,10 @@
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "alloc.h"
#include "config.h"
#include "convert.h"
-#include "builtin.h"
#include "diff.h"
#include "environment.h"
#include "gettext.h"
@@ -22,7 +21,7 @@
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "replace-object.h"
#include "promisor-remote.h"
#include "mailmap.h"
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index e27b86d150..b22ff748c3 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -1,6 +1,5 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "attr.h"
#include "environment.h"
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index e4b78782a3..906cd96753 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -1,6 +1,5 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "dir.h"
#include "gettext.h"
diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c
index 002d2941e9..b8a05b8e07 100644
--- a/builtin/check-mailmap.c
+++ b/builtin/check-mailmap.c
@@ -4,6 +4,7 @@
#include "ident.h"
#include "mailmap.h"
#include "parse-options.h"
+#include "strbuf.h"
#include "string-list.h"
#include "write-or-die.h"
diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c
index 57f0505070..5eb6bdc3f6 100644
--- a/builtin/check-ref-format.c
+++ b/builtin/check-ref-format.c
@@ -2,9 +2,8 @@
* GIT - The information manager from hell
*/
-#include "cache.h"
-#include "refs.h"
#include "builtin.h"
+#include "refs.h"
#include "setup.h"
#include "strbuf.h"
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index 2120dd1d30..c655dc4b13 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -6,6 +6,7 @@
#include "parallel-checkout.h"
#include "parse-options.h"
#include "pkt-line.h"
+#include "read-cache-ll.h"
static void packet_to_pc_item(const char *buffer, int len,
struct parallel_checkout_item *pc_item)
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 9375a05539..f62f13f2b5 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -16,7 +16,9 @@
#include "parse-options.h"
#include "entry.h"
#include "parallel-checkout.h"
+#include "read-cache-ll.h"
#include "setup.h"
+#include "sparse-index.h"
#define CHECKOUT_ALL 4
static int nul_term_line;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 715eeb5048..fd6ee8c272 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -13,13 +13,16 @@
#include "gettext.h"
#include "hex.h"
#include "hook.h"
-#include "ll-merge.h"
+#include "merge-ll.h"
#include "lockfile.h"
#include "mem-pool.h"
#include "merge-recursive.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "parse-options.h"
+#include "path.h"
+#include "preload-index.h"
+#include "read-cache.h"
#include "refs.h"
#include "remote.h"
#include "resolve-undo.h"
@@ -861,7 +864,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
* entries in the index.
*/
- add_files_to_cache(NULL, NULL, 0);
+ add_files_to_cache(the_repository, NULL, NULL, 0, 0);
init_merge_options(&o, the_repository);
o.verbosity = 0;
work = write_in_core_index_as_tree(the_repository);
diff --git a/builtin/clean.c b/builtin/clean.c
index 78852d28ce..1bb6b7965c 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -9,11 +9,12 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
-#include "cache.h"
#include "config.h"
#include "dir.h"
#include "gettext.h"
#include "parse-options.h"
+#include "path.h"
+#include "read-cache-ll.h"
#include "repository.h"
#include "setup.h"
#include "string-list.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 15f9912b4c..687a686269 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -23,7 +23,7 @@
#include "refs.h"
#include "refspec.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "tree.h"
#include "tree-walk.h"
#include "unpack-trees.h"
@@ -39,6 +39,7 @@
#include "setup.h"
#include "connected.h"
#include "packfile.h"
+#include "path.h"
#include "pkt-line.h"
#include "list-objects-filter-options.h"
#include "hook.h"
@@ -930,6 +931,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
int submodule_progress;
int filter_submodules = 0;
int hash_algo;
+ const int do_not_override_repo_unix_permissions = -1;
struct transport_ls_refs_options transport_ls_refs_options =
TRANSPORT_LS_REFS_OPTIONS_INIT;
@@ -1097,7 +1099,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
}
init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN, NULL,
- INIT_DB_QUIET);
+ do_not_override_repo_unix_permissions, INIT_DB_QUIET);
if (real_git_dir) {
free((char *)git_dir);
diff --git a/builtin/column.c b/builtin/column.c
index de623a16c2..ce13ff0baa 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "strbuf.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index dd732b3534..73dbcf9d20 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "commit.h"
#include "config.h"
#include "dir.h"
#include "environment.h"
@@ -8,7 +9,7 @@
#include "parse-options.h"
#include "repository.h"
#include "commit-graph.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "progress.h"
#include "replace-object.h"
#include "tag.h"
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index d1d251c3de..02625e7176 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -3,16 +3,15 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "repository.h"
#include "commit.h"
#include "tree.h"
-#include "builtin.h"
#include "utf8.h"
#include "gpg-interface.h"
#include "parse-options.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 65a5c0e29d..a9e8c62c85 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -6,7 +6,7 @@
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "advice.h"
#include "config.h"
#include "lockfile.h"
@@ -15,7 +15,6 @@
#include "dir.h"
#include "editor.h"
#include "environment.h"
-#include "builtin.h"
#include "diff.h"
#include "diffcore.h"
#include "commit.h"
@@ -30,6 +29,9 @@
#include "utf8.h"
#include "object-name.h"
#include "parse-options.h"
+#include "path.h"
+#include "preload-index.h"
+#include "read-cache.h"
#include "string-list.h"
#include "rerere.h"
#include "unpack-trees.h"
@@ -38,6 +40,7 @@
#include "gpg-interface.h"
#include "column.h"
#include "sequencer.h"
+#include "sparse-index.h"
#include "mailmap.h"
#include "help.h"
#include "commit-reach.h"
@@ -447,7 +450,8 @@ static const char *prepare_index(const char **argv, const char *prefix,
if (all || (also && pathspec.nr)) {
repo_hold_locked_index(the_repository, &index_lock,
LOCK_DIE_ON_ERROR);
- add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
+ add_files_to_cache(the_repository, also ? prefix : NULL,
+ &pathspec, 0, 0);
refresh_cache_or_die(refresh_flags);
cache_tree_update(&the_index, WRITE_TREE_SILENT);
if (write_locked_index(&the_index, &index_lock, 0))
diff --git a/builtin/config.c b/builtin/config.c
index d40fddb042..6599f88b24 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -13,6 +13,7 @@
#include "path.h"
#include "quote.h"
#include "setup.h"
+#include "strbuf.h"
#include "worktree.h"
#include "wrapper.h"
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index f3d8f1bcbb..97cdfb0ac5 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -4,17 +4,17 @@
* Copyright (c) 2006 Junio C Hamano
*/
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
+#include "path.h"
#include "repository.h"
-#include "builtin.h"
#include "parse-options.h"
#include "quote.h"
#include "packfile.h"
-#include "object-store.h"
+#include "object-store-ll.h"
static unsigned long garbage;
static off_t size_garbage;
diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c
index 0ffacfdd83..ff3a47badb 100644
--- a/builtin/credential-cache.c
+++ b/builtin/credential-cache.c
@@ -2,6 +2,7 @@
#include "gettext.h"
#include "parse-options.h"
#include "path.h"
+#include "strbuf.h"
#include "wrapper.h"
#include "write-or-die.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index 55b4baaa22..7ce23e1b8e 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -1,5 +1,5 @@
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
@@ -9,19 +9,20 @@
#include "tag.h"
#include "blob.h"
#include "refs.h"
-#include "builtin.h"
#include "exec-cmd.h"
#include "object-name.h"
#include "parse-options.h"
+#include "read-cache-ll.h"
#include "revision.h"
#include "diff.h"
#include "hashmap.h"
#include "setup.h"
#include "strvec.h"
#include "run-command.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "list-objects.h"
#include "commit-slab.h"
+#include "wildmatch.h"
#define MAX_TAGS (FLAG_BITS - 1)
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 360464e6ef..50330b8dd2 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -3,13 +3,14 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "diff-merges.h"
#include "commit.h"
+#include "preload-index.h"
+#include "repository.h"
#include "revision.h"
-#include "builtin.h"
#include "submodule.h"
static const char diff_files_usage[] =
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index b9a19bb7d3..9db7139b83 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -1,11 +1,13 @@
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "diff-merges.h"
#include "commit.h"
+#include "preload-index.h"
+#include "repository.h"
#include "revision.h"
-#include "builtin.h"
#include "setup.h"
+#include "sparse-index.h"
#include "submodule.h"
static const char diff_cache_usage[] =
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index c0540317fb..d62caa6c8b 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -1,14 +1,15 @@
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "commit.h"
#include "gettext.h"
#include "hex.h"
#include "log-tree.h"
-#include "builtin.h"
#include "submodule.h"
+#include "read-cache-ll.h"
#include "repository.h"
+#include "revision.h"
#include "tree.h"
static struct rev_info log_tree_opt;
diff --git a/builtin/diff.c b/builtin/diff.c
index 7b64659fe7..b19530c996 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -4,7 +4,7 @@
* Copyright (c) 2006 Junio C Hamano
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "ewah/ewok.h"
#include "lockfile.h"
@@ -16,9 +16,10 @@
#include "diff.h"
#include "diff-merges.h"
#include "diffcore.h"
+#include "preload-index.h"
+#include "read-cache-ll.h"
#include "revision.h"
#include "log-tree.h"
-#include "builtin.h"
#include "setup.h"
#include "submodule.h"
#include "oid-array.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 0049342f5c..e2c9ab7d5d 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -12,22 +12,23 @@
* Copyright (C) 2016 Johannes Schindelin
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "abspath.h"
#include "config.h"
#include "copy.h"
-#include "builtin.h"
#include "run-command.h"
#include "environment.h"
#include "exec-cmd.h"
#include "gettext.h"
#include "hex.h"
#include "parse-options.h"
+#include "read-cache-ll.h"
+#include "sparse-index.h"
#include "strvec.h"
#include "strbuf.h"
#include "lockfile.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "dir.h"
#include "entry.h"
#include "setup.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 9a95f6a1a8..56dc69fac1 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -4,14 +4,13 @@
* Copyright (C) 2007 Johannes E. Schindelin
*/
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "refs.h"
#include "refspec.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "commit.h"
#include "object.h"
#include "tag.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index bbd9b2b3e7..2ee19c7373 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "abspath.h"
-#include "cache.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
@@ -13,6 +12,7 @@
#include "commit.h"
#include "delta.h"
#include "pack.h"
+#include "path.h"
#include "refs.h"
#include "csum-file.h"
#include "quote.h"
@@ -21,7 +21,7 @@
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "mem-pool.h"
#include "commit-reach.h"
#include "khash.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index e3871048cf..951a23d733 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1,7 +1,7 @@
/*
* "git fetch"
*/
-#include "cache.h"
+#include "builtin.h"
#include "advice.h"
#include "config.h"
#include "gettext.h"
@@ -11,11 +11,10 @@
#include "refs.h"
#include "refspec.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "oidset.h"
#include "oid-array.h"
#include "commit.h"
-#include "builtin.h"
#include "string-list.h"
#include "remote.h"
#include "transport.h"
@@ -29,6 +28,7 @@
#include "utf8.h"
#include "packfile.h"
#include "pager.h"
+#include "path.h"
#include "pkt-line.h"
#include "list-objects-filter-options.h"
#include "commit-reach.h"
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 695fc8f4a5..15409337f8 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -1,11 +1,11 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "refs.h"
#include "object.h"
#include "parse-options.h"
#include "ref-filter.h"
+#include "strbuf.h"
#include "strvec.h"
#include "commit-reach.h"
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c
index 37daf7bec1..28186b30f5 100644
--- a/builtin/for-each-repo.c
+++ b/builtin/for-each-repo.c
@@ -1,6 +1,5 @@
-#include "cache.h"
-#include "config.h"
#include "builtin.h"
+#include "config.h"
#include "gettext.h"
#include "parse-options.h"
#include "path.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index d9aa4db828..fa26462337 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "gettext.h"
#include "hex.h"
#include "repository.h"
@@ -21,10 +20,13 @@
#include "packfile.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
+#include "path.h"
+#include "read-cache-ll.h"
#include "replace-object.h"
#include "resolve-undo.h"
#include "run-command.h"
+#include "sparse-index.h"
#include "worktree.h"
#include "pack-revindex.h"
#include "pack-bitmap.h"
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index f6dd9a784c..74d1d6a585 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -5,15 +5,17 @@
#include "environment.h"
#include "gettext.h"
#include "parse-options.h"
-#include "fsmonitor.h"
+#include "fsmonitor-ll.h"
#include "fsmonitor-ipc.h"
#include "fsmonitor-path-utils.h"
+#include "fsmonitor-settings.h"
#include "compat/fsmonitor/fsm-health.h"
#include "compat/fsmonitor/fsm-listen.h"
#include "fsmonitor--daemon.h"
#include "simple-ipc.h"
#include "khash.h"
#include "pkt-line.h"
+#include "trace.h"
#include "trace2.h"
static const char * const builtin_fsmonitor__daemon_usage[] = {
diff --git a/builtin/gc.c b/builtin/gc.c
index f3942188a6..91eec7703a 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -27,9 +27,10 @@
#include "commit-graph.h"
#include "packfile.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "pack.h"
#include "pack-objects.h"
+#include "path.h"
#include "blob.h"
#include "tree.h"
#include "promisor-remote.h"
diff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c
index 564cfcac4f..9303e386cc 100644
--- a/builtin/get-tar-commit-id.c
+++ b/builtin/get-tar-commit-id.c
@@ -1,10 +1,9 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
-#include "cache.h"
+#include "builtin.h"
#include "commit.h"
#include "tar.h"
-#include "builtin.h"
#include "quote.h"
#include "wrapper.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index b86c754def..72e70b3a48 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2006 Junio C Hamano
*/
-#include "cache.h"
+#include "builtin.h"
#include "alloc.h"
#include "gettext.h"
#include "hex.h"
@@ -14,7 +14,6 @@
#include "commit.h"
#include "tag.h"
#include "tree-walk.h"
-#include "builtin.h"
#include "parse-options.h"
#include "string-list.h"
#include "run-command.h"
@@ -28,9 +27,11 @@
#include "submodule-config.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "packfile.h"
#include "pager.h"
+#include "path.h"
+#include "read-cache-ll.h"
#include "write-or-die.h"
static const char *grep_prefix;
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index a380121166..5ffec99dce 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -10,12 +10,13 @@
#include "gettext.h"
#include "hex.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "blob.h"
#include "quote.h"
#include "parse-options.h"
#include "exec-cmd.h"
#include "setup.h"
+#include "strbuf.h"
#include "write-or-die.h"
/*
diff --git a/builtin/help.c b/builtin/help.c
index d3cf4af3f6..e93533fb09 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -1,9 +1,8 @@
/*
* Builtin help command
*/
-#include "cache.h"
-#include "config.h"
#include "builtin.h"
+#include "config.h"
#include "exec-cmd.h"
#include "gettext.h"
#include "pager.h"
diff --git a/builtin/hook.c b/builtin/hook.c
index 88051795c7..09b51a6487 100644
--- a/builtin/hook.c
+++ b/builtin/hook.c
@@ -1,4 +1,3 @@
-#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "gettext.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index d0d8067510..c1250b070f 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -14,12 +14,13 @@
#include "progress.h"
#include "fsck.h"
#include "exec-cmd.h"
+#include "strbuf.h"
#include "streaming.h"
#include "thread-utils.h"
#include "packfile.h"
#include "pack-revindex.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "oid-array.h"
#include "replace-object.h"
#include "promisor-remote.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index aef4036105..0d8bd4d721 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -3,485 +3,18 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
-#include "cache.h"
+#include "builtin.h"
#include "abspath.h"
#include "config.h"
-#include "copy.h"
#include "environment.h"
#include "gettext.h"
-#include "refs.h"
-#include "builtin.h"
-#include "exec-cmd.h"
#include "object-file.h"
#include "parse-options.h"
#include "path.h"
#include "setup.h"
-#include "worktree.h"
+#include "strbuf.h"
#include "wrapper.h"
-#ifndef DEFAULT_GIT_TEMPLATE_DIR
-#define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates"
-#endif
-
-#ifdef NO_TRUSTABLE_FILEMODE
-#define TEST_FILEMODE 0
-#else
-#define TEST_FILEMODE 1
-#endif
-
-#define GIT_DEFAULT_HASH_ENVIRONMENT "GIT_DEFAULT_HASH"
-
-static int init_is_bare_repository = 0;
-static int init_shared_repository = -1;
-
-static void copy_templates_1(struct strbuf *path, struct strbuf *template_path,
- DIR *dir)
-{
- size_t path_baselen = path->len;
- size_t template_baselen = template_path->len;
- struct dirent *de;
-
- /* Note: if ".git/hooks" file exists in the repository being
- * re-initialized, /etc/core-git/templates/hooks/update would
- * cause "git init" to fail here. I think this is sane but
- * it means that the set of templates we ship by default, along
- * with the way the namespace under .git/ is organized, should
- * be really carefully chosen.
- */
- safe_create_dir(path->buf, 1);
- while ((de = readdir(dir)) != NULL) {
- struct stat st_git, st_template;
- int exists = 0;
-
- strbuf_setlen(path, path_baselen);
- strbuf_setlen(template_path, template_baselen);
-
- if (de->d_name[0] == '.')
- continue;
- strbuf_addstr(path, de->d_name);
- strbuf_addstr(template_path, de->d_name);
- if (lstat(path->buf, &st_git)) {
- if (errno != ENOENT)
- die_errno(_("cannot stat '%s'"), path->buf);
- }
- else
- exists = 1;
-
- if (lstat(template_path->buf, &st_template))
- die_errno(_("cannot stat template '%s'"), template_path->buf);
-
- if (S_ISDIR(st_template.st_mode)) {
- DIR *subdir = opendir(template_path->buf);
- if (!subdir)
- die_errno(_("cannot opendir '%s'"), template_path->buf);
- strbuf_addch(path, '/');
- strbuf_addch(template_path, '/');
- copy_templates_1(path, template_path, subdir);
- closedir(subdir);
- }
- else if (exists)
- continue;
- else if (S_ISLNK(st_template.st_mode)) {
- struct strbuf lnk = STRBUF_INIT;
- if (strbuf_readlink(&lnk, template_path->buf,
- st_template.st_size) < 0)
- die_errno(_("cannot readlink '%s'"), template_path->buf);
- if (symlink(lnk.buf, path->buf))
- die_errno(_("cannot symlink '%s' '%s'"),
- lnk.buf, path->buf);
- strbuf_release(&lnk);
- }
- else if (S_ISREG(st_template.st_mode)) {
- if (copy_file(path->buf, template_path->buf, st_template.st_mode))
- die_errno(_("cannot copy '%s' to '%s'"),
- template_path->buf, path->buf);
- }
- else
- error(_("ignoring template %s"), template_path->buf);
- }
-}
-
-static void copy_templates(const char *template_dir, const char *init_template_dir)
-{
- struct strbuf path = STRBUF_INIT;
- struct strbuf template_path = STRBUF_INIT;
- size_t template_len;
- struct repository_format template_format = REPOSITORY_FORMAT_INIT;
- struct strbuf err = STRBUF_INIT;
- DIR *dir;
- char *to_free = NULL;
-
- if (!template_dir)
- template_dir = getenv(TEMPLATE_DIR_ENVIRONMENT);
- if (!template_dir)
- template_dir = init_template_dir;
- if (!template_dir)
- template_dir = to_free = system_path(DEFAULT_GIT_TEMPLATE_DIR);
- if (!template_dir[0]) {
- free(to_free);
- return;
- }
-
- strbuf_addstr(&template_path, template_dir);
- strbuf_complete(&template_path, '/');
- template_len = template_path.len;
-
- dir = opendir(template_path.buf);
- if (!dir) {
- warning(_("templates not found in %s"), template_dir);
- goto free_return;
- }
-
- /* Make sure that template is from the correct vintage */
- strbuf_addstr(&template_path, "config");
- read_repository_format(&template_format, template_path.buf);
- strbuf_setlen(&template_path, template_len);
-
- /*
- * No mention of version at all is OK, but anything else should be
- * verified.
- */
- if (template_format.version >= 0 &&
- verify_repository_format(&template_format, &err) < 0) {
- warning(_("not copying templates from '%s': %s"),
- template_dir, err.buf);
- strbuf_release(&err);
- goto close_free_return;
- }
-
- strbuf_addstr(&path, get_git_common_dir());
- strbuf_complete(&path, '/');
- copy_templates_1(&path, &template_path, dir);
-close_free_return:
- closedir(dir);
-free_return:
- free(to_free);
- strbuf_release(&path);
- strbuf_release(&template_path);
- clear_repository_format(&template_format);
-}
-
-/*
- * If the git_dir is not directly inside the working tree, then git will not
- * find it by default, and we need to set the worktree explicitly.
- */
-static int needs_work_tree_config(const char *git_dir, const char *work_tree)
-{
- if (!strcmp(work_tree, "/") && !strcmp(git_dir, "/.git"))
- return 0;
- if (skip_prefix(git_dir, work_tree, &git_dir) &&
- !strcmp(git_dir, "/.git"))
- return 0;
- return 1;
-}
-
-void initialize_repository_version(int hash_algo, int reinit)
-{
- char repo_version_string[10];
- int repo_version = GIT_REPO_VERSION;
-
- if (hash_algo != GIT_HASH_SHA1)
- repo_version = GIT_REPO_VERSION_READ;
-
- /* This forces creation of new config file */
- xsnprintf(repo_version_string, sizeof(repo_version_string),
- "%d", repo_version);
- git_config_set("core.repositoryformatversion", repo_version_string);
-
- if (hash_algo != GIT_HASH_SHA1)
- git_config_set("extensions.objectformat",
- hash_algos[hash_algo].name);
- else if (reinit)
- git_config_set_gently("extensions.objectformat", NULL);
-}
-
-static int create_default_files(const char *template_path,
- const char *original_git_dir,
- const char *initial_branch,
- const struct repository_format *fmt,
- int quiet)
-{
- struct stat st1;
- struct strbuf buf = STRBUF_INIT;
- char *path;
- char junk[2];
- int reinit;
- int filemode;
- struct strbuf err = STRBUF_INIT;
- const char *init_template_dir = NULL;
- const char *work_tree = get_git_work_tree();
-
- /*
- * First copy the templates -- we might have the default
- * config file there, in which case we would want to read
- * from it after installing.
- *
- * Before reading that config, we also need to clear out any cached
- * values (since we've just potentially changed what's available on
- * disk).
- */
- git_config_get_pathname("init.templatedir", &init_template_dir);
- copy_templates(template_path, init_template_dir);
- free((char *)init_template_dir);
- git_config_clear();
- reset_shared_repository();
- git_config(git_default_config, NULL);
-
- /*
- * We must make sure command-line options continue to override any
- * values we might have just re-read from the config.
- */
- is_bare_repository_cfg = init_is_bare_repository || !work_tree;
- if (init_shared_repository != -1)
- set_shared_repository(init_shared_repository);
-
- /*
- * We would have created the above under user's umask -- under
- * shared-repository settings, we would need to fix them up.
- */
- if (get_shared_repository()) {
- adjust_shared_perm(get_git_dir());
- }
-
- /*
- * We need to create a "refs" dir in any case so that older
- * versions of git can tell that this is a repository.
- */
- safe_create_dir(git_path("refs"), 1);
- adjust_shared_perm(git_path("refs"));
-
- if (refs_init_db(&err))
- die("failed to set up refs db: %s", err.buf);
-
- /*
- * Point the HEAD symref to the initial branch with if HEAD does
- * not yet exist.
- */
- path = git_path_buf(&buf, "HEAD");
- reinit = (!access(path, R_OK)
- || readlink(path, junk, sizeof(junk)-1) != -1);
- if (!reinit) {
- char *ref;
-
- if (!initial_branch)
- initial_branch = git_default_branch_name(quiet);
-
- ref = xstrfmt("refs/heads/%s", initial_branch);
- if (check_refname_format(ref, 0) < 0)
- die(_("invalid initial branch name: '%s'"),
- initial_branch);
-
- if (create_symref("HEAD", ref, NULL) < 0)
- exit(1);
- free(ref);
- }
-
- initialize_repository_version(fmt->hash_algo, 0);
-
- /* Check filemode trustability */
- path = git_path_buf(&buf, "config");
- filemode = TEST_FILEMODE;
- if (TEST_FILEMODE && !lstat(path, &st1)) {
- struct stat st2;
- filemode = (!chmod(path, st1.st_mode ^ S_IXUSR) &&
- !lstat(path, &st2) &&
- st1.st_mode != st2.st_mode &&
- !chmod(path, st1.st_mode));
- if (filemode && !reinit && (st1.st_mode & S_IXUSR))
- filemode = 0;
- }
- git_config_set("core.filemode", filemode ? "true" : "false");
-
- if (is_bare_repository())
- git_config_set("core.bare", "true");
- else {
- git_config_set("core.bare", "false");
- /* allow template config file to override the default */
- if (log_all_ref_updates == LOG_REFS_UNSET)
- git_config_set("core.logallrefupdates", "true");
- if (needs_work_tree_config(original_git_dir, work_tree))
- git_config_set("core.worktree", work_tree);
- }
-
- if (!reinit) {
- /* Check if symlink is supported in the work tree */
- path = git_path_buf(&buf, "tXXXXXX");
- if (!close(xmkstemp(path)) &&
- !unlink(path) &&
- !symlink("testing", path) &&
- !lstat(path, &st1) &&
- S_ISLNK(st1.st_mode))
- unlink(path); /* good */
- else
- git_config_set("core.symlinks", "false");
-
- /* Check if the filesystem is case-insensitive */
- path = git_path_buf(&buf, "CoNfIg");
- if (!access(path, F_OK))
- git_config_set("core.ignorecase", "true");
- probe_utf8_pathname_composition();
- }
-
- strbuf_release(&buf);
- return reinit;
-}
-
-static void create_object_directory(void)
-{
- struct strbuf path = STRBUF_INIT;
- size_t baselen;
-
- strbuf_addstr(&path, get_object_directory());
- baselen = path.len;
-
- safe_create_dir(path.buf, 1);
-
- strbuf_setlen(&path, baselen);
- strbuf_addstr(&path, "/pack");
- safe_create_dir(path.buf, 1);
-
- strbuf_setlen(&path, baselen);
- strbuf_addstr(&path, "/info");
- safe_create_dir(path.buf, 1);
-
- strbuf_release(&path);
-}
-
-static void separate_git_dir(const char *git_dir, const char *git_link)
-{
- struct stat st;
-
- if (!stat(git_link, &st)) {
- const char *src;
-
- if (S_ISREG(st.st_mode))
- src = read_gitfile(git_link);
- else if (S_ISDIR(st.st_mode))
- src = git_link;
- else
- die(_("unable to handle file type %d"), (int)st.st_mode);
-
- if (rename(src, git_dir))
- die_errno(_("unable to move %s to %s"), src, git_dir);
- repair_worktrees(NULL, NULL);
- }
-
- write_file(git_link, "gitdir: %s", git_dir);
-}
-
-static void validate_hash_algorithm(struct repository_format *repo_fmt, int hash)
-{
- const char *env = getenv(GIT_DEFAULT_HASH_ENVIRONMENT);
- /*
- * If we already have an initialized repo, don't allow the user to
- * specify a different algorithm, as that could cause corruption.
- * Otherwise, if the user has specified one on the command line, use it.
- */
- if (repo_fmt->version >= 0 && hash != GIT_HASH_UNKNOWN && hash != repo_fmt->hash_algo)
- die(_("attempt to reinitialize repository with different hash"));
- else if (hash != GIT_HASH_UNKNOWN)
- repo_fmt->hash_algo = hash;
- else if (env) {
- int env_algo = hash_algo_by_name(env);
- if (env_algo == GIT_HASH_UNKNOWN)
- die(_("unknown hash algorithm '%s'"), env);
- repo_fmt->hash_algo = env_algo;
- }
-}
-
-int init_db(const char *git_dir, const char *real_git_dir,
- const char *template_dir, int hash, const char *initial_branch,
- unsigned int flags)
-{
- int reinit;
- int exist_ok = flags & INIT_DB_EXIST_OK;
- char *original_git_dir = real_pathdup(git_dir, 1);
- struct repository_format repo_fmt = REPOSITORY_FORMAT_INIT;
-
- if (real_git_dir) {
- struct stat st;
-
- if (!exist_ok && !stat(git_dir, &st))
- die(_("%s already exists"), git_dir);
-
- if (!exist_ok && !stat(real_git_dir, &st))
- die(_("%s already exists"), real_git_dir);
-
- set_git_dir(real_git_dir, 1);
- git_dir = get_git_dir();
- separate_git_dir(git_dir, original_git_dir);
- }
- else {
- set_git_dir(git_dir, 1);
- git_dir = get_git_dir();
- }
- startup_info->have_repository = 1;
-
- /* Ensure `core.hidedotfiles` is processed */
- git_config(platform_core_config, NULL);
-
- safe_create_dir(git_dir, 0);
-
- init_is_bare_repository = is_bare_repository();
-
- /* Check to see if the repository version is right.
- * Note that a newly created repository does not have
- * config file, so this will not fail. What we are catching
- * is an attempt to reinitialize new repository with an old tool.
- */
- check_repository_format(&repo_fmt);
-
- validate_hash_algorithm(&repo_fmt, hash);
-
- reinit = create_default_files(template_dir, original_git_dir,
- initial_branch, &repo_fmt,
- flags & INIT_DB_QUIET);
- if (reinit && initial_branch)
- warning(_("re-init: ignored --initial-branch=%s"),
- initial_branch);
-
- create_object_directory();
-
- if (get_shared_repository()) {
- char buf[10];
- /* We do not spell "group" and such, so that
- * the configuration can be read by older version
- * of git. Note, we use octal numbers for new share modes,
- * and compatibility values for PERM_GROUP and
- * PERM_EVERYBODY.
- */
- if (get_shared_repository() < 0)
- /* force to the mode value */
- xsnprintf(buf, sizeof(buf), "0%o", -get_shared_repository());
- else if (get_shared_repository() == PERM_GROUP)
- xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_GROUP);
- else if (get_shared_repository() == PERM_EVERYBODY)
- xsnprintf(buf, sizeof(buf), "%d", OLD_PERM_EVERYBODY);
- else
- BUG("invalid value for shared_repository");
- git_config_set("core.sharedrepository", buf);
- git_config_set("receive.denyNonFastforwards", "true");
- }
-
- if (!(flags & INIT_DB_QUIET)) {
- int len = strlen(git_dir);
-
- if (reinit)
- printf(get_shared_repository()
- ? _("Reinitialized existing shared Git repository in %s%s\n")
- : _("Reinitialized existing Git repository in %s%s\n"),
- git_dir, len && git_dir[len-1] != '/' ? "/" : "");
- else
- printf(get_shared_repository()
- ? _("Initialized empty shared Git repository in %s%s\n")
- : _("Initialized empty Git repository in %s%s\n"),
- git_dir, len && git_dir[len-1] != '/' ? "/" : "");
- }
-
- free(original_git_dir);
- return 0;
-}
-
static int guess_repository_type(const char *git_dir)
{
const char *slash;
@@ -546,6 +79,7 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
const char *object_format = NULL;
const char *initial_branch = NULL;
int hash_algo = GIT_HASH_UNKNOWN;
+ int init_shared_repository = -1;
const struct option init_db_options[] = {
OPT_STRING(0, "template", &template_dir, N_("template-directory"),
N_("directory from which templates will be used")),
@@ -703,5 +237,5 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
flags |= INIT_DB_EXIST_OK;
return init_db(git_dir, real_git_dir, template_dir, hash_algo,
- initial_branch, flags);
+ initial_branch, init_shared_repository, flags);
}
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
index 107ac28f0e..c5e8345265 100644
--- a/builtin/interpret-trailers.c
+++ b/builtin/interpret-trailers.c
@@ -5,7 +5,6 @@
*
*/
-#include "cache.h"
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
diff --git a/builtin/log.c b/builtin/log.c
index c85f13a5d5..89442dceda 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -14,7 +14,7 @@
#include "refs.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "pager.h"
#include "color.h"
#include "commit.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 72012c0f0f..c1ff79c559 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -5,13 +5,12 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
-#include "cache.h"
+#include "builtin.h"
#include "repository.h"
#include "config.h"
#include "convert.h"
#include "quote.h"
#include "dir.h"
-#include "builtin.h"
#include "gettext.h"
#include "object-name.h"
#include "strbuf.h"
@@ -20,9 +19,12 @@
#include "parse-options.h"
#include "resolve-undo.h"
#include "string-list.h"
+#include "path.h"
#include "pathspec.h"
+#include "read-cache.h"
#include "run-command.h"
#include "setup.h"
+#include "sparse-index.h"
#include "submodule.h"
#include "submodule-config.h"
#include "object-store.h"
@@ -543,143 +545,6 @@ static int get_common_prefix_len(const char *common_prefix)
return common_prefix_len;
}
-static int read_one_entry_opt(struct index_state *istate,
- const struct object_id *oid,
- struct strbuf *base,
- const char *pathname,
- unsigned mode, int opt)
-{
- int len;
- struct cache_entry *ce;
-
- if (S_ISDIR(mode))
- return READ_TREE_RECURSIVE;
-
- len = strlen(pathname);
- ce = make_empty_cache_entry(istate, base->len + len);
-
- ce->ce_mode = create_ce_mode(mode);
- ce->ce_flags = create_ce_flags(1);
- ce->ce_namelen = base->len + len;
- memcpy(ce->name, base->buf, base->len);
- memcpy(ce->name + base->len, pathname, len+1);
- oidcpy(&ce->oid, oid);
- return add_index_entry(istate, ce, opt);
-}
-
-static int read_one_entry(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode,
- void *context)
-{
- struct index_state *istate = context;
- return read_one_entry_opt(istate, oid, base, pathname,
- mode,
- ADD_CACHE_OK_TO_ADD|ADD_CACHE_SKIP_DFCHECK);
-}
-
-/*
- * This is used when the caller knows there is no existing entries at
- * the stage that will conflict with the entry being added.
- */
-static int read_one_entry_quick(const struct object_id *oid, struct strbuf *base,
- const char *pathname, unsigned mode,
- void *context)
-{
- struct index_state *istate = context;
- return read_one_entry_opt(istate, oid, base, pathname,
- mode, ADD_CACHE_JUST_APPEND);
-}
-
-/*
- * Read the tree specified with --with-tree option
- * (typically, HEAD) into stage #1 and then
- * squash them down to stage #0. This is used for
- * --error-unmatch to list and check the path patterns
- * that were given from the command line. We are not
- * going to write this index out.
- */
-void overlay_tree_on_index(struct index_state *istate,
- const char *tree_name, const char *prefix)
-{
- struct tree *tree;
- struct object_id oid;
- struct pathspec pathspec;
- struct cache_entry *last_stage0 = NULL;
- int i;
- read_tree_fn_t fn = NULL;
- int err;
-
- if (repo_get_oid(the_repository, tree_name, &oid))
- die("tree-ish %s not found.", tree_name);
- tree = parse_tree_indirect(&oid);
- if (!tree)
- die("bad tree-ish %s", tree_name);
-
- /* Hoist the unmerged entries up to stage #3 to make room */
- /* TODO: audit for interaction with sparse-index. */
- ensure_full_index(istate);
- for (i = 0; i < istate->cache_nr; i++) {
- struct cache_entry *ce = istate->cache[i];
- if (!ce_stage(ce))
- continue;
- ce->ce_flags |= CE_STAGEMASK;
- }
-
- if (prefix) {
- static const char *(matchbuf[1]);
- matchbuf[0] = NULL;
- parse_pathspec(&pathspec, PATHSPEC_ALL_MAGIC,
- PATHSPEC_PREFER_CWD, prefix, matchbuf);
- } else
- memset(&pathspec, 0, sizeof(pathspec));
-
- /*
- * See if we have cache entry at the stage. If so,
- * do it the original slow way, otherwise, append and then
- * sort at the end.
- */
- for (i = 0; !fn && i < istate->cache_nr; i++) {
- const struct cache_entry *ce = istate->cache[i];
- if (ce_stage(ce) == 1)
- fn = read_one_entry;
- }
-
- if (!fn)
- fn = read_one_entry_quick;
- err = read_tree(the_repository, tree, &pathspec, fn, istate);
- clear_pathspec(&pathspec);
- if (err)
- die("unable to read tree entries %s", tree_name);
-
- /*
- * Sort the cache entry -- we need to nuke the cache tree, though.
- */
- if (fn == read_one_entry_quick) {
- cache_tree_free(&istate->cache_tree);
- QSORT(istate->cache, istate->cache_nr, cmp_cache_name_compare);
- }
-
- for (i = 0; i < istate->cache_nr; i++) {
- struct cache_entry *ce = istate->cache[i];
- switch (ce_stage(ce)) {
- case 0:
- last_stage0 = ce;
- /* fallthru */
- default:
- continue;
- case 1:
- /*
- * If there is stage #0 entry for this, we do not
- * need to show it. We use CE_UPDATE bit to mark
- * such an entry.
- */
- if (last_stage0 &&
- !strcmp(last_stage0->name, ce->name))
- ce->ce_flags |= CE_UPDATE;
- }
- }
-}
-
static const char * const ls_files_usage[] = {
N_("git ls-files [<options>] [<file>...]"),
NULL
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index cb6cb77e08..fc76575430 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "gettext.h"
#include "hex.h"
#include "transport.h"
@@ -8,6 +7,7 @@
#include "remote.h"
#include "refs.h"
#include "parse-options.h"
+#include "wildmatch.h"
static const char * const ls_remote_usage[] = {
N_("git ls-remote [--heads] [--tags] [--refs] [--upload-pack=<exec>]\n"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 077977a461..4e17f13648 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -3,17 +3,17 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "blob.h"
#include "tree.h"
#include "commit.h"
+#include "path.h"
#include "quote.h"
-#include "builtin.h"
#include "parse-options.h"
#include "pathspec.h"
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index a032a1c388..53b55dd71c 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -2,9 +2,8 @@
* Another stupid program, this one parsing the headers of an
* email to figure out authorship and subject
*/
-#include "cache.h"
-#include "abspath.h"
#include "builtin.h"
+#include "abspath.h"
#include "environment.h"
#include "gettext.h"
#include "utf8.h"
diff --git a/builtin/mailsplit.c b/builtin/mailsplit.c
index 0b6193a091..3af9ddb8ae 100644
--- a/builtin/mailsplit.c
+++ b/builtin/mailsplit.c
@@ -4,7 +4,6 @@
* It just splits a mbox into a list of files: "0001" "0002" ..
* so you can process them further from there.
*/
-#include "cache.h"
#include "builtin.h"
#include "gettext.h"
#include "string-list.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 854019a32d..e68b7fe45d 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "commit.h"
#include "gettext.h"
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 781818d08f..d7eb4c6540 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "abspath.h"
-#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "setup.h"
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index ab16e70f23..270d5f644a 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -1,8 +1,10 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "hex.h"
+#include "read-cache-ll.h"
#include "repository.h"
#include "run-command.h"
+#include "sparse-index.h"
static const char *pgm;
static int one_shot, quiet;
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index c2e519301e..932924e5d0 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -10,6 +10,7 @@
#include "git-compat-util.h"
#include "builtin.h"
#include "diff.h"
+#include "repository.h"
static const char builtin_merge_ours_usage[] =
"git merge-ours <base>... -- HEAD <remote>...";
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index b9e980384a..3366699657 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -1,4 +1,3 @@
-#include "cache.h"
#include "builtin.h"
#include "advice.h"
#include "commit.h"
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 4325897a80..6f7db436d2 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -9,7 +9,7 @@
#include "commit-reach.h"
#include "merge-ort.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "parse-options.h"
#include "repository.h"
#include "blob.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 8da3e46abb..420e81008e 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -7,7 +7,7 @@
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "abspath.h"
#include "advice.h"
#include "alloc.h"
@@ -18,7 +18,6 @@
#include "hex.h"
#include "object-name.h"
#include "parse-options.h"
-#include "builtin.h"
#include "lockfile.h"
#include "run-command.h"
#include "hook.h"
@@ -28,6 +27,7 @@
#include "refspec.h"
#include "commit.h"
#include "diffcore.h"
+#include "path.h"
#include "revision.h"
#include "unpack-trees.h"
#include "cache-tree.h"
@@ -37,6 +37,7 @@
#include "color.h"
#include "rerere.h"
#include "help.h"
+#include "merge.h"
#include "merge-recursive.h"
#include "merge-ort-wrappers.h"
#include "resolve-undo.h"
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 44fa56eff3..43e2766db4 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -2,10 +2,11 @@
#include "gettext.h"
#include "hex.h"
#include "parse-options.h"
+#include "strbuf.h"
#include "tag.h"
#include "replace-object.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "fsck.h"
#include "config.h"
diff --git a/builtin/mktree.c b/builtin/mktree.c
index 09a7bd5c5c..0eea810c7e 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -8,9 +8,10 @@
#include "gettext.h"
#include "hex.h"
#include "quote.h"
+#include "strbuf.h"
#include "tree.h"
#include "parse-options.h"
-#include "object-store.h"
+#include "object-store-ll.h"
static struct treeent {
unsigned mode;
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 1b5083f8b2..a31dde1db9 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -1,13 +1,13 @@
#include "builtin.h"
#include "abspath.h"
-#include "cache.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "parse-options.h"
#include "midx.h"
+#include "strbuf.h"
#include "trace2.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#define BUILTIN_MIDX_WRITE_USAGE \
N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]" \
diff --git a/builtin/mv.c b/builtin/mv.c
index 665bd27448..ae462bd7d4 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -11,6 +11,7 @@
#include "config.h"
#include "environment.h"
#include "gettext.h"
+#include "name-hash.h"
#include "object-file.h"
#include "pathspec.h"
#include "lockfile.h"
@@ -18,6 +19,7 @@
#include "cache-tree.h"
#include "string-list.h"
#include "parse-options.h"
+#include "read-cache-ll.h"
#include "repository.h"
#include "setup.h"
#include "submodule.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 4d15a23fc4..c3b722b36f 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -15,6 +15,7 @@
#include "hash-lookup.h"
#include "commit-slab.h"
#include "commit-graph.h"
+#include "wildmatch.h"
/*
* One day. See the 'name a rev shortly after epoch' test in t6120 when
diff --git a/builtin/notes.c b/builtin/notes.c
index d5788352b6..0a19796f73 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -7,15 +7,15 @@
* and builtin/tag.c by Kristian Høgsberg and Carlos Rica.
*/
-#include "cache.h"
-#include "config.h"
#include "builtin.h"
+#include "config.h"
#include "editor.h"
#include "gettext.h"
#include "hex.h"
#include "notes.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
+#include "path.h"
#include "repository.h"
#include "blob.h"
#include "pretty.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3af2d84f58..3c4db66478 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -34,7 +34,7 @@
#include "list.h"
#include "packfile.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "replace-object.h"
#include "dir.h"
#include "midx.h"
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index 43e9d12dfd..4c735ba069 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -11,7 +11,7 @@
#include "hex.h"
#include "repository.h"
#include "packfile.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#define BLKSIZE 512
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 9d5585d3a7..b7118b290b 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -1,8 +1,8 @@
-#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "gettext.h"
+#include "hash.h"
#include "hex.h"
#include "parse-options.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 2877201737..57fe31467f 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -1,19 +1,20 @@
-#include "cache.h"
+#include "builtin.h"
#include "commit.h"
#include "diff.h"
+#include "dir.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "revision.h"
-#include "builtin.h"
#include "reachable.h"
#include "parse-options.h"
+#include "path.h"
#include "progress.h"
#include "prune-packed.h"
#include "replace-object.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "shallow.h"
static const char * const prune_usage[] = {
diff --git a/builtin/pull.c b/builtin/pull.c
index 0c7bac97b7..b9e5c64ee8 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -6,12 +6,12 @@
* Fetch one or more remote refs and merge it/them into the current HEAD.
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "advice.h"
#include "config.h"
-#include "builtin.h"
#include "gettext.h"
#include "hex.h"
+#include "merge.h"
#include "object-name.h"
#include "parse-options.h"
#include "exec-cmd.h"
@@ -19,6 +19,8 @@
#include "oid-array.h"
#include "remote.h"
#include "dir.h"
+#include "path.h"
+#include "read-cache-ll.h"
#include "rebase.h"
#include "refs.h"
#include "refspec.h"
diff --git a/builtin/push.c b/builtin/push.c
index dbdf609daf..6f8a8dc711 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -1,7 +1,7 @@
/*
* "git push"
*/
-#include "cache.h"
+#include "builtin.h"
#include "advice.h"
#include "branch.h"
#include "config.h"
@@ -10,7 +10,6 @@
#include "refs.h"
#include "refspec.h"
#include "run-command.h"
-#include "builtin.h"
#include "remote.h"
#include "transport.h"
#include "parse-options.h"
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 04339a92ea..e455a4795c 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -1,10 +1,10 @@
-#include "cache.h"
#include "builtin.h"
#include "gettext.h"
#include "object-name.h"
#include "parse-options.h"
#include "range-diff.h"
#include "config.h"
+#include "repository.h"
#include "revision.h"
static const char * const builtin_range_diff_usage[] = {
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 440f19b1b8..63c92936fa 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -5,7 +5,7 @@
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
@@ -17,11 +17,11 @@
#include "cache-tree.h"
#include "unpack-trees.h"
#include "dir.h"
-#include "builtin.h"
#include "parse-options.h"
#include "repository.h"
#include "resolve-undo.h"
#include "setup.h"
+#include "sparse-index.h"
#include "submodule.h"
#include "submodule-config.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index ace1d5e8d1..91849f920f 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -24,6 +24,7 @@
#include "object-file.h"
#include "object-name.h"
#include "parse-options.h"
+#include "path.h"
#include "commit.h"
#include "diff.h"
#include "wt-status.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 1a31a58367..91caaf8706 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -30,7 +30,8 @@
#include "oidset.h"
#include "packfile.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
+#include "path.h"
#include "protocol.h"
#include "commit-reach.h"
#include "server-info.h"
diff --git a/builtin/reflog.c b/builtin/reflog.c
index a1fa0c855f..79b4ff04aa 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -1,8 +1,10 @@
#include "builtin.h"
#include "config.h"
#include "gettext.h"
+#include "repository.h"
#include "revision.h"
#include "reachable.h"
+#include "wildmatch.h"
#include "worktree.h"
#include "reflog.h"
#include "parse-options.h"
diff --git a/builtin/remote.c b/builtin/remote.c
index 1e0b137d97..7d96687ec7 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -2,6 +2,7 @@
#include "config.h"
#include "gettext.h"
#include "parse-options.h"
+#include "path.h"
#include "transport.h"
#include "remote.h"
#include "string-list.h"
@@ -10,7 +11,7 @@
#include "rebase.h"
#include "refs.h"
#include "refspec.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "strvec.h"
#include "commit-reach.h"
#include "progress.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index 1e21a21ea8..a96e1c2638 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -6,6 +6,7 @@
#include "gettext.h"
#include "hex.h"
#include "parse-options.h"
+#include "path.h"
#include "run-command.h"
#include "server-info.h"
#include "sigchain.h"
@@ -15,7 +16,7 @@
#include "midx.h"
#include "packfile.h"
#include "prune-packed.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "promisor-remote.h"
#include "shallow.h"
#include "pack.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index abff800276..9ceaa25233 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -8,22 +8,23 @@
* git-tag.sh and mktag.c by Linus Torvalds.
*/
-#include "cache.h"
-#include "config.h"
#include "builtin.h"
+#include "config.h"
#include "editor.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "refs.h"
#include "parse-options.h"
+#include "path.h"
#include "run-command.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "replace-object.h"
#include "repository.h"
#include "tag.h"
+#include "wildmatch.h"
static const char * const git_replace_usage[] = {
N_("git replace [-f] <object> <replacement>"),
diff --git a/builtin/rerere.c b/builtin/rerere.c
index d4bd52797f..0458db9cad 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "dir.h"
#include "gettext.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index f99f32d580..dad2117c97 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -13,6 +13,7 @@
#include "config.h"
#include "environment.h"
#include "gettext.h"
+#include "hash.h"
#include "hex.h"
#include "lockfile.h"
#include "tag.h"
@@ -26,9 +27,11 @@
#include "branch.h"
#include "object-name.h"
#include "parse-options.h"
+#include "path.h"
#include "unpack-trees.h"
#include "cache-tree.h"
#include "setup.h"
+#include "sparse-index.h"
#include "submodule.h"
#include "submodule-config.h"
#include "trace.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 6dc8be492a..ff715d6918 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "commit.h"
#include "diff.h"
@@ -12,10 +12,9 @@
#include "object.h"
#include "object-name.h"
#include "object-file.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "pack.h"
#include "pack-bitmap.h"
-#include "builtin.h"
#include "log-tree.h"
#include "graph.h"
#include "bisect.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index d2eb239a08..3e2ee44177 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -4,20 +4,22 @@
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "abspath.h"
#include "alloc.h"
#include "config.h"
#include "commit.h"
#include "environment.h"
#include "gettext.h"
+#include "hash.h"
#include "hex.h"
#include "refs.h"
#include "quote.h"
-#include "builtin.h"
#include "object-name.h"
#include "parse-options.h"
+#include "path.h"
#include "diff.h"
+#include "read-cache-ll.h"
#include "revision.h"
#include "setup.h"
#include "split-index.h"
diff --git a/builtin/revert.c b/builtin/revert.c
index 0240ec8593..f6f07d9b53 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -5,6 +5,7 @@
#include "parse-options.h"
#include "diff.h"
#include "gettext.h"
+#include "repository.h"
#include "revision.h"
#include "rerere.h"
#include "dir.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index b4589c824c..463eeabcea 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -16,9 +16,11 @@
#include "tree-walk.h"
#include "object-name.h"
#include "parse-options.h"
+#include "read-cache.h"
#include "repository.h"
#include "string-list.h"
#include "setup.h"
+#include "sparse-index.h"
#include "submodule.h"
#include "pathspec.h"
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 46f4e0832a..1307ed2b88 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -1,11 +1,11 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "commit.h"
#include "diff.h"
#include "environment.h"
#include "gettext.h"
#include "string-list.h"
+#include "repository.h"
#include "revision.h"
#include "utf8.h"
#include "mailmap.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 7ef4a642c1..a203f13cb0 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
@@ -6,7 +6,6 @@
#include "hex.h"
#include "pretty.h"
#include "refs.h"
-#include "builtin.h"
#include "color.h"
#include "strvec.h"
#include "object-name.h"
@@ -15,6 +14,7 @@
#include "dir.h"
#include "commit-slab.h"
#include "date.h"
+#include "wildmatch.h"
static const char* show_branch_usage[] = {
N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n"
diff --git a/builtin/show-index.c b/builtin/show-index.c
index d839e55335..540dc3dad1 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "gettext.h"
#include "hash.h"
#include "hex.h"
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index a2243b4219..5110814f79 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -1,11 +1,10 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
#include "refs.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "object.h"
#include "tag.h"
#include "string-list.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 40d420f06c..5c8ffb1f75 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "dir.h"
#include "environment.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index a7e17ffe38..84e83e0627 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -4,6 +4,7 @@
#include "config.h"
#include "environment.h"
#include "gettext.h"
+#include "hash.h"
#include "hex.h"
#include "object-name.h"
#include "parse-options.h"
@@ -17,9 +18,12 @@
#include "run-command.h"
#include "dir.h"
#include "entry.h"
+#include "preload-index.h"
+#include "read-cache.h"
#include "rerere.h"
#include "revision.h"
#include "setup.h"
+#include "sparse-index.h"
#include "log-tree.h"
#include "diffcore.h"
#include "exec-cmd.h"
diff --git a/builtin/stripspace.c b/builtin/stripspace.c
index 9451eb69ff..397d7fe2dc 100644
--- a/builtin/stripspace.c
+++ b/builtin/stripspace.c
@@ -1,5 +1,4 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "parse-options.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 6a16208e8a..6321d7e9c9 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -6,13 +6,16 @@
#include "gettext.h"
#include "hex.h"
#include "repository.h"
-#include "cache.h"
#include "config.h"
#include "parse-options.h"
#include "quote.h"
+#include "path.h"
#include "pathspec.h"
+#include "preload-index.h"
#include "dir.h"
+#include "read-cache.h"
#include "setup.h"
+#include "sparse-index.h"
#include "submodule.h"
#include "submodule-config.h"
#include "string-list.h"
@@ -26,7 +29,7 @@
#include "diff.h"
#include "object-file.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "advice.h"
#include "branch.h"
#include "list-objects-filter-options.h"
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index 10198a74fa..a61fa3c0f8 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "config.h"
-#include "cache.h"
#include "gettext.h"
#include "refs.h"
#include "parse-options.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 49b64c7a28..e63bee8eab 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -6,17 +6,17 @@
* Based on git-tag.sh and mktag.c by Linus Torvalds.
*/
-#include "cache.h"
+#include "builtin.h"
#include "advice.h"
#include "config.h"
-#include "builtin.h"
#include "editor.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
#include "refs.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
+#include "path.h"
#include "tag.h"
#include "run-command.h"
#include "parse-options.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index b35a4b9dfe..6842a6c499 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -2,7 +2,7 @@
#include "config.h"
#include "hex.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "wrapper.h"
static char *create_temp_file(struct object_id *oid)
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 0b4fe803cc..1979532a9d 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -1,12 +1,11 @@
#include "builtin.h"
-#include "cache.h"
#include "bulk-checkin.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
#include "git-zlib.h"
#include "hex.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "object.h"
#include "delta.h"
#include "pack.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 5fab9ad2ec..aee3cb8cbd 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -4,7 +4,7 @@
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_VARIABLE
-#include "cache.h"
+#include "builtin.h"
#include "bulk-checkin.h"
#include "config.h"
#include "environment.h"
@@ -15,15 +15,16 @@
#include "quote.h"
#include "cache-tree.h"
#include "tree-walk.h"
-#include "builtin.h"
#include "object-file.h"
#include "refs.h"
#include "resolve-undo.h"
#include "parse-options.h"
#include "pathspec.h"
#include "dir.h"
+#include "read-cache.h"
#include "repository.h"
#include "setup.h"
+#include "sparse-index.h"
#include "split-index.h"
#include "symlinks.h"
#include "fsmonitor.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 0c59b1c9ef..242102273e 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -1,9 +1,8 @@
-#include "cache.h"
+#include "builtin.h"
#include "config.h"
#include "gettext.h"
#include "hash.h"
#include "refs.h"
-#include "builtin.h"
#include "object-name.h"
#include "parse-options.h"
#include "quote.h"
diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index 19dce3c065..1dc3971ede 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -1,6 +1,5 @@
-#include "cache.h"
-#include "config.h"
#include "builtin.h"
+#include "config.h"
#include "gettext.h"
#include "parse-options.h"
#include "server-info.h"
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index 44ad400e18..1b09e5e1aa 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -1,9 +1,9 @@
/*
* Copyright (c) 2006 Franck Bui-Huu
*/
-#include "cache.h"
#include "builtin.h"
#include "archive.h"
+#include "path.h"
#include "pkt-line.h"
#include "sideband.h"
#include "repository.h"
diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c
index 81d2008e01..9b021ef026 100644
--- a/builtin/upload-pack.c
+++ b/builtin/upload-pack.c
@@ -1,9 +1,9 @@
-#include "cache.h"
#include "builtin.h"
#include "exec-cmd.h"
#include "gettext.h"
#include "pkt-line.h"
#include "parse-options.h"
+#include "path.h"
#include "protocol.h"
#include "replace-object.h"
#include "upload-pack.h"
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 5d99b82a64..9680b58701 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -5,12 +5,11 @@
*
* Based on git-verify-tag
*/
-#include "cache.h"
-#include "config.h"
#include "builtin.h"
+#include "config.h"
#include "gettext.h"
#include "object-name.h"
-#include "object-store.h"
+#include "object-store-ll.h"
#include "repository.h"
#include "commit.h"
#include "run-command.h"
diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c
index 190fd69540..011dddd2dc 100644
--- a/builtin/verify-pack.c
+++ b/builtin/verify-pack.c
@@ -1,9 +1,9 @@
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "run-command.h"
#include "parse-options.h"
+#include "strbuf.h"
#define VERIFY_PACK_VERBOSE 01
#define VERIFY_PACK_STAT_ONLY 02
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index c6019a0ad8..d8753270eb 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -5,9 +5,8 @@
*
* Based on git-verify-tag.sh
*/
-#include "cache.h"
-#include "config.h"
#include "builtin.h"
+#include "config.h"
#include "gettext.h"
#include "tag.h"
#include "run-command.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 5a9cf076ad..05dec7e330 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -1,10 +1,9 @@
-#include "cache.h"
+#include "builtin.h"
#include "abspath.h"
#include "advice.h"
#include "checkout.h"
#include "config.h"
#include "copy.h"
-#include "builtin.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
@@ -12,8 +11,10 @@
#include "object-file.h"
#include "object-name.h"
#include "parse-options.h"
+#include "path.h"
#include "strvec.h"
#include "branch.h"
+#include "read-cache-ll.h"
#include "refs.h"
#include "remote.h"
#include "repository.h"
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index 84b83318c9..66e83d0ecb 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -5,7 +5,6 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
-#include "cache.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"