From e8cf8ef5075d7805846f0f7159f8d072b07e588e Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 16 May 2023 06:33:44 +0000 Subject: setup: adopt shared init-db & clone code The functions init_db() and initialize_repository_version() were shared by builtin/init-db.c and builtin/clone.c, and declared in cache.h. Move these functions, plus their several helpers only used by these functions, to setup.[ch]. Diff best viewed with `--color-moved`. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- setup.c | 492 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 492 insertions(+) (limited to 'setup.c') diff --git a/setup.c b/setup.c index d866395435..6e7282e680 100644 --- a/setup.c +++ b/setup.c @@ -1,8 +1,11 @@ #include "git-compat-util.h" #include "abspath.h" +#include "copy.h" #include "environment.h" +#include "exec-cmd.h" #include "gettext.h" #include "object-name.h" +#include "refs.h" #include "repository.h" #include "config.h" #include "dir.h" @@ -12,6 +15,7 @@ #include "promisor-remote.h" #include "quote.h" #include "trace2.h" +#include "worktree.h" #include "wrapper.h" static int inside_git_dir = -1; @@ -1713,3 +1717,491 @@ int daemonize(void) return 0; #endif } + +#ifdef NO_TRUSTABLE_FILEMODE +#define TEST_FILEMODE 0 +#else +#define TEST_FILEMODE 1 +#endif + +#define GIT_DEFAULT_HASH_ENVIRONMENT "GIT_DEFAULT_HASH" + +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 prev_bare_repository, + int init_shared_repository, + 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. + */ + if (init_shared_repository != -1) + set_shared_repository(init_shared_repository); + /* + * TODO: heed core.bare from config file in templates if no + * command-line override given + */ + is_bare_repository_cfg = prev_bare_repository || !work_tree; + /* TODO (continued): + * + * Unfortunately, the line above is equivalent to + * is_bare_repository_cfg = !work_tree; + * which ignores the config entirely even if no `--[no-]bare` + * command line option was present. + * + * To see why, note that before this function, there was this call: + * prev_bare_repository = is_bare_repository() + * expanding the right hand side: + * = is_bare_repository_cfg && !get_git_work_tree() + * = is_bare_repository_cfg && !work_tree + * note that the last simplification above is valid because nothing + * calls repo_init() or set_git_work_tree() between any of the + * relevant calls in the code, and thus the !get_git_work_tree() + * calls will return the same result each time. So, what we are + * interested in computing is the right hand side of the line of + * code just above this comment: + * prev_bare_repository || !work_tree + * = is_bare_repository_cfg && !work_tree || !work_tree + * = !work_tree + * because "A && !B || !B == !B" for all boolean values of A & B. + */ + + /* + * 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, + int init_shared_repository, 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; + int prev_bare_repository; + + 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); + + prev_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, + prev_bare_repository, + init_shared_repository, + 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; +} -- cgit v1.2.3 From c339932bd858e84490c8690d393307a58764d6ed Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 16 May 2023 06:33:59 +0000 Subject: repository: remove unnecessary include of path.h This also made it clear that several .c files that depended upon path.h were missing a #include for it; add the missing includes while at it. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- apply.c | 1 + archive.c | 1 + attr.c | 1 + bisect.c | 1 + blame.c | 1 + branch.c | 1 + builtin/add.c | 1 + builtin/am.c | 1 + builtin/bisect.c | 1 + builtin/branch.c | 1 + builtin/checkout.c | 1 + builtin/clean.c | 1 + builtin/clone.c | 1 + builtin/commit.c | 1 + builtin/count-objects.c | 1 + builtin/fast-import.c | 1 + builtin/fetch.c | 1 + builtin/fsck.c | 1 + builtin/gc.c | 1 + builtin/grep.c | 1 + builtin/ls-files.c | 1 + builtin/ls-tree.c | 1 + builtin/merge.c | 1 + builtin/notes.c | 1 + builtin/prune.c | 1 + builtin/pull.c | 1 + builtin/rebase.c | 1 + builtin/receive-pack.c | 1 + builtin/remote.c | 1 + builtin/repack.c | 1 + builtin/replace.c | 1 + builtin/reset.c | 1 + builtin/rev-parse.c | 1 + builtin/submodule--helper.c | 1 + builtin/tag.c | 1 + builtin/upload-archive.c | 1 + builtin/upload-pack.c | 1 + builtin/worktree.c | 1 + commit-graph.c | 1 + compat/fsmonitor/fsm-ipc-darwin.c | 1 + config.c | 1 + connect.c | 1 + dir.c | 1 + environment.c | 1 + fetch-pack.c | 1 + fsck.c | 1 + http-backend.c | 1 + merge-ort.c | 1 + merge-recursive.c | 1 + notes-merge.c | 1 + object-file.c | 1 + pack-bitmap-write.c | 1 + pack-write.c | 1 + read-cache.c | 1 + refs.c | 1 + refs/files-backend.c | 1 + remote.c | 1 + repository.c | 1 + repository.h | 2 -- rerere.c | 1 + sequencer.c | 1 + server-info.c | 1 + setup.c | 1 + shallow.c | 1 + strbuf.c | 1 + submodule-config.c | 1 + submodule.c | 1 + t/helper/test-ref-store.c | 1 + tmp-objdir.c | 1 + worktree.c | 1 + wt-status.c | 1 + 71 files changed, 70 insertions(+), 2 deletions(-) (limited to 'setup.c') diff --git a/apply.c b/apply.c index e44a5dd7c5..be58dc08d2 100644 --- a/apply.c +++ b/apply.c @@ -27,6 +27,7 @@ #include "object-name.h" #include "object-file.h" #include "parse-options.h" +#include "path.h" #include "quote.h" #include "read-cache.h" #include "rerere.h" diff --git a/archive.c b/archive.c index 2ea9cbef92..2ad5f44201 100644 --- a/archive.c +++ b/archive.c @@ -6,6 +6,7 @@ #include "environment.h" #include "gettext.h" #include "hex.h" +#include "path.h" #include "pretty.h" #include "setup.h" #include "refs.h" diff --git a/attr.c b/attr.c index b659f415d8..2514c8a002 100644 --- a/attr.c +++ b/attr.c @@ -14,6 +14,7 @@ #include "attr.h" #include "dir.h" #include "gettext.h" +#include "path.h" #include "utf8.h" #include "quote.h" #include "read-cache-ll.h" diff --git a/bisect.c b/bisect.c index 8d5f8e5885..9f7cf0be07 100644 --- a/bisect.c +++ b/bisect.c @@ -19,6 +19,7 @@ #include "commit-reach.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "dir.h" static struct oid_array good_revs; diff --git a/blame.c b/blame.c index ab3c6108cc..2e25a7254c 100644 --- a/blame.c +++ b/blame.c @@ -8,6 +8,7 @@ #include "diffcore.h" #include "gettext.h" #include "hex.h" +#include "path.h" #include "read-cache.h" #include "setup.h" #include "tag.h" diff --git a/branch.c b/branch.c index ba3914adf5..20073284c8 100644 --- a/branch.c +++ b/branch.c @@ -6,6 +6,7 @@ #include "gettext.h" #include "hex.h" #include "object-name.h" +#include "path.h" #include "refs.h" #include "refspec.h" #include "remote.h" diff --git a/builtin/add.c b/builtin/add.c index 50792c0d49..4318311448 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -16,6 +16,7 @@ #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" diff --git a/builtin/am.c b/builtin/am.c index 2f0f233791..a78daa6971 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -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/bisect.c b/builtin/bisect.c index bce0ee6268..6478df3489 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -11,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/branch.c b/builtin/branch.c index c480fa2121..20fea4576a 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -18,6 +18,7 @@ #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/checkout.c b/builtin/checkout.c index 09b8415649..716dcd4cae 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -20,6 +20,7 @@ #include "object-name.h" #include "object-store.h" #include "parse-options.h" +#include "path.h" #include "preload-index.h" #include "read-cache.h" #include "refs.h" diff --git a/builtin/clean.c b/builtin/clean.c index 66b4479356..1bb6b7965c 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -13,6 +13,7 @@ #include "dir.h" #include "gettext.h" #include "parse-options.h" +#include "path.h" #include "read-cache-ll.h" #include "repository.h" #include "setup.h" diff --git a/builtin/clone.c b/builtin/clone.c index cc34c194f5..6c5cb33f6a 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -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" diff --git a/builtin/commit.c b/builtin/commit.c index acf21789a0..288314fe60 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -29,6 +29,7 @@ #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" diff --git a/builtin/count-objects.c b/builtin/count-objects.c index b9e6b55a9a..c9f82d0bce 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -9,6 +9,7 @@ #include "dir.h" #include "environment.h" #include "gettext.h" +#include "path.h" #include "repository.h" #include "parse-options.h" #include "quote.h" diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 67a2260a5e..5698b92ae7 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -12,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" diff --git a/builtin/fetch.c b/builtin/fetch.c index 2c6f4d3dff..d51b28fe2e 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -28,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/fsck.c b/builtin/fsck.c index 3e169f413d..88c466c048 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -21,6 +21,7 @@ #include "object-file.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "read-cache-ll.h" #include "replace-object.h" #include "resolve-undo.h" diff --git a/builtin/gc.c b/builtin/gc.c index f3942188a6..aeceed4117 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -30,6 +30,7 @@ #include "object-store.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/grep.c b/builtin/grep.c index 7638d77900..6bc8abcd3e 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -30,6 +30,7 @@ #include "object-store.h" #include "packfile.h" #include "pager.h" +#include "path.h" #include "read-cache-ll.h" #include "write-or-die.h" diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 3e314980fe..c1ff79c559 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -19,6 +19,7 @@ #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" diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index f4331c640f..c06858de4b 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -12,6 +12,7 @@ #include "blob.h" #include "tree.h" #include "commit.h" +#include "path.h" #include "quote.h" #include "parse-options.h" #include "pathspec.h" diff --git a/builtin/merge.c b/builtin/merge.c index d7ac108ce9..420e81008e 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -27,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" diff --git a/builtin/notes.c b/builtin/notes.c index efdf245148..0a870d9083 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -15,6 +15,7 @@ #include "notes.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "repository.h" #include "blob.h" #include "pretty.h" diff --git a/builtin/prune.c b/builtin/prune.c index b3658b5b51..a46c5aa2b5 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -7,6 +7,7 @@ #include "revision.h" #include "reachable.h" #include "parse-options.h" +#include "path.h" #include "progress.h" #include "prune-packed.h" #include "replace-object.h" diff --git a/builtin/pull.c b/builtin/pull.c index d434495091..b9e5c64ee8 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -19,6 +19,7 @@ #include "oid-array.h" #include "remote.h" #include "dir.h" +#include "path.h" #include "read-cache-ll.h" #include "rebase.h" #include "refs.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..d1718a3ac9 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -31,6 +31,7 @@ #include "packfile.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "protocol.h" #include "commit-reach.h" #include "server-info.h" diff --git a/builtin/remote.c b/builtin/remote.c index 1e0b137d97..3794f13330 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" diff --git a/builtin/repack.c b/builtin/repack.c index 0541c3ce15..fe8d5810d4 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" diff --git a/builtin/replace.c b/builtin/replace.c index e0fbdc98ed..6b266a66d3 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -16,6 +16,7 @@ #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" diff --git a/builtin/reset.c b/builtin/reset.c index 3dc41ac332..f947c449d1 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -26,6 +26,7 @@ #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" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 8d8c870421..6eb5965bee 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -16,6 +16,7 @@ #include "quote.h" #include "object-name.h" #include "parse-options.h" +#include "path.h" #include "diff.h" #include "read-cache-ll.h" #include "revision.h" diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 12ba2ae45d..5fddfb158d 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -9,6 +9,7 @@ #include "config.h" #include "parse-options.h" #include "quote.h" +#include "path.h" #include "pathspec.h" #include "preload-index.h" #include "dir.h" diff --git a/builtin/tag.c b/builtin/tag.c index 26691e7e52..26122dd103 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -16,6 +16,7 @@ #include "refs.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "tag.h" #include "run-command.h" #include "parse-options.h" diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c index d4c7f162ff..1b09e5e1aa 100644 --- a/builtin/upload-archive.c +++ b/builtin/upload-archive.c @@ -3,6 +3,7 @@ */ #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 ba5103a933..b02d479248 100644 --- a/builtin/upload-pack.c +++ b/builtin/upload-pack.c @@ -3,6 +3,7 @@ #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/worktree.c b/builtin/worktree.c index 2d83ea4bf2..1a25980eb5 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -10,6 +10,7 @@ #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" diff --git a/commit-graph.c b/commit-graph.c index 843bdb458d..25cbd66c33 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -14,6 +14,7 @@ #include "object-file.h" #include "object-store.h" #include "oid-array.h" +#include "path.h" #include "alloc.h" #include "hashmap.h" #include "replace-object.h" diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c index 793073aaa7..964bc074db 100644 --- a/compat/fsmonitor/fsm-ipc-darwin.c +++ b/compat/fsmonitor/fsm-ipc-darwin.c @@ -2,6 +2,7 @@ #include "config.h" #include "gettext.h" #include "hex.h" +#include "path.h" #include "repository.h" #include "strbuf.h" #include "fsmonitor.h" diff --git a/config.c b/config.c index b92b75c5d0..8afa266054 100644 --- a/config.c +++ b/config.c @@ -27,6 +27,7 @@ #include "object-name.h" #include "object-store.h" #include "pager.h" +#include "path.h" #include "utf8.h" #include "dir.h" #include "color.h" diff --git a/connect.c b/connect.c index 3a0186280c..37674f7112 100644 --- a/connect.c +++ b/connect.c @@ -12,6 +12,7 @@ #include "url.h" #include "string-list.h" #include "oid-array.h" +#include "path.h" #include "transport.h" #include "trace2.h" #include "strbuf.h" diff --git a/dir.c b/dir.c index 1e84b1e1f2..3cf3d428c7 100644 --- a/dir.c +++ b/dir.c @@ -16,6 +16,7 @@ #include "name-hash.h" #include "object-file.h" #include "object-store.h" +#include "path.h" #include "attr.h" #include "refs.h" #include "wildmatch.h" diff --git a/environment.c b/environment.c index 4ecad41bb9..5c494777a6 100644 --- a/environment.c +++ b/environment.c @@ -21,6 +21,7 @@ #include "strvec.h" #include "object-file.h" #include "object-store.h" +#include "path.h" #include "replace-object.h" #include "tmp-objdir.h" #include "chdir-notify.h" diff --git a/fetch-pack.c b/fetch-pack.c index 0f71054fba..207548b3e5 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -25,6 +25,7 @@ #include "oidset.h" #include "packfile.h" #include "object-store.h" +#include "path.h" #include "connected.h" #include "fetch-negotiator.h" #include "fsck.h" diff --git a/fsck.c b/fsck.c index 3261ef9ec2..04e729953b 100644 --- a/fsck.c +++ b/fsck.c @@ -3,6 +3,7 @@ #include "date.h" #include "hex.h" #include "object-store.h" +#include "path.h" #include "repository.h" #include "object.h" #include "attr.h" diff --git a/http-backend.c b/http-backend.c index ac146d85c5..ddb9549ecb 100644 --- a/http-backend.c +++ b/http-backend.c @@ -4,6 +4,7 @@ #include "environment.h" #include "git-zlib.h" #include "hex.h" +#include "path.h" #include "repository.h" #include "refs.h" #include "pkt-line.h" diff --git a/merge-ort.c b/merge-ort.c index 12d0181f4a..587eea9801 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -36,6 +36,7 @@ #include "object-name.h" #include "object-store.h" #include "oid-array.h" +#include "path.h" #include "promisor-remote.h" #include "read-cache-ll.h" #include "revision.h" diff --git a/merge-recursive.c b/merge-recursive.c index 4bef9b62fa..527dbbd010 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -27,6 +27,7 @@ #include "object-file.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "repository.h" #include "revision.h" #include "sparse-index.h" diff --git a/notes-merge.c b/notes-merge.c index 233e49e319..4b328d852c 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -6,6 +6,7 @@ #include "object-file.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "repository.h" #include "diff.h" #include "diffcore.h" diff --git a/object-file.c b/object-file.c index 7c1af5c8db..8d87720dd5 100644 --- a/object-file.c +++ b/object-file.c @@ -39,6 +39,7 @@ #include "object-file.h" #include "object-store.h" #include "oidtree.h" +#include "path.h" #include "promisor-remote.h" #include "setup.h" #include "submodule.h" diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index cdffe2ce47..623ee2a819 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -15,6 +15,7 @@ #include "pack-bitmap.h" #include "hash-lookup.h" #include "pack-objects.h" +#include "path.h" #include "commit-reach.h" #include "prio-queue.h" #include "trace2.h" diff --git a/pack-write.c b/pack-write.c index 3b3ce89de6..45681e2d7d 100644 --- a/pack-write.c +++ b/pack-write.c @@ -10,6 +10,7 @@ #include "oidmap.h" #include "pack-objects.h" #include "pack-revindex.h" +#include "path.h" #include "wrapper.h" void reset_pack_idx_option(struct pack_idx_option *opts) diff --git a/read-cache.c b/read-cache.c index edab96765d..86ada403a8 100644 --- a/read-cache.c +++ b/read-cache.c @@ -27,6 +27,7 @@ #include "mem-pool.h" #include "name-hash.h" #include "object-name.h" +#include "path.h" #include "preload-index.h" #include "read-cache.h" #include "resolve-undo.h" diff --git a/refs.c b/refs.c index 881a0da65c..6d657e3bb4 100644 --- a/refs.c +++ b/refs.c @@ -19,6 +19,7 @@ #include "object-name.h" #include "object-store.h" #include "object.h" +#include "path.h" #include "tag.h" #include "submodule.h" #include "worktree.h" diff --git a/refs/files-backend.c b/refs/files-backend.c index 9223c7f5f4..09b4954f21 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -15,6 +15,7 @@ #include "../lockfile.h" #include "../object.h" #include "../object-file.h" +#include "../path.h" #include "../dir.h" #include "../chdir-notify.h" #include "../setup.h" diff --git a/remote.c b/remote.c index 0764fca0db..8550056db4 100644 --- a/remote.c +++ b/remote.c @@ -11,6 +11,7 @@ #include "refspec.h" #include "object-name.h" #include "object-store.h" +#include "path.h" #include "commit.h" #include "diff.h" #include "revision.h" diff --git a/repository.c b/repository.c index 2616aabde5..4d68537407 100644 --- a/repository.c +++ b/repository.c @@ -10,6 +10,7 @@ #include "config.h" #include "object.h" #include "lockfile.h" +#include "path.h" #include "read-cache-ll.h" #include "remote.h" #include "setup.h" diff --git a/repository.h b/repository.h index 1cb314721c..0f430b1bc2 100644 --- a/repository.h +++ b/repository.h @@ -1,8 +1,6 @@ #ifndef REPOSITORY_H #define REPOSITORY_H -#include "path.h" - struct config_set; struct fsmonitor_settings; struct git_hash_algo; diff --git a/rerere.c b/rerere.c index 2fb93a5112..35b9785d57 100644 --- a/rerere.c +++ b/rerere.c @@ -14,6 +14,7 @@ #include "resolve-undo.h" #include "ll-merge.h" #include "attr.h" +#include "path.h" #include "pathspec.h" #include "object-file.h" #include "object-store.h" diff --git a/sequencer.c b/sequencer.c index efad20b753..282a6cff1b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -23,6 +23,7 @@ #include "utf8.h" #include "cache-tree.h" #include "diff.h" +#include "path.h" #include "revision.h" #include "rerere.h" #include "merge.h" diff --git a/server-info.c b/server-info.c index 55aa04f00a..85d17bbb15 100644 --- a/server-info.c +++ b/server-info.c @@ -9,6 +9,7 @@ #include "commit.h" #include "tag.h" #include "packfile.h" +#include "path.h" #include "object-file.h" #include "object-store.h" #include "server-info.h" diff --git a/setup.c b/setup.c index 6e7282e680..ef55ad7cda 100644 --- a/setup.c +++ b/setup.c @@ -12,6 +12,7 @@ #include "setup.h" #include "string-list.h" #include "chdir-notify.h" +#include "path.h" #include "promisor-remote.h" #include "quote.h" #include "trace2.h" diff --git a/shallow.c b/shallow.c index f1c93e7464..45343e6a78 100644 --- a/shallow.c +++ b/shallow.c @@ -11,6 +11,7 @@ #include "remote.h" #include "refs.h" #include "oid-array.h" +#include "path.h" #include "diff.h" #include "revision.h" #include "commit-slab.h" diff --git a/strbuf.c b/strbuf.c index 08eec8f1d8..d070e007f8 100644 --- a/strbuf.c +++ b/strbuf.c @@ -6,6 +6,7 @@ #include "hex.h" #include "object-name.h" #include "refs.h" +#include "path.h" #include "repository.h" #include "string-list.h" #include "utf8.h" diff --git a/submodule-config.c b/submodule-config.c index 7eb7a0d88d..6786bcee52 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -4,6 +4,7 @@ #include "environment.h" #include "gettext.h" #include "hex.h" +#include "path.h" #include "repository.h" #include "config.h" #include "submodule-config.h" diff --git a/submodule.c b/submodule.c index 20aa8ed0fb..245300596f 100644 --- a/submodule.c +++ b/submodule.c @@ -20,6 +20,7 @@ #include "strvec.h" #include "blob.h" #include "thread-utils.h" +#include "path.h" #include "quote.h" #include "remote.h" #include "worktree.h" diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index a6977b5e83..15fa3f880c 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -4,6 +4,7 @@ #include "setup.h" #include "worktree.h" #include "object-store.h" +#include "path.h" #include "repository.h" #include "revision.h" diff --git a/tmp-objdir.c b/tmp-objdir.c index c33a554f92..db1f7038da 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -5,6 +5,7 @@ #include "dir.h" #include "environment.h" #include "object-file.h" +#include "path.h" #include "sigchain.h" #include "string-list.h" #include "strbuf.h" diff --git a/worktree.c b/worktree.c index c448fecd4b..b4b01340a0 100644 --- a/worktree.c +++ b/worktree.c @@ -3,6 +3,7 @@ #include "alloc.h" #include "environment.h" #include "gettext.h" +#include "path.h" #include "repository.h" #include "refs.h" #include "setup.h" diff --git a/wt-status.c b/wt-status.c index 6ee8567ac2..7ada6b305f 100644 --- a/wt-status.c +++ b/wt-status.c @@ -9,6 +9,7 @@ #include "gettext.h" #include "hex.h" #include "object-name.h" +#include "path.h" #include "revision.h" #include "diffcore.h" #include "quote.h" -- cgit v1.2.3