From f394e093df10f1867d9bb2180b3789ee61124aed Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 21 Mar 2023 06:25:54 +0000 Subject: treewide: be explicit about dependence on gettext.h Dozens of files made use of gettext functions, without explicitly including gettext.h. This made it more difficult to find which files could remove a dependence on cache.h. Make C files explicitly include gettext.h if they are using it. However, while compat/fsmonitor/fsm-ipc-darwin.c should also gain an include of gettext.h, it was left out to avoid conflicting with an in-flight topic. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- diff.c | 1 + 1 file changed, 1 insertion(+) (limited to 'diff.c') diff --git a/diff.c b/diff.c index 00d47281a1..00746f2f86 100644 --- a/diff.c +++ b/diff.c @@ -4,6 +4,7 @@ #include "cache.h" #include "alloc.h" #include "config.h" +#include "gettext.h" #include "tempfile.h" #include "quote.h" #include "diff.h" -- cgit v1.2.3 From 0b027f6ca79cafbc14f36ff1741fc7378282f295 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 21 Mar 2023 06:25:58 +0000 Subject: abspath.h: move absolute path functions from cache.h This is another step towards letting us remove the include of cache.h in strbuf.c. It does mean that we also need to add includes of abspath.h in a number of C files. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- abspath.c | 4 +++- abspath.h | 33 +++++++++++++++++++++++++++++++++ apply.c | 1 + archive.c | 1 + builtin/am.c | 1 + builtin/bugreport.c | 1 + builtin/bundle.c | 1 + builtin/clean.c | 1 + builtin/clone.c | 1 + builtin/config.c | 1 + builtin/credential-cache--daemon.c | 1 + builtin/diagnose.c | 1 + builtin/difftool.c | 1 + builtin/fast-import.c | 1 + builtin/fsmonitor--daemon.c | 1 + builtin/gc.c | 1 + builtin/hash-object.c | 1 + builtin/init-db.c | 1 + builtin/log.c | 1 + builtin/mailinfo.c | 1 + builtin/merge-file.c | 1 + builtin/merge.c | 1 + builtin/multi-pack-index.c | 1 + builtin/mv.c | 1 + builtin/rebase.c | 1 + builtin/receive-pack.c | 1 + builtin/rev-parse.c | 1 + builtin/stash.c | 1 + builtin/submodule--helper.c | 1 + builtin/worktree.c | 1 + cache.h | 27 --------------------------- chdir-notify.c | 1 + compat/disk.h | 1 + compat/mingw.c | 1 + compat/simple-ipc/ipc-win32.c | 1 + config.c | 1 + credential.c | 1 + daemon.c | 1 + diff-no-index.c | 1 + diff.c | 1 + dir.c | 1 + editor.c | 1 + environment.c | 1 + exec-cmd.c | 1 + gettext.c | 1 + lockfile.c | 1 + midx.c | 1 + object-file.c | 1 + parse-options.c | 1 + path.c | 1 + pathspec.c | 1 + remote.c | 1 + repository.c | 1 + rerere.c | 1 + scalar.c | 1 + sequencer.c | 1 + setup.c | 1 + strbuf.c | 1 + submodule.c | 1 + t/helper/test-path-utils.c | 1 + tmp-objdir.c | 1 + trace.c | 1 + trace2/tr2_dst.c | 1 + worktree.c | 1 + wrapper.c | 1 + 65 files changed, 98 insertions(+), 28 deletions(-) create mode 100644 abspath.h (limited to 'diff.c') diff --git a/abspath.c b/abspath.c index 9a81c5525b..d032f5dce5 100644 --- a/abspath.c +++ b/abspath.c @@ -1,4 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "abspath.h" +#include "strbuf.h" /* * Do not use this for inspecting *tracked* content. When path is a diff --git a/abspath.h b/abspath.h new file mode 100644 index 0000000000..7cd3de5e9d --- /dev/null +++ b/abspath.h @@ -0,0 +1,33 @@ +#ifndef ABSPATH_H +#define ABSPATH_H + +int is_directory(const char *); +char *strbuf_realpath(struct strbuf *resolved, const char *path, + int die_on_error); +char *strbuf_realpath_forgiving(struct strbuf *resolved, const char *path, + int die_on_error); +char *real_pathdup(const char *path, int die_on_error); +const char *absolute_path(const char *path); +char *absolute_pathdup(const char *path); + +/* + * Concatenate "prefix" (if len is non-zero) and "path", with no + * connecting characters (so "prefix" should end with a "/"). + * Unlike prefix_path, this should be used if the named file does + * not have to interact with index entry; i.e. name of a random file + * on the filesystem. + * + * The return value is always a newly allocated string (even if the + * prefix was empty). + */ +char *prefix_filename(const char *prefix, const char *path); + +/* Likewise, but path=="-" always yields "-" */ +char *prefix_filename_except_for_dash(const char *prefix, const char *path); + +static inline int is_absolute_path(const char *path) +{ + return is_dir_sep(path[0]) || has_dos_drive_prefix(path); +} + +#endif /* ABSPATH_H */ diff --git a/apply.c b/apply.c index e0bdd43a68..e5e11b8579 100644 --- a/apply.c +++ b/apply.c @@ -8,6 +8,7 @@ */ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "object-store.h" diff --git a/archive.c b/archive.c index 2c3da1cff3..c3c45a5ebe 100644 --- a/archive.c +++ b/archive.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/builtin/am.c b/builtin/am.c index cc1fdf4f75..14347ecf9a 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "abspath.h" #include "config.h" #include "builtin.h" #include "exec-cmd.h" diff --git a/builtin/bugreport.c b/builtin/bugreport.c index b61cfa9464..b5dfad4e12 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "gettext.h" #include "parse-options.h" #include "strbuf.h" diff --git a/builtin/bundle.c b/builtin/bundle.c index de3898ffa4..9e2aecadf7 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "gettext.h" #include "strvec.h" #include "parse-options.h" diff --git a/builtin/clean.c b/builtin/clean.c index 46c51029ab..fdcf62c5df 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -8,6 +8,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "abspath.h" #include "cache.h" #include "config.h" #include "dir.h" diff --git a/builtin/clone.c b/builtin/clone.c index d605fcafa0..b94324ea02 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -10,6 +10,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "abspath.h" #include "config.h" #include "gettext.h" #include "hex.h" diff --git a/builtin/config.c b/builtin/config.c index 33b17b40b4..42e6b8d348 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "color.h" diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c index 0f00ba4d74..62c09a271d 100644 --- a/builtin/credential-cache--daemon.c +++ b/builtin/credential-cache--daemon.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "alloc.h" #include "gettext.h" #include "parse-options.h" diff --git a/builtin/diagnose.c b/builtin/diagnose.c index 5b12d1fb96..0f8b64994c 100644 --- a/builtin/diagnose.c +++ b/builtin/diagnose.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "gettext.h" #include "parse-options.h" #include "diagnose.h" diff --git a/builtin/difftool.c b/builtin/difftool.c index f7380dd1cc..ed06db1208 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -13,6 +13,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "abspath.h" #include "config.h" #include "builtin.h" #include "run-command.h" diff --git a/builtin/fast-import.c b/builtin/fast-import.c index f3635c7aef..7307c4657f 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "cache.h" #include "gettext.h" #include "hex.h" diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c index 215e3813d7..4efb141734 100644 --- a/builtin/fsmonitor--daemon.c +++ b/builtin/fsmonitor--daemon.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/builtin/gc.c b/builtin/gc.c index 32cabad7cf..ef063fc828 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -11,6 +11,7 @@ */ #include "builtin.h" +#include "abspath.h" #include "hex.h" #include "repository.h" #include "config.h" diff --git a/builtin/hash-object.c b/builtin/hash-object.c index f233eda759..7651a7a5f5 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -5,6 +5,7 @@ * Copyright (C) Junio C Hamano, 2005 */ #include "builtin.h" +#include "abspath.h" #include "config.h" #include "gettext.h" #include "hex.h" diff --git a/builtin/init-db.c b/builtin/init-db.c index e182bc7e83..6f724f694f 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "abspath.h" #include "config.h" #include "gettext.h" #include "refs.h" diff --git a/builtin/log.c b/builtin/log.c index e702cf126e..b7333b34cc 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -5,6 +5,7 @@ * 2006 Junio Hamano */ #include "git-compat-util.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index e8bb011cfb..e14f7c0abc 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -3,6 +3,7 @@ * email to figure out authorship and subject */ #include "cache.h" +#include "abspath.h" #include "builtin.h" #include "gettext.h" #include "utf8.h" diff --git a/builtin/merge-file.c b/builtin/merge-file.c index ae45f523b9..c0096ee081 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "cache.h" #include "config.h" #include "gettext.h" diff --git a/builtin/merge.c b/builtin/merge.c index 2c9da4b23d..38243e55c5 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -8,6 +8,7 @@ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "environment.h" diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c index e6757a4447..579bc2cac0 100644 --- a/builtin/multi-pack-index.c +++ b/builtin/multi-pack-index.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "cache.h" #include "config.h" #include "gettext.h" diff --git a/builtin/mv.c b/builtin/mv.c index c02dddb72b..0a49bf21b0 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/builtin/rebase.c b/builtin/rebase.c index a2c68b8ff7..a3f8be8888 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -6,6 +6,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "abspath.h" #include "gettext.h" #include "hex.h" #include "run-command.h" diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 006565f851..aec5ee930b 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "abspath.h" #include "repository.h" #include "config.h" #include "gettext.h" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index 5a932a861b..a4c0878bc9 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "commit.h" diff --git a/builtin/stash.c b/builtin/stash.c index 65817d0b76..52fa892f7e 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1,5 +1,6 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "abspath.h" #include "config.h" #include "gettext.h" #include "hex.h" diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index a4bdd44daa..ff1fd8c87a 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1,5 +1,6 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "abspath.h" #include "alloc.h" #include "gettext.h" #include "hex.h" diff --git a/builtin/worktree.c b/builtin/worktree.c index ed89b7e972..ed614ffddc 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "checkout.h" #include "config.h" #include "builtin.h" diff --git a/cache.h b/cache.h index e122de6f93..260203c7a6 100644 --- a/cache.h +++ b/cache.h @@ -598,21 +598,6 @@ const char *setup_git_directory(void); char *prefix_path(const char *prefix, int len, const char *path); char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path); -/* - * Concatenate "prefix" (if len is non-zero) and "path", with no - * connecting characters (so "prefix" should end with a "/"). - * Unlike prefix_path, this should be used if the named file does - * not have to interact with index entry; i.e. name of a random file - * on the filesystem. - * - * The return value is always a newly allocated string (even if the - * prefix was empty). - */ -char *prefix_filename(const char *prefix, const char *path); - -/* Likewise, but path=="-" always yields "-" */ -char *prefix_filename_except_for_dash(const char *prefix, const char *path); - int check_filename(const char *prefix, const char *name); void verify_filename(const char *prefix, const char *name, @@ -1160,18 +1145,6 @@ char *interpolate_path(const char *path, int real_home); /* NEEDSWORK: remove this synonym once in-flight topics have migrated */ #define expand_user_path interpolate_path const char *enter_repo(const char *path, int strict); -static inline int is_absolute_path(const char *path) -{ - return is_dir_sep(path[0]) || has_dos_drive_prefix(path); -} -int is_directory(const char *); -char *strbuf_realpath(struct strbuf *resolved, const char *path, - int die_on_error); -char *strbuf_realpath_forgiving(struct strbuf *resolved, const char *path, - int die_on_error); -char *real_pathdup(const char *path, int die_on_error); -const char *absolute_path(const char *path); -char *absolute_pathdup(const char *path); const char *remove_leading_path(const char *in, const char *prefix); const char *relative_path(const char *in, const char *prefix, struct strbuf *sb); int normalize_path_copy_len(char *dst, const char *src, int *prefix_len); diff --git a/chdir-notify.c b/chdir-notify.c index 5f7f2c2ac2..929ec01b3a 100644 --- a/chdir-notify.c +++ b/chdir-notify.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "chdir-notify.h" #include "list.h" #include "strbuf.h" diff --git a/compat/disk.h b/compat/disk.h index a04a8d294a..6c979c27d8 100644 --- a/compat/disk.h +++ b/compat/disk.h @@ -2,6 +2,7 @@ #define COMPAT_DISK_H #include "git-compat-util.h" +#include "abspath.h" #include "gettext.h" static int get_disk_info(struct strbuf *out) diff --git a/compat/mingw.c b/compat/mingw.c index a9e5570288..cbcd03aea9 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -7,6 +7,7 @@ #include "../strbuf.h" #include "../run-command.h" #include "../cache.h" +#include "../abspath.h" #include "../alloc.h" #include "win32/lazyload.h" #include "../config.h" diff --git a/compat/simple-ipc/ipc-win32.c b/compat/simple-ipc/ipc-win32.c index f011e5cead..997f614434 100644 --- a/compat/simple-ipc/ipc-win32.c +++ b/compat/simple-ipc/ipc-win32.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "gettext.h" #include "simple-ipc.h" #include "strbuf.h" diff --git a/config.c b/config.c index f30a6d8e68..6815919ec3 100644 --- a/config.c +++ b/config.c @@ -6,6 +6,7 @@ * */ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "date.h" #include "branch.h" diff --git a/credential.c b/credential.c index 5244f3c12c..e6417bf880 100644 --- a/credential.c +++ b/credential.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "config.h" #include "credential.h" #include "gettext.h" diff --git a/daemon.c b/daemon.c index 8908e7f8d2..bb795ca3ca 100644 --- a/daemon.c +++ b/daemon.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "pkt-line.h" diff --git a/diff-no-index.c b/diff-no-index.c index 287a113bad..934a24bee5 100644 --- a/diff-no-index.c +++ b/diff-no-index.c @@ -5,6 +5,7 @@ */ #include "cache.h" +#include "abspath.h" #include "color.h" #include "commit.h" #include "blob.h" diff --git a/diff.c b/diff.c index 00746f2f86..1b0be99c06 100644 --- a/diff.c +++ b/diff.c @@ -2,6 +2,7 @@ * Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/dir.c b/dir.c index 46f1bb6e5b..c72481c60e 100644 --- a/dir.c +++ b/dir.c @@ -6,6 +6,7 @@ * Junio Hamano, 2005-2006 */ #include "git-compat-util.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "dir.h" diff --git a/editor.c b/editor.c index 58e790548d..2d3e6be64e 100644 --- a/editor.c +++ b/editor.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "config.h" #include "gettext.h" #include "strbuf.h" diff --git a/environment.c b/environment.c index 82a1fc17d0..c69571f0b2 100644 --- a/environment.c +++ b/environment.c @@ -8,6 +8,7 @@ * are. */ #include "cache.h" +#include "abspath.h" #include "branch.h" #include "environment.h" #include "gettext.h" diff --git a/exec-cmd.c b/exec-cmd.c index 282d95af08..042d9247a5 100644 --- a/exec-cmd.c +++ b/exec-cmd.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "exec-cmd.h" #include "gettext.h" #include "quote.h" diff --git a/gettext.c b/gettext.c index f139008d0a..3e7b3baabc 100644 --- a/gettext.c +++ b/gettext.c @@ -3,6 +3,7 @@ */ #include "cache.h" +#include "abspath.h" #include "exec-cmd.h" #include "gettext.h" #include "strbuf.h" diff --git a/lockfile.c b/lockfile.c index ab6490a391..673c21d17a 100644 --- a/lockfile.c +++ b/lockfile.c @@ -3,6 +3,7 @@ */ #include "cache.h" +#include "abspath.h" #include "gettext.h" #include "lockfile.h" diff --git a/midx.c b/midx.c index e132ef250e..b111665dca 100644 --- a/midx.c +++ b/midx.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "csum-file.h" diff --git a/object-file.c b/object-file.c index 39660d49db..bee41b3047 100644 --- a/object-file.c +++ b/object-file.c @@ -7,6 +7,7 @@ * creation etc. */ #include "git-compat-util.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/parse-options.c b/parse-options.c index 084b4f1062..a577cc85f6 100644 --- a/parse-options.c +++ b/parse-options.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "parse-options.h" +#include "abspath.h" #include "cache.h" #include "config.h" #include "commit.h" diff --git a/path.c b/path.c index 3f2702cbe4..3976c0d7ac 100644 --- a/path.c +++ b/path.c @@ -2,6 +2,7 @@ * Utilities for paths and pathnames */ #include "cache.h" +#include "abspath.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/pathspec.c b/pathspec.c index 868b4d280c..53763e272f 100644 --- a/pathspec.c +++ b/pathspec.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "config.h" #include "dir.h" #include "gettext.h" diff --git a/remote.c b/remote.c index edb1e07497..2bae247a0a 100644 --- a/remote.c +++ b/remote.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/repository.c b/repository.c index 937fa974b3..4412f63322 100644 --- a/repository.c +++ b/repository.c @@ -4,6 +4,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "abspath.h" #include "repository.h" #include "object-store.h" #include "config.h" diff --git a/rerere.c b/rerere.c index 9428cbca7b..c3258e1390 100644 --- a/rerere.c +++ b/rerere.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "gettext.h" diff --git a/scalar.c b/scalar.c index ca19b95ce4..fe61a3ebdd 100644 --- a/scalar.c +++ b/scalar.c @@ -3,6 +3,7 @@ */ #include "cache.h" +#include "abspath.h" #include "gettext.h" #include "parse-options.h" #include "config.h" diff --git a/sequencer.c b/sequencer.c index 7fa776b061..c61c1fc4d8 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "config.h" #include "environment.h" diff --git a/setup.c b/setup.c index 8a4ccee4c2..8f385d9f29 100644 --- a/setup.c +++ b/setup.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "gettext.h" #include "repository.h" #include "config.h" diff --git a/strbuf.c b/strbuf.c index b9cd593b14..9633e37b62 100644 --- a/strbuf.c +++ b/strbuf.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "environment.h" #include "gettext.h" diff --git a/submodule.c b/submodule.c index 8b551e5327..13ff333f68 100644 --- a/submodule.c +++ b/submodule.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "repository.h" #include "config.h" diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index f69709d674..d3d00dc34f 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "abspath.h" #include "string-list.h" #include "utf8.h" diff --git a/tmp-objdir.c b/tmp-objdir.c index 2a2012eb6d..fff15cb6b5 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -1,5 +1,6 @@ #include "cache.h" #include "tmp-objdir.h" +#include "abspath.h" #include "chdir-notify.h" #include "dir.h" #include "sigchain.h" diff --git a/trace.c b/trace.c index efa4e2d8e0..2b41c683fc 100644 --- a/trace.c +++ b/trace.c @@ -22,6 +22,7 @@ */ #include "cache.h" +#include "abspath.h" #include "quote.h" struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 }; diff --git a/trace2/tr2_dst.c b/trace2/tr2_dst.c index 8a21dd2972..273260e1f1 100644 --- a/trace2/tr2_dst.c +++ b/trace2/tr2_dst.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "sigchain.h" #include "trace2/tr2_dst.h" #include "trace2/tr2_sid.h" diff --git a/worktree.c b/worktree.c index 09eb522e5a..b7bc4c7bb7 100644 --- a/worktree.c +++ b/worktree.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "abspath.h" #include "alloc.h" #include "gettext.h" #include "repository.h" diff --git a/wrapper.c b/wrapper.c index 0d4ceba6fc..df1fa6286d 100644 --- a/wrapper.c +++ b/wrapper.c @@ -2,6 +2,7 @@ * Various trivial helper wrappers around standard functions */ #include "cache.h" +#include "abspath.h" #include "config.h" #include "gettext.h" -- cgit v1.2.3 From d5ebb50dcb2bae27cf9f233088f7258f21e72be7 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 21 Mar 2023 06:26:01 +0000 Subject: wrapper.h: move declarations for wrapper.c functions from cache.h Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- apply.c | 1 + builtin/am.c | 1 + builtin/bisect.c | 1 + builtin/branch.c | 1 + builtin/bugreport.c | 2 +- builtin/config.c | 1 + builtin/credential-cache.c | 1 + builtin/difftool.c | 1 + builtin/fast-import.c | 1 + builtin/fmt-merge-msg.c | 1 + builtin/gc.c | 1 + builtin/get-tar-commit-id.c | 1 + builtin/index-pack.c | 1 + builtin/init-db.c | 1 + builtin/merge.c | 1 + builtin/pack-objects.c | 1 + builtin/rebase.c | 1 + builtin/receive-pack.c | 1 + builtin/rerere.c | 1 + builtin/unpack-file.c | 1 + builtin/worktree.c | 1 + cache.h | 32 -------------------------------- commit-graph.c | 1 + compat/mingw.c | 1 + compat/terminal.c | 1 + config.c | 1 + convert.c | 1 + copy.c | 1 + csum-file.c | 1 + daemon.c | 1 + diff.c | 1 + dir.c | 1 + entry.c | 1 + environment.c | 1 + fetch-pack.c | 1 + gpg-interface.c | 1 + http-backend.c | 1 + imap-send.c | 1 + ll-merge.c | 1 + merge-recursive.c | 1 + notes-merge.c | 1 + object-file.c | 1 + packfile.c | 1 + parallel-checkout.c | 1 + pkt-line.c | 1 + read-cache.c | 1 + rebase-interactive.c | 1 + refs.c | 1 + refs/files-backend.c | 3 ++- rerere.c | 1 + sequencer.c | 1 + server-info.c | 1 + shallow.c | 1 + strbuf.c | 1 + streaming.c | 1 + t/helper/test-delta.c | 1 + t/helper/test-fsmonitor-client.c | 1 + t/helper/test-read-cache.c | 1 + tag.c | 1 + tempfile.c | 1 + trace.c | 1 + transport-helper.c | 1 + transport.c | 1 + usage.c | 1 + worktree.c | 1 + wrapper.c | 1 + wrapper.h | 36 ++++++++++++++++++++++++++++++++++++ write-or-die.c | 1 + 68 files changed, 103 insertions(+), 34 deletions(-) create mode 100644 wrapper.h (limited to 'diff.c') diff --git a/apply.c b/apply.c index e5e11b8579..373565a7ba 100644 --- a/apply.c +++ b/apply.c @@ -26,6 +26,7 @@ #include "rerere.h" #include "apply.h" #include "entry.h" +#include "wrapper.h" struct gitdiff_data { struct strbuf *root; diff --git a/builtin/am.c b/builtin/am.c index 14347ecf9a..37f82b3eb4 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -38,6 +38,7 @@ #include "packfile.h" #include "repository.h" #include "pretty.h" +#include "wrapper.h" /** * Returns the length of the first line of msg. diff --git a/builtin/bisect.c b/builtin/bisect.c index 09188e554b..31cc57e45b 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -11,6 +11,7 @@ #include "prompt.h" #include "quote.h" #include "revision.h" +#include "wrapper.h" static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS") static GIT_PATH_FUNC(git_path_bisect_expected_rev, "BISECT_EXPECTED_REV") diff --git a/builtin/branch.c b/builtin/branch.c index 56dbee97d2..98475ea532 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -26,6 +26,7 @@ #include "worktree.h" #include "help.h" #include "commit-reach.h" +#include "wrapper.h" static const char * const builtin_branch_usage[] = { N_("git branch [] [-r | -a] [--merged] [--no-merged]"), diff --git a/builtin/bugreport.c b/builtin/bugreport.c index b5dfad4e12..160590e4ef 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -8,7 +8,7 @@ #include "hook.h" #include "hook-list.h" #include "diagnose.h" - +#include "wrapper.h" static void get_system_info(struct strbuf *sys_info) { diff --git a/builtin/config.c b/builtin/config.c index 42e6b8d348..1c1e006ff3 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -9,6 +9,7 @@ #include "urlmatch.h" #include "quote.h" #include "worktree.h" +#include "wrapper.h" static const char *const builtin_config_usage[] = { N_("git config []"), diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c index 25f2f71c21..af56a44923 100644 --- a/builtin/credential-cache.c +++ b/builtin/credential-cache.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "gettext.h" #include "parse-options.h" +#include "wrapper.h" #ifndef NO_UNIX_SOCKETS diff --git a/builtin/difftool.c b/builtin/difftool.c index ed06db1208..59465c39f1 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -27,6 +27,7 @@ #include "object-store.h" #include "dir.h" #include "entry.h" +#include "wrapper.h" static int trust_exit_code; diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 7307c4657f..3300b7f30f 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -23,6 +23,7 @@ #include "commit-reach.h" #include "khash.h" #include "date.h" +#include "wrapper.h" #define PACK_ID_BITS 16 #define MAX_PACK_ID ((1<] [--log[=] | --no-log] [--file ]"), diff --git a/builtin/gc.c b/builtin/gc.c index ef063fc828..2107e3d1f2 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -35,6 +35,7 @@ #include "exec-cmd.h" #include "gettext.h" #include "hook.h" +#include "wrapper.h" #define FAILED_RUN "failed to run %s" diff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c index 491af9202d..6745796998 100644 --- a/builtin/get-tar-commit-id.c +++ b/builtin/get-tar-commit-id.c @@ -6,6 +6,7 @@ #include "tar.h" #include "builtin.h" #include "quote.h" +#include "wrapper.h" static const char builtin_get_tar_commit_id_usage[] = "git get-tar-commit-id"; diff --git a/builtin/index-pack.c b/builtin/index-pack.c index bae5b05403..2393897cb8 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -19,6 +19,7 @@ #include "object-store.h" #include "replace-object.h" #include "promisor-remote.h" +#include "wrapper.h" static const char index_pack_usage[] = "git index-pack [-v] [-o ] [--keep | --keep=] [--[no-]rev-index] [--verify] [--strict] ( | --stdin [--fix-thin] [])"; diff --git a/builtin/init-db.c b/builtin/init-db.c index 6f724f694f..a5d4f5c8ec 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -12,6 +12,7 @@ #include "exec-cmd.h" #include "parse-options.h" #include "worktree.h" +#include "wrapper.h" #ifndef DEFAULT_GIT_TEMPLATE_DIR #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates" diff --git a/builtin/merge.c b/builtin/merge.c index 38243e55c5..f4f4a220f3 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -49,6 +49,7 @@ #include "commit-reach.h" #include "wt-status.h" #include "commit-graph.h" +#include "wrapper.h" #define DEFAULT_TWOHEAD (1<<0) #define DEFAULT_OCTOPUS (1<<1) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 1ca800c7c5..8b55a088a7 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -40,6 +40,7 @@ #include "shallow.h" #include "promisor-remote.h" #include "pack-mtimes.h" +#include "wrapper.h" /* * Objects we are going to pack are collected in the `to_pack` structure. diff --git a/builtin/rebase.c b/builtin/rebase.c index a3f8be8888..d2f8f703d6 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -32,6 +32,7 @@ #include "rebase-interactive.h" #include "reset.h" #include "hook.h" +#include "wrapper.h" static char const * const builtin_rebase_usage[] = { N_("git rebase [-i] [options] [--exec ] " diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index aec5ee930b..ae49ea8c2a 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -33,6 +33,7 @@ #include "commit-reach.h" #include "worktree.h" #include "shallow.h" +#include "wrapper.h" static const char * const receive_pack_usage[] = { N_("git receive-pack "), diff --git a/builtin/rerere.c b/builtin/rerere.c index 24c7875572..d4a03707b1 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -6,6 +6,7 @@ #include "parse-options.h" #include "string-list.h" #include "rerere.h" +#include "wrapper.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" #include "pathspec.h" diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c index e9b105a539..4cbb403929 100644 --- a/builtin/unpack-file.c +++ b/builtin/unpack-file.c @@ -2,6 +2,7 @@ #include "config.h" #include "hex.h" #include "object-store.h" +#include "wrapper.h" static char *create_temp_file(struct object_id *oid) { diff --git a/builtin/worktree.c b/builtin/worktree.c index ed614ffddc..1533b4ab43 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -16,6 +16,7 @@ #include "submodule.h" #include "utf8.h" #include "worktree.h" +#include "wrapper.h" #include "quote.h" #define BUILTIN_WORKTREE_ADD_USAGE \ diff --git a/cache.h b/cache.h index 705c41992b..31c722533f 100644 --- a/cache.h +++ b/cache.h @@ -1085,10 +1085,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len); #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len) -/* set default permissions by passing mode arguments to open(2) */ -int git_mkstemps_mode(char *pattern, int suffix_len, int mode); -int git_mkstemp_mode(char *pattern, int mode); - /* * NOTE NOTE NOTE!! * @@ -1423,31 +1419,6 @@ static inline int batch_fsync_enabled(enum fsync_component component) return (fsync_components & component) && (fsync_method == FSYNC_METHOD_BATCH); } -ssize_t read_in_full(int fd, void *buf, size_t count); -ssize_t write_in_full(int fd, const void *buf, size_t count); -ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset); - -static inline ssize_t write_str_in_full(int fd, const char *str) -{ - return write_in_full(fd, str, strlen(str)); -} - -/** - * Open (and truncate) the file at path, write the contents of buf to it, - * and close it. Dies if any errors are encountered. - */ -void write_file_buf(const char *path, const char *buf, size_t len); - -/** - * Like write_file_buf(), but format the contents into a buffer first. - * Additionally, write_file() will append a newline if one is not already - * present, making it convenient to write text files: - * - * write_file(path, "counter: %d", ctr); - */ -__attribute__((format (printf, 2, 3))) -void write_file(const char *path, const char *fmt, ...); - /* pager.c */ void setup_pager(void); int pager_in_use(void); @@ -1571,7 +1542,4 @@ int versioncmp(const char *s1, const char *s2); */ int print_sha1_ellipsis(void); -/* Return 1 if the file is empty or does not exists, 0 otherwise. */ -int is_empty_or_missing_file(const char *filename); - #endif /* CACHE_H */ diff --git a/commit-graph.c b/commit-graph.c index 8f21a0a0c2..5481736c76 100644 --- a/commit-graph.c +++ b/commit-graph.c @@ -22,6 +22,7 @@ #include "json-writer.h" #include "trace2.h" #include "chunk-format.h" +#include "wrapper.h" void git_test_write_commit_graph_or_die(void) { diff --git a/compat/mingw.c b/compat/mingw.c index cbcd03aea9..d48899bf7b 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -11,6 +11,7 @@ #include "../alloc.h" #include "win32/lazyload.h" #include "../config.h" +#include "../wrapper.h" #include "dir.h" #include "gettext.h" #define SECURITY_WIN32 diff --git a/compat/terminal.c b/compat/terminal.c index afebe6b249..ed2b30b38f 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -6,6 +6,7 @@ #include "run-command.h" #include "string-list.h" #include "hashmap.h" +#include "wrapper.h" #if defined(HAVE_DEV_TTY) || defined(GIT_WINDOWS_NATIVE) diff --git a/config.c b/config.c index 6815919ec3..5b1a5d5205 100644 --- a/config.c +++ b/config.c @@ -28,6 +28,7 @@ #include "replace-object.h" #include "refs.h" #include "worktree.h" +#include "wrapper.h" struct config_source { struct config_source *prev; diff --git a/convert.c b/convert.c index 2bd54244b5..da06e2f51c 100644 --- a/convert.c +++ b/convert.c @@ -11,6 +11,7 @@ #include "sub-process.h" #include "utf8.h" #include "ll-merge.h" +#include "wrapper.h" /* * convert.c - convert a file when checking it out and checking it in. diff --git a/copy.c b/copy.c index 4de6a110f0..c3250f0822 100644 --- a/copy.c +++ b/copy.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "wrapper.h" int copy_fd(int ifd, int ofd) { diff --git a/csum-file.c b/csum-file.c index cce13c0f04..2d22f80d90 100644 --- a/csum-file.c +++ b/csum-file.c @@ -10,6 +10,7 @@ #include "cache.h" #include "progress.h" #include "csum-file.h" +#include "wrapper.h" static void verify_buffer_or_die(struct hashfile *f, const void *buf, diff --git a/daemon.c b/daemon.c index bb795ca3ca..e35604e194 100644 --- a/daemon.c +++ b/daemon.c @@ -6,6 +6,7 @@ #include "run-command.h" #include "strbuf.h" #include "string-list.h" +#include "wrapper.h" #ifdef NO_INITGROUPS #define initgroups(x, y) (0) /* nothing */ diff --git a/diff.c b/diff.c index 1b0be99c06..1b0b24c21c 100644 --- a/diff.c +++ b/diff.c @@ -33,6 +33,7 @@ #include "promisor-remote.h" #include "dir.h" #include "strmap.h" +#include "wrapper.h" #ifdef NO_FAST_WORKING_DIRECTORY #define FAST_WORKING_DIRECTORY 0 diff --git a/dir.c b/dir.c index c72481c60e..b57c770e68 100644 --- a/dir.c +++ b/dir.c @@ -21,6 +21,7 @@ #include "ewah/ewok.h" #include "fsmonitor.h" #include "submodule-config.h" +#include "wrapper.h" /* * Tells read_directory_recursive how a file or directory should be treated. diff --git a/entry.c b/entry.c index acb76a61ac..70212af260 100644 --- a/entry.c +++ b/entry.c @@ -10,6 +10,7 @@ #include "fsmonitor.h" #include "entry.h" #include "parallel-checkout.h" +#include "wrapper.h" static void create_directories(const char *path, int path_len, const struct checkout *state) diff --git a/environment.c b/environment.c index c69571f0b2..bf02f3cf48 100644 --- a/environment.c +++ b/environment.c @@ -23,6 +23,7 @@ #include "tmp-objdir.h" #include "chdir-notify.h" #include "shallow.h" +#include "wrapper.h" int trust_executable_bit = 1; int trust_ctime = 1; diff --git a/fetch-pack.c b/fetch-pack.c index 359dce6afe..c119080140 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -30,6 +30,7 @@ #include "commit-graph.h" #include "sigchain.h" #include "mergesort.h" +#include "wrapper.h" static int transfer_unpack_limit = -1; static int fetch_unpack_limit = -1; diff --git a/gpg-interface.c b/gpg-interface.c index f9c5b6c3f5..6644701fda 100644 --- a/gpg-interface.c +++ b/gpg-interface.c @@ -10,6 +10,7 @@ #include "sigchain.h" #include "tempfile.h" #include "alias.h" +#include "wrapper.h" static int git_gpg_config(const char *, const char *, void *); diff --git a/http-backend.c b/http-backend.c index 7e7c19e66b..42e6c2596e 100644 --- a/http-backend.c +++ b/http-backend.c @@ -16,6 +16,7 @@ #include "object-store.h" #include "protocol.h" #include "date.h" +#include "wrapper.h" static const char content_type[] = "Content-Type"; static const char content_length[] = "Content-Length"; diff --git a/imap-send.c b/imap-send.c index c65a27219c..aa5b2f252d 100644 --- a/imap-send.c +++ b/imap-send.c @@ -28,6 +28,7 @@ #include "gettext.h" #include "run-command.h" #include "parse-options.h" +#include "wrapper.h" #if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG) typedef void *SSL; #endif diff --git a/ll-merge.c b/ll-merge.c index 130d26501c..8be38d3bd4 100644 --- a/ll-merge.c +++ b/ll-merge.c @@ -11,6 +11,7 @@ #include "run-command.h" #include "ll-merge.h" #include "quote.h" +#include "wrapper.h" struct ll_merge_driver; diff --git a/merge-recursive.c b/merge-recursive.c index 0b0255ebc8..f918cea4c6 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -30,6 +30,7 @@ #include "tag.h" #include "tree-walk.h" #include "unpack-trees.h" +#include "wrapper.h" #include "xdiff-interface.h" struct merge_options_internal { diff --git a/notes-merge.c b/notes-merge.c index c8d0020b1a..ba2970f070 100644 --- a/notes-merge.c +++ b/notes-merge.c @@ -15,6 +15,7 @@ #include "strbuf.h" #include "notes-utils.h" #include "commit-reach.h" +#include "wrapper.h" struct notes_merge_pair { struct object_id obj, base, local, remote; diff --git a/object-file.c b/object-file.c index bee41b3047..bdf68763a5 100644 --- a/object-file.c +++ b/object-file.c @@ -38,6 +38,7 @@ #include "promisor-remote.h" #include "submodule.h" #include "fsck.h" +#include "wrapper.h" /* The maximum size for an object header. */ #define MAX_HEADER_LEN 32 diff --git a/packfile.c b/packfile.c index 3290fde15a..8c117ccee2 100644 --- a/packfile.c +++ b/packfile.c @@ -20,6 +20,7 @@ #include "midx.h" #include "commit-graph.h" #include "promisor-remote.h" +#include "wrapper.h" char *odb_pack_name(struct strbuf *buf, const unsigned char *hash, diff --git a/parallel-checkout.c b/parallel-checkout.c index 38c4dc665d..50fd7fe31e 100644 --- a/parallel-checkout.c +++ b/parallel-checkout.c @@ -12,6 +12,7 @@ #include "streaming.h" #include "thread-utils.h" #include "trace2.h" +#include "wrapper.h" struct pc_worker { struct child_process cp; diff --git a/pkt-line.c b/pkt-line.c index c8b90b2242..30469eb4d8 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -3,6 +3,7 @@ #include "gettext.h" #include "hex.h" #include "run-command.h" +#include "wrapper.h" char packet_buffer[LARGE_PACKET_MAX]; static const char *packet_trace_prefix = "git"; diff --git a/read-cache.c b/read-cache.c index 63789ea5e2..9a8d5fe97e 100644 --- a/read-cache.c +++ b/read-cache.c @@ -32,6 +32,7 @@ #include "csum-file.h" #include "promisor-remote.h" #include "hook.h" +#include "wrapper.h" /* Mask for the name length in ce_flags in the on-disk index */ diff --git a/rebase-interactive.c b/rebase-interactive.c index 649c94e69a..7c885c35bf 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -7,6 +7,7 @@ #include "commit-slab.h" #include "config.h" #include "dir.h" +#include "wrapper.h" static const char edit_todo_list_advice[] = N_("You can fix this with 'git rebase --edit-todo' " diff --git a/refs.c b/refs.c index 8684f4610f..385051752f 100644 --- a/refs.c +++ b/refs.c @@ -24,6 +24,7 @@ #include "sigchain.h" #include "date.h" #include "commit.h" +#include "wrapper.h" /* * List of all available backends diff --git a/refs/files-backend.c b/refs/files-backend.c index de3628ff3f..eb14d124e3 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -13,7 +13,8 @@ #include "../object.h" #include "../dir.h" #include "../chdir-notify.h" -#include "worktree.h" +#include "../worktree.h" +#include "../wrapper.h" /* * This backend uses the following flags in `ref_update::flags` for diff --git a/rerere.c b/rerere.c index c3258e1390..b5ccbecdcd 100644 --- a/rerere.c +++ b/rerere.c @@ -16,6 +16,7 @@ #include "object-store.h" #include "hash-lookup.h" #include "strmap.h" +#include "wrapper.h" #define RESOLVED 0 #define PUNTED 1 diff --git a/sequencer.c b/sequencer.c index c61c1fc4d8..aa7983f5b4 100644 --- a/sequencer.c +++ b/sequencer.c @@ -41,6 +41,7 @@ #include "rebase-interactive.h" #include "reset.h" #include "branch.h" +#include "wrapper.h" #define GIT_REFLOG_ACTION "GIT_REFLOG_ACTION" diff --git a/server-info.c b/server-info.c index 7864337705..ae96d784e5 100644 --- a/server-info.c +++ b/server-info.c @@ -10,6 +10,7 @@ #include "packfile.h" #include "object-store.h" #include "strbuf.h" +#include "wrapper.h" struct update_info_ctx { FILE *cur_fp; diff --git a/shallow.c b/shallow.c index c5433a4fd3..7fcba5f6d0 100644 --- a/shallow.c +++ b/shallow.c @@ -17,6 +17,7 @@ #include "list-objects.h" #include "commit-reach.h" #include "shallow.h" +#include "wrapper.h" void set_alternate_shallow_file(struct repository *r, const char *path, int override) { diff --git a/strbuf.c b/strbuf.c index 9633e37b62..70a83e7980 100644 --- a/strbuf.c +++ b/strbuf.c @@ -8,6 +8,7 @@ #include "string-list.h" #include "utf8.h" #include "date.h" +#include "wrapper.h" int starts_with(const char *str, const char *prefix) { diff --git a/streaming.c b/streaming.c index 27841dc1d9..6c69f59504 100644 --- a/streaming.c +++ b/streaming.c @@ -7,6 +7,7 @@ #include "object-store.h" #include "replace-object.h" #include "packfile.h" +#include "wrapper.h" typedef int (*open_istream_fn)(struct git_istream *, struct repository *, diff --git a/t/helper/test-delta.c b/t/helper/test-delta.c index b15481ea59..6609fcbc12 100644 --- a/t/helper/test-delta.c +++ b/t/helper/test-delta.c @@ -12,6 +12,7 @@ #include "git-compat-util.h" #include "delta.h" #include "cache.h" +#include "wrapper.h" static const char usage_str[] = "test-tool delta (-d|-p) "; diff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c index 54a4856c48..c43fc976b8 100644 --- a/t/helper/test-fsmonitor-client.c +++ b/t/helper/test-fsmonitor-client.c @@ -9,6 +9,7 @@ #include "fsmonitor-ipc.h" #include "thread-utils.h" #include "trace2.h" +#include "wrapper.h" #ifndef HAVE_FSMONITOR_DAEMON_BACKEND int cmd__fsmonitor_client(int argc, const char **argv) diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index 23e9e27109..84818363d5 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -2,6 +2,7 @@ #include "test-tool.h" #include "cache.h" #include "config.h" +#include "wrapper.h" int cmd__read_cache(int argc, const char **argv) { diff --git a/tag.c b/tag.c index 18b718cca6..3408bb9433 100644 --- a/tag.c +++ b/tag.c @@ -8,6 +8,7 @@ #include "gpg-interface.h" #include "hex.h" #include "packfile.h" +#include "wrapper.h" const char *tag_type = "tag"; diff --git a/tempfile.c b/tempfile.c index e27048f970..cdd2cab3ba 100644 --- a/tempfile.c +++ b/tempfile.c @@ -45,6 +45,7 @@ #include "cache.h" #include "tempfile.h" #include "sigchain.h" +#include "wrapper.h" static VOLATILE_LIST_HEAD(tempfile_list); diff --git a/trace.c b/trace.c index 2b41c683fc..de004f6298 100644 --- a/trace.c +++ b/trace.c @@ -24,6 +24,7 @@ #include "cache.h" #include "abspath.h" #include "quote.h" +#include "wrapper.h" struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 }; struct trace_key trace_perf_key = TRACE_KEY_INIT(PERFORMANCE); diff --git a/transport-helper.c b/transport-helper.c index 105bb801c2..09048eab48 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -16,6 +16,7 @@ #include "refspec.h" #include "transport-internal.h" #include "protocol.h" +#include "wrapper.h" static int debug; diff --git a/transport.c b/transport.c index 80059124c0..c6179b801e 100644 --- a/transport.c +++ b/transport.c @@ -26,6 +26,7 @@ #include "object-store.h" #include "color.h" #include "bundle-uri.h" +#include "wrapper.h" static int transport_use_color = -1; static char transport_colors[][COLOR_MAXLEN] = { diff --git a/usage.c b/usage.c index 40a1c5a433..b53c99dbe5 100644 --- a/usage.c +++ b/usage.c @@ -5,6 +5,7 @@ */ #include "cache.h" #include "gettext.h" +#include "wrapper.h" static void vreportf(const char *prefix, const char *err, va_list params) { diff --git a/worktree.c b/worktree.c index b7bc4c7bb7..fe4345012c 100644 --- a/worktree.c +++ b/worktree.c @@ -9,6 +9,7 @@ #include "dir.h" #include "wt-status.h" #include "config.h" +#include "wrapper.h" void free_worktrees(struct worktree **worktrees) { diff --git a/wrapper.c b/wrapper.c index df1fa6286d..ee83757590 100644 --- a/wrapper.c +++ b/wrapper.c @@ -5,6 +5,7 @@ #include "abspath.h" #include "config.h" #include "gettext.h" +#include "wrapper.h" static intmax_t count_fsync_writeout_only; static intmax_t count_fsync_hardware_flush; diff --git a/wrapper.h b/wrapper.h new file mode 100644 index 0000000000..f0c7d0616d --- /dev/null +++ b/wrapper.h @@ -0,0 +1,36 @@ +#ifndef WRAPPER_H +#define WRAPPER_H + +/* set default permissions by passing mode arguments to open(2) */ +int git_mkstemps_mode(char *pattern, int suffix_len, int mode); +int git_mkstemp_mode(char *pattern, int mode); + +ssize_t read_in_full(int fd, void *buf, size_t count); +ssize_t write_in_full(int fd, const void *buf, size_t count); +ssize_t pread_in_full(int fd, void *buf, size_t count, off_t offset); + +static inline ssize_t write_str_in_full(int fd, const char *str) +{ + return write_in_full(fd, str, strlen(str)); +} + +/** + * Open (and truncate) the file at path, write the contents of buf to it, + * and close it. Dies if any errors are encountered. + */ +void write_file_buf(const char *path, const char *buf, size_t len); + +/** + * Like write_file_buf(), but format the contents into a buffer first. + * Additionally, write_file() will append a newline if one is not already + * present, making it convenient to write text files: + * + * write_file(path, "counter: %d", ctr); + */ +__attribute__((format (printf, 2, 3))) +void write_file(const char *path, const char *fmt, ...); + +/* Return 1 if the file is empty or does not exists, 0 otherwise. */ +int is_empty_or_missing_file(const char *filename); + +#endif /* WRAPPER_H */ diff --git a/write-or-die.c b/write-or-die.c index aaa0318e82..a7afc303db 100644 --- a/write-or-die.c +++ b/write-or-die.c @@ -1,6 +1,7 @@ #include "cache.h" #include "config.h" #include "run-command.h" +#include "wrapper.h" /* * Some cases use stdio, but want to flush after the write -- cgit v1.2.3 From 32a8f510614312cc8b81bbc6a982d08ab7562ab4 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 21 Mar 2023 06:26:03 +0000 Subject: environment.h: move declarations for environment.c functions from cache.h Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- apply.c | 1 + archive.c | 1 + attr.c | 1 + bisect.c | 1 + branch.c | 1 + builtin/am.c | 1 + builtin/bisect.c | 1 + builtin/blame.c | 1 + builtin/cat-file.c | 1 + builtin/check-attr.c | 1 + builtin/checkout.c | 1 + builtin/clone.c | 1 + builtin/commit-graph.c | 1 + builtin/config.c | 1 + builtin/count-objects.c | 1 + builtin/describe.c | 1 + builtin/difftool.c | 1 + builtin/fast-import.c | 1 + builtin/fetch.c | 1 + builtin/fsmonitor--daemon.c | 1 + builtin/gc.c | 1 + builtin/index-pack.c | 1 + builtin/init-db.c | 1 + builtin/log.c | 1 + builtin/mailinfo.c | 1 + builtin/multi-pack-index.c | 1 + builtin/mv.c | 1 + builtin/name-rev.c | 1 + builtin/pack-objects.c | 1 + builtin/prune.c | 1 + builtin/push.c | 1 + builtin/rebase.c | 1 + builtin/receive-pack.c | 1 + builtin/repack.c | 1 + builtin/replace.c | 1 + builtin/reset.c | 1 + builtin/rev-list.c | 1 + builtin/rev-parse.c | 1 + builtin/shortlog.c | 1 + builtin/show-branch.c | 1 + builtin/sparse-checkout.c | 1 + builtin/stash.c | 1 + builtin/submodule--helper.c | 1 + builtin/unpack-objects.c | 1 + builtin/update-index.c | 1 + builtin/worktree.c | 1 + builtin/write-tree.c | 1 + bulk-checkin.c | 1 + bundle-uri.c | 1 + bundle.c | 1 + cache-tree.c | 1 + cache.h | 207 ----------------------------------- combine-diff.c | 1 + compat/mingw.c | 1 + compat/precompose_utf8.c | 1 + connect.c | 1 + daemon.c | 1 + diff.c | 1 + dir.c | 1 + editor.c | 1 + entry.c | 1 + environment.h | 213 ++++++++++++++++++++++++++++++++++++ exec-cmd.c | 1 + fetch-pack.c | 1 + fsmonitor.c | 1 + gettext.c | 1 + git.c | 1 + http-backend.c | 1 + http-push.c | 1 + log-tree.c | 1 + ls-refs.c | 1 + mailmap.c | 1 + merge-ort.c | 1 + merge-recursive.c | 1 + name-hash.c | 1 + notes-utils.c | 1 + notes.c | 1 + object-file.c | 1 + object-name.c | 1 + pack-bitmap-write.c | 1 + pack-check.c | 1 + pack-write.c | 1 + packfile.c | 1 + parse-options-cb.c | 1 + path.c | 1 + pathspec.c | 1 + preload-index.c | 1 + pretty.c | 1 + prompt.c | 1 + protocol.c | 1 + prune-packed.c | 1 + range-diff.c | 1 + read-cache.c | 1 + rebase-interactive.c | 1 + ref-filter.c | 1 + refs.c | 1 + refs/files-backend.c | 1 + remote-curl.c | 1 + remote.c | 1 + revision.c | 1 + run-command.c | 1 + server-info.c | 1 + setup.c | 1 + sparse-index.c | 1 + streaming.c | 1 + submodule-config.c | 1 + submodule.c | 1 + t/helper/test-fast-rebase.c | 1 + t/helper/test-lazy-init-name-hash.c | 1 + t/helper/test-path-utils.c | 1 + t/helper/test-repository.c | 1 + tag.c | 1 + tmp-objdir.c | 1 + trace.c | 1 + transport-helper.c | 1 + transport.c | 1 + unpack-trees.c | 1 + upload-pack.c | 1 + worktree.c | 1 + 119 files changed, 330 insertions(+), 207 deletions(-) (limited to 'diff.c') diff --git a/apply.c b/apply.c index 373565a7ba..a7c0bccb15 100644 --- a/apply.c +++ b/apply.c @@ -16,6 +16,7 @@ #include "delta.h" #include "diff.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "xdiff-interface.h" diff --git a/archive.c b/archive.c index c3c45a5ebe..7aeaaf368f 100644 --- a/archive.c +++ b/archive.c @@ -2,6 +2,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "refs.h" diff --git a/attr.c b/attr.c index 48e2d64618..62127196cb 100644 --- a/attr.c +++ b/attr.c @@ -9,6 +9,7 @@ #include "cache.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "exec-cmd.h" #include "attr.h" #include "dir.h" diff --git a/bisect.c b/bisect.c index 5a3a8182d8..8a4be05dc5 100644 --- a/bisect.c +++ b/bisect.c @@ -2,6 +2,7 @@ #include "config.h" #include "commit.h" #include "diff.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "revision.h" diff --git a/branch.c b/branch.c index 66d32c6856..3865bdbc87 100644 --- a/branch.c +++ b/branch.c @@ -2,6 +2,7 @@ #include "cache.h" #include "config.h" #include "branch.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "refs.h" diff --git a/builtin/am.c b/builtin/am.c index 37f82b3eb4..192968ac30 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -8,6 +8,7 @@ #include "abspath.h" #include "config.h" #include "builtin.h" +#include "environment.h" #include "exec-cmd.h" #include "gettext.h" #include "hex.h" diff --git a/builtin/bisect.c b/builtin/bisect.c index 31cc57e45b..d8e92dfa16 100644 --- a/builtin/bisect.c +++ b/builtin/bisect.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "cache.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "parse-options.h" diff --git a/builtin/blame.c b/builtin/blame.c index 21f6b523a6..9ec82edcbd 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -10,6 +10,7 @@ #include "config.h" #include "color.h" #include "builtin.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 9f1bf8f0e9..365d9234bd 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -9,6 +9,7 @@ #include "config.h" #include "builtin.h" #include "diff.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "ident.h" diff --git a/builtin/check-attr.c b/builtin/check-attr.c index ad27255e2c..5870c4683a 100644 --- a/builtin/check-attr.c +++ b/builtin/check-attr.c @@ -3,6 +3,7 @@ #include "cache.h" #include "config.h" #include "attr.h" +#include "environment.h" #include "gettext.h" #include "quote.h" #include "parse-options.h" diff --git a/builtin/checkout.c b/builtin/checkout.c index 47d4c369a1..5541e76c33 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -9,6 +9,7 @@ #include "config.h" #include "diff.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "hook.h" diff --git a/builtin/clone.c b/builtin/clone.c index b94324ea02..15dc15408e 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -12,6 +12,7 @@ #include "builtin.h" #include "abspath.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index 311e010681..9011426976 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/builtin/config.c b/builtin/config.c index 1c1e006ff3..cf994a216c 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -3,6 +3,7 @@ #include "alloc.h" #include "config.h" #include "color.h" +#include "environment.h" #include "gettext.h" #include "ident.h" #include "parse-options.h" diff --git a/builtin/count-objects.c b/builtin/count-objects.c index 48edc86c24..f3d8f1bcbb 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -7,6 +7,7 @@ #include "cache.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "repository.h" #include "builtin.h" diff --git a/builtin/describe.c b/builtin/describe.c index fcacdf8a69..27c6670e93 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/builtin/difftool.c b/builtin/difftool.c index 59465c39f1..3613de6389 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -17,6 +17,7 @@ #include "config.h" #include "builtin.h" #include "run-command.h" +#include "environment.h" #include "exec-cmd.h" #include "gettext.h" #include "hex.h" diff --git a/builtin/fast-import.c b/builtin/fast-import.c index 3300b7f30f..068843a5d2 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "abspath.h" #include "cache.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/builtin/fetch.c b/builtin/fetch.c index 990f81f6d1..4d883da02e 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -4,6 +4,7 @@ #include "cache.h" #include "config.h" #include "gettext.h" +#include "environment.h" #include "hex.h" #include "repository.h" #include "refs.h" diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c index 4efb141734..a280d8bb14 100644 --- a/builtin/fsmonitor--daemon.c +++ b/builtin/fsmonitor--daemon.c @@ -2,6 +2,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "parse-options.h" #include "fsmonitor.h" diff --git a/builtin/gc.c b/builtin/gc.c index 2107e3d1f2..525c5de5b2 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -12,6 +12,7 @@ #include "builtin.h" #include "abspath.h" +#include "environment.h" #include "hex.h" #include "repository.h" #include "config.h" diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 2393897cb8..fdce8f8872 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "delta.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "pack.h" diff --git a/builtin/init-db.c b/builtin/init-db.c index a5d4f5c8ec..2ebc9023f5 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -6,6 +6,7 @@ #include "cache.h" #include "abspath.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "refs.h" #include "builtin.h" diff --git a/builtin/log.c b/builtin/log.c index b7333b34cc..1b92dee196 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -8,6 +8,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "refs.h" diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index e14f7c0abc..a032a1c388 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -5,6 +5,7 @@ #include "cache.h" #include "abspath.h" #include "builtin.h" +#include "environment.h" #include "gettext.h" #include "utf8.h" #include "strbuf.h" diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c index 579bc2cac0..1b5083f8b2 100644 --- a/builtin/multi-pack-index.c +++ b/builtin/multi-pack-index.c @@ -2,6 +2,7 @@ #include "abspath.h" #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "parse-options.h" #include "midx.h" diff --git a/builtin/mv.c b/builtin/mv.c index 0a49bf21b0..c2dd42efbf 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -8,6 +8,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "pathspec.h" #include "lockfile.h" diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 6977a5f580..66f82ef66f 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 8b55a088a7..9829b952c2 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/builtin/prune.c b/builtin/prune.c index ff62a0adb8..5a381fcdf9 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -1,6 +1,7 @@ #include "cache.h" #include "commit.h" #include "diff.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "revision.h" diff --git a/builtin/push.c b/builtin/push.c index 2d76fa6837..fa550b8f80 100644 --- a/builtin/push.c +++ b/builtin/push.c @@ -4,6 +4,7 @@ #include "cache.h" #include "branch.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "refs.h" #include "refspec.h" diff --git a/builtin/rebase.c b/builtin/rebase.c index d2f8f703d6..9f3135116e 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -7,6 +7,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "abspath.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "run-command.h" diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index ae49ea8c2a..3745c0b95c 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -2,6 +2,7 @@ #include "abspath.h" #include "repository.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/builtin/repack.c b/builtin/repack.c index 771ca01527..ccbd5f5556 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "parse-options.h" diff --git a/builtin/replace.c b/builtin/replace.c index cf85e590d9..dc0331defc 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -11,6 +11,7 @@ #include "cache.h" #include "config.h" #include "builtin.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "refs.h" diff --git a/builtin/reset.c b/builtin/reset.c index 4335c1a6e1..b5dfce1159 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -10,6 +10,7 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/builtin/rev-list.c b/builtin/rev-list.c index f2f6a0d3e6..b202647f28 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -2,6 +2,7 @@ #include "config.h" #include "commit.h" #include "diff.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "revision.h" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index a4c0878bc9..bba49d56b9 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -9,6 +9,7 @@ #include "alloc.h" #include "config.h" #include "commit.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "refs.h" diff --git a/builtin/shortlog.c b/builtin/shortlog.c index d8c4379ea1..31f81c25ea 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -3,6 +3,7 @@ #include "config.h" #include "commit.h" #include "diff.h" +#include "environment.h" #include "gettext.h" #include "string-list.h" #include "revision.h" diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 8d56962972..c4aa0e62f2 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "pretty.h" diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index 3976d8e86b..f6a120c7c4 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -2,6 +2,7 @@ #include "cache.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "parse-options.h" #include "pathspec.h" diff --git a/builtin/stash.c b/builtin/stash.c index 52fa892f7e..94f81d75d0 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -2,6 +2,7 @@ #include "builtin.h" #include "abspath.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "parse-options.h" diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index ff1fd8c87a..2bf2a1a8be 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -2,6 +2,7 @@ #include "builtin.h" #include "abspath.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index f7c4b53107..c65ae3b207 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -2,6 +2,7 @@ #include "cache.h" #include "bulk-checkin.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "object-store.h" diff --git a/builtin/update-index.c b/builtin/update-index.c index ef78b2d28e..4642afaeb7 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -7,6 +7,7 @@ #include "cache.h" #include "bulk-checkin.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/builtin/worktree.c b/builtin/worktree.c index 1533b4ab43..d9345efdb2 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -4,6 +4,7 @@ #include "config.h" #include "builtin.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "parse-options.h" diff --git a/builtin/write-tree.c b/builtin/write-tree.c index 7eec4e3cbd..6085f64d10 100644 --- a/builtin/write-tree.c +++ b/builtin/write-tree.c @@ -7,6 +7,7 @@ #include "builtin.h" #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "tree.h" diff --git a/bulk-checkin.c b/bulk-checkin.c index 778ca1e0f4..eb6d7a2805 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -4,6 +4,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "bulk-checkin.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/bundle-uri.c b/bundle-uri.c index 2cc7d159bd..1ff1cf51da 100644 --- a/bundle-uri.c +++ b/bundle-uri.c @@ -1,6 +1,7 @@ #include "cache.h" #include "bundle-uri.h" #include "bundle.h" +#include "environment.h" #include "gettext.h" #include "object-store.h" #include "refs.h" diff --git a/bundle.c b/bundle.c index f5b3643b17..efeaf6f715 100644 --- a/bundle.c +++ b/bundle.c @@ -1,6 +1,7 @@ #include "cache.h" #include "lockfile.h" #include "bundle.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "object-store.h" diff --git a/cache-tree.c b/cache-tree.c index 6f899beb04..231c3eb2ff 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -1,5 +1,6 @@ #include "cache.h" #include "alloc.h" +#include "environment.h" #include "hex.h" #include "lockfile.h" #include "tree.h" diff --git a/cache.h b/cache.h index 31c722533f..720c88f9fd 100644 --- a/cache.h +++ b/cache.h @@ -452,98 +452,10 @@ static inline enum object_type object_type(unsigned int mode) OBJ_BLOB; } -/* Double-check local_repo_env below if you add to this list. */ -#define GIT_DIR_ENVIRONMENT "GIT_DIR" -#define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR" -#define GIT_NAMESPACE_ENVIRONMENT "GIT_NAMESPACE" -#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE" -#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX" -#define DEFAULT_GIT_DIR_ENVIRONMENT ".git" -#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY" -#define INDEX_ENVIRONMENT "GIT_INDEX_FILE" -#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE" -#define GIT_SHALLOW_FILE_ENVIRONMENT "GIT_SHALLOW_FILE" -#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR" -#define CONFIG_ENVIRONMENT "GIT_CONFIG" -#define CONFIG_DATA_ENVIRONMENT "GIT_CONFIG_PARAMETERS" -#define CONFIG_COUNT_ENVIRONMENT "GIT_CONFIG_COUNT" -#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH" -#define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES" -#define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS" -#define GIT_REPLACE_REF_BASE_ENVIRONMENT "GIT_REPLACE_REF_BASE" -#define GITATTRIBUTES_FILE ".gitattributes" -#define INFOATTRIBUTES_FILE "info/attributes" -#define ATTRIBUTE_MACRO_PREFIX "[attr]" -#define GITMODULES_FILE ".gitmodules" -#define GITMODULES_INDEX ":.gitmodules" -#define GITMODULES_HEAD "HEAD:.gitmodules" -#define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF" -#define GIT_NOTES_DEFAULT_REF "refs/notes/commits" -#define GIT_NOTES_DISPLAY_REF_ENVIRONMENT "GIT_NOTES_DISPLAY_REF" -#define GIT_NOTES_REWRITE_REF_ENVIRONMENT "GIT_NOTES_REWRITE_REF" -#define GIT_NOTES_REWRITE_MODE_ENVIRONMENT "GIT_NOTES_REWRITE_MODE" -#define GIT_LITERAL_PATHSPECS_ENVIRONMENT "GIT_LITERAL_PATHSPECS" -#define GIT_GLOB_PATHSPECS_ENVIRONMENT "GIT_GLOB_PATHSPECS" -#define GIT_NOGLOB_PATHSPECS_ENVIRONMENT "GIT_NOGLOB_PATHSPECS" -#define GIT_ICASE_PATHSPECS_ENVIRONMENT "GIT_ICASE_PATHSPECS" -#define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH" -#define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS" -#define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR" - -/* - * Environment variable used in handshaking the wire protocol. - * Contains a colon ':' separated list of keys with optional values - * 'key[=value]'. Presence of unknown keys and values must be - * ignored. - */ -#define GIT_PROTOCOL_ENVIRONMENT "GIT_PROTOCOL" -/* HTTP header used to handshake the wire protocol */ -#define GIT_PROTOCOL_HEADER "Git-Protocol" - -/* - * This environment variable is expected to contain a boolean indicating - * whether we should or should not treat: - * - * GIT_DIR=foo.git git ... - * - * as if GIT_WORK_TREE=. was given. It's not expected that users will make use - * of this, but we use it internally to communicate to sub-processes that we - * are in a bare repo. If not set, defaults to true. - */ -#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE" - -/* - * Repository-local GIT_* environment variables; these will be cleared - * when git spawns a sub-process that runs inside another repository. - * The array is NULL-terminated, which makes it easy to pass in the "env" - * parameter of a run-command invocation, or to do a simple walk. - */ -extern const char * const local_repo_env[]; - -void setup_git_env(const char *git_dir); - -/* - * Returns true iff we have a configured git repository (either via - * setup_git_directory, or in the environment via $GIT_DIR). - */ -int have_git_dir(void); - -extern int is_bare_repository_cfg; -int is_bare_repository(void); int is_inside_git_dir(void); -extern char *git_work_tree_cfg; int is_inside_work_tree(void); -const char *get_git_dir(void); -const char *get_git_common_dir(void); -const char *get_object_directory(void); -char *get_index_file(void); -char *get_graft_file(struct repository *r); -void set_git_dir(const char *path, int make_realpath); int get_common_dir_noenv(struct strbuf *sb, const char *gitdir); int get_common_dir(struct strbuf *sb, const char *gitdir); -const char *get_git_namespace(void); -const char *strip_namespace(const char *namespaced_ref); -const char *get_git_work_tree(void); /* * Return true if the given path is a git directory; note that this _just_ @@ -578,10 +490,6 @@ const char *read_gitfile_gently(const char *path, int *return_error_code); const char *resolve_gitdir_gently(const char *suspect, int *return_error_code); #define resolve_gitdir(path) resolve_gitdir_gently((path), NULL) -void set_git_work_tree(const char *tree); - -#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" - void setup_work_tree(void); /* * Find the commondir and gitdir of the repository that contains the current @@ -840,39 +748,7 @@ void set_alternate_index_output(const char *); extern int verify_index_checksum; extern int verify_ce_order; -/* Environment bits from configuration mechanism */ -extern int trust_executable_bit; -extern int trust_ctime; -extern int check_stat; extern int quote_path_fully; -extern int has_symlinks; -extern int minimum_abbrev, default_abbrev; -extern int ignore_case; -extern int assume_unchanged; -extern int prefer_symlink_refs; -extern int warn_ambiguous_refs; -extern int warn_on_object_refname_ambiguity; -extern char *apply_default_whitespace; -extern char *apply_default_ignorewhitespace; -extern const char *git_attributes_file; -extern const char *git_hooks_path; -extern int zlib_compression_level; -extern int pack_compression_level; -extern size_t packed_git_window_size; -extern size_t packed_git_limit; -extern size_t delta_base_cache_limit; -extern unsigned long big_file_threshold; -extern unsigned long pack_size_limit_cfg; - -/* - * Accessors for the core.sharedrepository config which lazy-load the value - * from the config (if not already set). The "reset" function can be - * used to unset "set" or cached value, meaning that the value will be loaded - * fresh from the config file on the next call to get_shared_repository(). - */ -void set_shared_repository(int value); -int get_shared_repository(void); -void reset_shared_repository(void); /* * These values are used to help identify parts of a repository to fsync. @@ -930,57 +806,6 @@ enum fsync_method { }; extern enum fsync_method fsync_method; -extern int core_preload_index; -extern int precomposed_unicode; -extern int protect_hfs; -extern int protect_ntfs; - -extern int core_apply_sparse_checkout; -extern int core_sparse_checkout_cone; -extern int sparse_expect_files_outside_of_patterns; - -/* - * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value). - */ -int use_optional_locks(void); - -enum log_refs_config { - LOG_REFS_UNSET = -1, - LOG_REFS_NONE = 0, - LOG_REFS_NORMAL, - LOG_REFS_ALWAYS -}; -extern enum log_refs_config log_all_ref_updates; - -enum rebase_setup_type { - AUTOREBASE_NEVER = 0, - AUTOREBASE_LOCAL, - AUTOREBASE_REMOTE, - AUTOREBASE_ALWAYS -}; - -enum push_default_type { - PUSH_DEFAULT_NOTHING = 0, - PUSH_DEFAULT_MATCHING, - PUSH_DEFAULT_SIMPLE, - PUSH_DEFAULT_UPSTREAM, - PUSH_DEFAULT_CURRENT, - PUSH_DEFAULT_UNSPECIFIED -}; - -extern enum rebase_setup_type autorebase; -extern enum push_default_type push_default; - -enum object_creation_mode { - OBJECT_CREATION_USES_HARDLINKS = 0, - OBJECT_CREATION_USES_RENAMES = 1 -}; - -extern enum object_creation_mode object_creation_mode; - -extern char *notes_ref_name; - -extern int grafts_replace_parents; /* * GIT_REPO_VERSION is the version we write by default. The @@ -989,8 +814,6 @@ extern int grafts_replace_parents; */ #define GIT_REPO_VERSION 0 #define GIT_REPO_VERSION_READ 1 -extern int repository_format_precious_objects; -extern int repository_format_worktree_config; /* * You _have_ to initialize a `struct repository_format` using @@ -1362,21 +1185,6 @@ struct pack_entry { struct packed_git *p; }; -/* - * Create a temporary file rooted in the object database directory, or - * die on failure. The filename is taken from "pattern", which should have the - * usual "XXXXXX" trailer, and the resulting filename is written into the - * "template" buffer. Returns the open descriptor. - */ -int odb_mkstemp(struct strbuf *temp_filename, const char *pattern); - -/* - * Create a pack .keep file named "name" (which should generally be the output - * of odb_pack_name). Returns a file descriptor opened for writing, or -1 on - * error. - */ -int odb_pack_keep(const char *name); - /* * Set this to 0 to prevent oid_object_info_extended() from fetching missing * blobs. This has a difference only if extensions.partialClone is set. @@ -1388,11 +1196,6 @@ extern int fetch_if_missing; /* Dumb servers support */ int update_server_info(int); -const char *get_log_output_encoding(void); -const char *get_commit_output_encoding(void); - -extern const char *git_commit_encoding; -extern const char *git_log_output_encoding; extern const char *git_mailmap_file; extern const char *git_mailmap_blob; @@ -1429,10 +1232,6 @@ int decimal_width(uintmax_t); int check_pager_config(const char *cmd); void prepare_pager_args(struct child_process *, const char *pager); -extern const char *editor_program; -extern const char *askpass_program; -extern const char *excludes_file; - /* base85 */ int decode_85(char *dst, const char *line, int linelen); void encode_85(char *buf, const unsigned char *data, int bytes); @@ -1536,10 +1335,4 @@ void stat_validity_update(struct stat_validity *sv, int fd); int versioncmp(const char *s1, const char *s2); -/* - * Should we print an ellipsis after an abbreviated SHA-1 value - * when doing diff-raw output or indicating a detached HEAD? - */ -int print_sha1_ellipsis(void); - #endif /* CACHE_H */ diff --git a/combine-diff.c b/combine-diff.c index 91051dc325..3758e47c4f 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -4,6 +4,7 @@ #include "blob.h" #include "diff.h" #include "diffcore.h" +#include "environment.h" #include "hex.h" #include "quote.h" #include "xdiff-interface.h" diff --git a/compat/mingw.c b/compat/mingw.c index d48899bf7b..94c5a1daa4 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -11,6 +11,7 @@ #include "../alloc.h" #include "win32/lazyload.h" #include "../config.h" +#include "../environment.h" #include "../wrapper.h" #include "dir.h" #include "gettext.h" diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c index 56d36cdf22..8a9881db07 100644 --- a/compat/precompose_utf8.c +++ b/compat/precompose_utf8.c @@ -7,6 +7,7 @@ #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "utf8.h" #include "precompose_utf8.h" diff --git a/connect.c b/connect.c index f3b159bf44..737dd906f7 100644 --- a/connect.c +++ b/connect.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "pkt-line.h" diff --git a/daemon.c b/daemon.c index e35604e194..b56a8f9717 100644 --- a/daemon.c +++ b/daemon.c @@ -2,6 +2,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "pkt-line.h" #include "run-command.h" #include "strbuf.h" diff --git a/diff.c b/diff.c index 1b0b24c21c..dcf1a94094 100644 --- a/diff.c +++ b/diff.c @@ -5,6 +5,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "tempfile.h" #include "quote.h" diff --git a/dir.c b/dir.c index b57c770e68..06f8aa3c01 100644 --- a/dir.c +++ b/dir.c @@ -10,6 +10,7 @@ #include "alloc.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "object-store.h" #include "attr.h" diff --git a/editor.c b/editor.c index 2d3e6be64e..d632d79066 100644 --- a/editor.c +++ b/editor.c @@ -1,6 +1,7 @@ #include "cache.h" #include "abspath.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "strbuf.h" #include "strvec.h" diff --git a/entry.c b/entry.c index 70212af260..750c1f6b2f 100644 --- a/entry.c +++ b/entry.c @@ -2,6 +2,7 @@ #include "blob.h" #include "object-store.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "streaming.h" diff --git a/environment.h b/environment.h index a26931556a..a63f0c6a24 100644 --- a/environment.h +++ b/environment.h @@ -3,6 +3,8 @@ #include "strvec.h" +struct repository; + /* * The character that begins a commented line in user-editable file * that is subject to stripspace. @@ -16,4 +18,215 @@ extern int auto_comment_line_char; */ const char *getenv_safe(struct strvec *argv, const char *name); +/* Double-check local_repo_env below if you add to this list. */ +#define GIT_DIR_ENVIRONMENT "GIT_DIR" +#define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR" +#define GIT_NAMESPACE_ENVIRONMENT "GIT_NAMESPACE" +#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE" +#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX" +#define DEFAULT_GIT_DIR_ENVIRONMENT ".git" +#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY" +#define INDEX_ENVIRONMENT "GIT_INDEX_FILE" +#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE" +#define GIT_SHALLOW_FILE_ENVIRONMENT "GIT_SHALLOW_FILE" +#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR" +#define CONFIG_ENVIRONMENT "GIT_CONFIG" +#define CONFIG_DATA_ENVIRONMENT "GIT_CONFIG_PARAMETERS" +#define CONFIG_COUNT_ENVIRONMENT "GIT_CONFIG_COUNT" +#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH" +#define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES" +#define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS" +#define GIT_REPLACE_REF_BASE_ENVIRONMENT "GIT_REPLACE_REF_BASE" +#define GITATTRIBUTES_FILE ".gitattributes" +#define INFOATTRIBUTES_FILE "info/attributes" +#define ATTRIBUTE_MACRO_PREFIX "[attr]" +#define GITMODULES_FILE ".gitmodules" +#define GITMODULES_INDEX ":.gitmodules" +#define GITMODULES_HEAD "HEAD:.gitmodules" +#define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF" +#define GIT_NOTES_DEFAULT_REF "refs/notes/commits" +#define GIT_NOTES_DISPLAY_REF_ENVIRONMENT "GIT_NOTES_DISPLAY_REF" +#define GIT_NOTES_REWRITE_REF_ENVIRONMENT "GIT_NOTES_REWRITE_REF" +#define GIT_NOTES_REWRITE_MODE_ENVIRONMENT "GIT_NOTES_REWRITE_MODE" +#define GIT_LITERAL_PATHSPECS_ENVIRONMENT "GIT_LITERAL_PATHSPECS" +#define GIT_GLOB_PATHSPECS_ENVIRONMENT "GIT_GLOB_PATHSPECS" +#define GIT_NOGLOB_PATHSPECS_ENVIRONMENT "GIT_NOGLOB_PATHSPECS" +#define GIT_ICASE_PATHSPECS_ENVIRONMENT "GIT_ICASE_PATHSPECS" +#define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH" +#define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS" +#define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR" + +/* + * Environment variable used in handshaking the wire protocol. + * Contains a colon ':' separated list of keys with optional values + * 'key[=value]'. Presence of unknown keys and values must be + * ignored. + */ +#define GIT_PROTOCOL_ENVIRONMENT "GIT_PROTOCOL" +/* HTTP header used to handshake the wire protocol */ +#define GIT_PROTOCOL_HEADER "Git-Protocol" + +/* + * This environment variable is expected to contain a boolean indicating + * whether we should or should not treat: + * + * GIT_DIR=foo.git git ... + * + * as if GIT_WORK_TREE=. was given. It's not expected that users will make use + * of this, but we use it internally to communicate to sub-processes that we + * are in a bare repo. If not set, defaults to true. + */ +#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE" + +/* + * Repository-local GIT_* environment variables; these will be cleared + * when git spawns a sub-process that runs inside another repository. + * The array is NULL-terminated, which makes it easy to pass in the "env" + * parameter of a run-command invocation, or to do a simple walk. + */ +extern const char * const local_repo_env[]; + +void setup_git_env(const char *git_dir); + +/* + * Returns true iff we have a configured git repository (either via + * setup_git_directory, or in the environment via $GIT_DIR). + */ +int have_git_dir(void); + +extern int is_bare_repository_cfg; +int is_bare_repository(void); +extern char *git_work_tree_cfg; +const char *get_git_dir(void); +const char *get_git_common_dir(void); +const char *get_object_directory(void); +char *get_index_file(void); +char *get_graft_file(struct repository *r); +void set_git_dir(const char *path, int make_realpath); +const char *get_git_namespace(void); +const char *strip_namespace(const char *namespaced_ref); +const char *get_git_work_tree(void); +void set_git_work_tree(const char *tree); + +#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" + +/* Environment bits from configuration mechanism */ +extern int trust_executable_bit; +extern int trust_ctime; +extern int check_stat; +extern int has_symlinks; +extern int minimum_abbrev, default_abbrev; +extern int ignore_case; +extern int assume_unchanged; +extern int prefer_symlink_refs; +extern int warn_ambiguous_refs; +extern int warn_on_object_refname_ambiguity; +extern char *apply_default_whitespace; +extern char *apply_default_ignorewhitespace; +extern const char *git_attributes_file; +extern const char *git_hooks_path; +extern int zlib_compression_level; +extern int pack_compression_level; +extern size_t packed_git_window_size; +extern size_t packed_git_limit; +extern size_t delta_base_cache_limit; +extern unsigned long big_file_threshold; +extern unsigned long pack_size_limit_cfg; + +/* + * Accessors for the core.sharedrepository config which lazy-load the value + * from the config (if not already set). The "reset" function can be + * used to unset "set" or cached value, meaning that the value will be loaded + * fresh from the config file on the next call to get_shared_repository(). + */ +void set_shared_repository(int value); +int get_shared_repository(void); +void reset_shared_repository(void); + +extern int core_preload_index; +extern int precomposed_unicode; +extern int protect_hfs; +extern int protect_ntfs; + +extern int core_apply_sparse_checkout; +extern int core_sparse_checkout_cone; +extern int sparse_expect_files_outside_of_patterns; + +/* + * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value). + */ +int use_optional_locks(void); + +enum log_refs_config { + LOG_REFS_UNSET = -1, + LOG_REFS_NONE = 0, + LOG_REFS_NORMAL, + LOG_REFS_ALWAYS +}; +extern enum log_refs_config log_all_ref_updates; + +enum rebase_setup_type { + AUTOREBASE_NEVER = 0, + AUTOREBASE_LOCAL, + AUTOREBASE_REMOTE, + AUTOREBASE_ALWAYS +}; + +enum push_default_type { + PUSH_DEFAULT_NOTHING = 0, + PUSH_DEFAULT_MATCHING, + PUSH_DEFAULT_SIMPLE, + PUSH_DEFAULT_UPSTREAM, + PUSH_DEFAULT_CURRENT, + PUSH_DEFAULT_UNSPECIFIED +}; + +extern enum rebase_setup_type autorebase; +extern enum push_default_type push_default; + +enum object_creation_mode { + OBJECT_CREATION_USES_HARDLINKS = 0, + OBJECT_CREATION_USES_RENAMES = 1 +}; + +extern enum object_creation_mode object_creation_mode; + +extern char *notes_ref_name; + +extern int grafts_replace_parents; + +extern int repository_format_precious_objects; +extern int repository_format_worktree_config; + +/* + * Create a temporary file rooted in the object database directory, or + * die on failure. The filename is taken from "pattern", which should have the + * usual "XXXXXX" trailer, and the resulting filename is written into the + * "template" buffer. Returns the open descriptor. + */ +int odb_mkstemp(struct strbuf *temp_filename, const char *pattern); + +/* + * Create a pack .keep file named "name" (which should generally be the output + * of odb_pack_name). Returns a file descriptor opened for writing, or -1 on + * error. + */ +int odb_pack_keep(const char *name); + +const char *get_log_output_encoding(void); +const char *get_commit_output_encoding(void); + +extern const char *git_commit_encoding; +extern const char *git_log_output_encoding; + +extern const char *editor_program; +extern const char *askpass_program; +extern const char *excludes_file; + +/* + * Should we print an ellipsis after an abbreviated SHA-1 value + * when doing diff-raw output or indicating a detached HEAD? + */ +int print_sha1_ellipsis(void); + #endif diff --git a/exec-cmd.c b/exec-cmd.c index 042d9247a5..fae0d4b244 100644 --- a/exec-cmd.c +++ b/exec-cmd.c @@ -1,5 +1,6 @@ #include "cache.h" #include "abspath.h" +#include "environment.h" #include "exec-cmd.h" #include "gettext.h" #include "quote.h" diff --git a/fetch-pack.c b/fetch-pack.c index c119080140..c453a4168f 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "repository.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/fsmonitor.c b/fsmonitor.c index a5b9e75437..c956a347a2 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -1,6 +1,7 @@ #include "cache.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "ewah/ewok.h" #include "fsmonitor.h" #include "fsmonitor-ipc.h" diff --git a/gettext.c b/gettext.c index 3e7b3baabc..85d3d3424e 100644 --- a/gettext.c +++ b/gettext.c @@ -4,6 +4,7 @@ #include "cache.h" #include "abspath.h" +#include "environment.h" #include "exec-cmd.h" #include "gettext.h" #include "strbuf.h" diff --git a/git.c b/git.c index 22ce4f14b6..b24c105e83 100644 --- a/git.c +++ b/git.c @@ -1,5 +1,6 @@ #include "builtin.h" #include "config.h" +#include "environment.h" #include "exec-cmd.h" #include "gettext.h" #include "help.h" diff --git a/http-backend.c b/http-backend.c index 42e6c2596e..042ccf12e8 100644 --- a/http-backend.c +++ b/http-backend.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "hex.h" #include "repository.h" #include "refs.h" diff --git a/http-push.c b/http-push.c index 88aa045ecb..40373bc486 100644 --- a/http-push.c +++ b/http-push.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "hex.h" #include "repository.h" #include "commit.h" diff --git a/log-tree.c b/log-tree.c index 3adcb576e4..e2bf8d6df7 100644 --- a/log-tree.c +++ b/log-tree.c @@ -2,6 +2,7 @@ #include "commit-reach.h" #include "config.h" #include "diff.h" +#include "environment.h" #include "hex.h" #include "object-store.h" #include "repository.h" diff --git a/ls-refs.c b/ls-refs.c index ae38889bf0..12cbb40a19 100644 --- a/ls-refs.c +++ b/ls-refs.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/mailmap.c b/mailmap.c index da2589b082..2c6e9b238d 100644 --- a/mailmap.c +++ b/mailmap.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "string-list.h" #include "mailmap.h" #include "object-store.h" diff --git a/merge-ort.c b/merge-ort.c index a26cad5f91..f3d7c202f5 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -26,6 +26,7 @@ #include "diff.h" #include "diffcore.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "entry.h" diff --git a/merge-recursive.c b/merge-recursive.c index f918cea4c6..d5f3772491 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -17,6 +17,7 @@ #include "diff.h" #include "diffcore.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "ll-merge.h" diff --git a/name-hash.c b/name-hash.c index bb9eae55ac..2c2861efd1 100644 --- a/name-hash.c +++ b/name-hash.c @@ -6,6 +6,7 @@ * Copyright (C) 2008 Linus Torvalds */ #include "cache.h" +#include "environment.h" #include "gettext.h" #include "thread-utils.h" #include "trace2.h" diff --git a/notes-utils.c b/notes-utils.c index da08e2e8e5..8797271faf 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -1,6 +1,7 @@ #include "cache.h" #include "config.h" #include "commit.h" +#include "environment.h" #include "gettext.h" #include "refs.h" #include "notes-utils.h" diff --git a/notes.c b/notes.c index a7187236e9..9288c1a070 100644 --- a/notes.c +++ b/notes.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "environment.h" #include "hex.h" #include "notes.h" #include "object-store.h" diff --git a/object-file.c b/object-file.c index bdf68763a5..3da6cd6886 100644 --- a/object-file.c +++ b/object-file.c @@ -10,6 +10,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "string-list.h" diff --git a/object-name.c b/object-name.c index 2c927bbded..3b0ce8ef05 100644 --- a/object-name.c +++ b/object-name.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "tag.h" diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c index 7dc7f0ba55..63f16080c9 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "object-store.h" diff --git a/pack-check.c b/pack-check.c index 7ed594d667..6974e40a95 100644 --- a/pack-check.c +++ b/pack-check.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "hex.h" #include "repository.h" #include "pack.h" diff --git a/pack-write.c b/pack-write.c index 87156f89d2..f171405495 100644 --- a/pack-write.c +++ b/pack-write.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "pack.h" diff --git a/packfile.c b/packfile.c index 8c117ccee2..4b5b841d04 100644 --- a/packfile.c +++ b/packfile.c @@ -1,5 +1,6 @@ #include "git-compat-util.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "list.h" diff --git a/parse-options-cb.c b/parse-options-cb.c index fbf4b01019..15d008c3da 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -4,6 +4,7 @@ #include "cache.h" #include "commit.h" #include "color.h" +#include "environment.h" #include "gettext.h" #include "string-list.h" #include "strvec.h" diff --git a/path.c b/path.c index 3976c0d7ac..5d5a15c13d 100644 --- a/path.c +++ b/path.c @@ -3,6 +3,7 @@ */ #include "cache.h" #include "abspath.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/pathspec.c b/pathspec.c index 53763e272f..5fb7b5f26c 100644 --- a/pathspec.c +++ b/pathspec.c @@ -2,6 +2,7 @@ #include "abspath.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "pathspec.h" #include "attr.h" diff --git a/preload-index.c b/preload-index.c index 4b45e1d691..52544d004e 100644 --- a/preload-index.c +++ b/preload-index.c @@ -4,6 +4,7 @@ #include "cache.h" #include "pathspec.h" #include "dir.h" +#include "environment.h" #include "fsmonitor.h" #include "gettext.h" #include "config.h" diff --git a/pretty.c b/pretty.c index 9d7922dcc6..2b6d0f52c9 100644 --- a/pretty.c +++ b/pretty.c @@ -2,6 +2,7 @@ #include "alloc.h" #include "config.h" #include "commit.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "utf8.h" diff --git a/prompt.c b/prompt.c index 50df17279d..ba10813b31 100644 --- a/prompt.c +++ b/prompt.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "environment.h" #include "run-command.h" #include "strbuf.h" #include "prompt.h" diff --git a/protocol.c b/protocol.c index c53f7df5be..bdb32e1eeb 100644 --- a/protocol.c +++ b/protocol.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "environment.h" #include "protocol.h" static enum protocol_version parse_protocol_version(const char *value) diff --git a/prune-packed.c b/prune-packed.c index cff5ad569c..5a57072a7a 100644 --- a/prune-packed.c +++ b/prune-packed.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "gettext.h" #include "object-store.h" #include "packfile.h" diff --git a/range-diff.c b/range-diff.c index 1bfc612e27..815fb24c9c 100644 --- a/range-diff.c +++ b/range-diff.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "gettext.h" #include "range-diff.h" #include "string-list.h" diff --git a/read-cache.c b/read-cache.c index 9a8d5fe97e..34567c1d55 100644 --- a/read-cache.c +++ b/read-cache.c @@ -18,6 +18,7 @@ #include "tree.h" #include "commit.h" #include "blob.h" +#include "environment.h" #include "gettext.h" #include "resolve-undo.h" #include "run-command.h" diff --git a/rebase-interactive.c b/rebase-interactive.c index 7c885c35bf..a83334dd56 100644 --- a/rebase-interactive.c +++ b/rebase-interactive.c @@ -1,5 +1,6 @@ #include "cache.h" #include "commit.h" +#include "environment.h" #include "gettext.h" #include "sequencer.h" #include "rebase-interactive.h" diff --git a/ref-filter.c b/ref-filter.c index 9a830bedef..1489fbfe4a 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1,5 +1,6 @@ #include "cache.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "parse-options.h" diff --git a/refs.c b/refs.c index 385051752f..04520e5a6b 100644 --- a/refs.c +++ b/refs.c @@ -5,6 +5,7 @@ #include "cache.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "hashmap.h" #include "gettext.h" #include "hex.h" diff --git a/refs/files-backend.c b/refs/files-backend.c index eb14d124e3..0c3138ede8 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -1,5 +1,6 @@ #include "../cache.h" #include "../config.h" +#include "../environment.h" #include "../gettext.h" #include "../hex.h" #include "../refs.h" diff --git a/remote-curl.c b/remote-curl.c index 943cd6fe6c..eb382a1e35 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "remote.h" diff --git a/remote.c b/remote.c index 2bae247a0a..aeca3ff813 100644 --- a/remote.c +++ b/remote.c @@ -2,6 +2,7 @@ #include "abspath.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "remote.h" diff --git a/revision.c b/revision.c index 7423e23327..53fdeef078 100644 --- a/revision.c +++ b/revision.c @@ -1,6 +1,7 @@ #include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "object-store.h" diff --git a/run-command.c b/run-command.c index 2c8b4cd9bf..614d48fa9a 100644 --- a/run-command.c +++ b/run-command.c @@ -1,5 +1,6 @@ #include "cache.h" #include "run-command.h" +#include "environment.h" #include "exec-cmd.h" #include "gettext.h" #include "sigchain.h" diff --git a/server-info.c b/server-info.c index ae96d784e5..355b6e01a5 100644 --- a/server-info.c +++ b/server-info.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "dir.h" +#include "environment.h" #include "hex.h" #include "repository.h" #include "refs.h" diff --git a/setup.c b/setup.c index 8f385d9f29..cfdc849a78 100644 --- a/setup.c +++ b/setup.c @@ -1,5 +1,6 @@ #include "cache.h" #include "abspath.h" +#include "environment.h" #include "gettext.h" #include "repository.h" #include "config.h" diff --git a/sparse-index.c b/sparse-index.c index fdae9011b8..886054729e 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -1,5 +1,6 @@ #include "cache.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "repository.h" #include "sparse-index.h" diff --git a/streaming.c b/streaming.c index 6c69f59504..024fd796b7 100644 --- a/streaming.c +++ b/streaming.c @@ -2,6 +2,7 @@ * Copyright (c) 2011, Google Inc. */ #include "cache.h" +#include "environment.h" #include "streaming.h" #include "repository.h" #include "object-store.h" diff --git a/submodule-config.c b/submodule-config.c index 38663801aa..28fdfddccf 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "repository.h" diff --git a/submodule.c b/submodule.c index 13ff333f68..acf030b95e 100644 --- a/submodule.c +++ b/submodule.c @@ -8,6 +8,7 @@ #include "dir.h" #include "diff.h" #include "commit.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "revision.h" diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c index 68bbc41b33..627a6bdc3d 100644 --- a/t/helper/test-fast-rebase.c +++ b/t/helper/test-fast-rebase.c @@ -15,6 +15,7 @@ #include "cache.h" #include "cache-tree.h" #include "commit.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "lockfile.h" diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c index ab86c14c8b..2b678a4579 100644 --- a/t/helper/test-lazy-init-name-hash.c +++ b/t/helper/test-lazy-init-name-hash.c @@ -1,6 +1,7 @@ #define USE_THE_INDEX_VARIABLE #include "test-tool.h" #include "cache.h" +#include "environment.h" #include "parse-options.h" static int single; diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index d3d00dc34f..cc266e3ec0 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -1,6 +1,7 @@ #include "test-tool.h" #include "cache.h" #include "abspath.h" +#include "environment.h" #include "string-list.h" #include "utf8.h" diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c index 10a6dfc216..c444775eb0 100644 --- a/t/helper/test-repository.c +++ b/t/helper/test-repository.c @@ -3,6 +3,7 @@ #include "commit-graph.h" #include "commit.h" #include "config.h" +#include "environment.h" #include "hex.h" #include "object-store.h" #include "object.h" diff --git a/tag.c b/tag.c index 3408bb9433..3943423179 100644 --- a/tag.c +++ b/tag.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "environment.h" #include "tag.h" #include "object-store.h" #include "commit.h" diff --git a/tmp-objdir.c b/tmp-objdir.c index fff15cb6b5..5adad1925d 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -3,6 +3,7 @@ #include "abspath.h" #include "chdir-notify.h" #include "dir.h" +#include "environment.h" #include "sigchain.h" #include "string-list.h" #include "strbuf.h" diff --git a/trace.c b/trace.c index de004f6298..9c85b71ec6 100644 --- a/trace.c +++ b/trace.c @@ -23,6 +23,7 @@ #include "cache.h" #include "abspath.h" +#include "environment.h" #include "quote.h" #include "wrapper.h" diff --git a/transport-helper.c b/transport-helper.c index 09048eab48..3313bb7409 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -4,6 +4,7 @@ #include "run-command.h" #include "commit.h" #include "diff.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "revision.h" diff --git a/transport.c b/transport.c index c6179b801e..4f06ccbee0 100644 --- a/transport.c +++ b/transport.c @@ -1,6 +1,7 @@ #include "cache.h" #include "alloc.h" #include "config.h" +#include "environment.h" #include "hex.h" #include "transport.h" #include "hook.h" diff --git a/unpack-trees.c b/unpack-trees.c index 84e0d2e8af..0ff4bbc6b9 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -3,6 +3,7 @@ #include "repository.h" #include "config.h" #include "dir.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "tree.h" diff --git a/upload-pack.c b/upload-pack.c index eea9e6a6e8..1155f79538 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -1,5 +1,6 @@ #include "cache.h" #include "config.h" +#include "environment.h" #include "gettext.h" #include "hex.h" #include "refs.h" diff --git a/worktree.c b/worktree.c index fe4345012c..c2671b0cdf 100644 --- a/worktree.c +++ b/worktree.c @@ -1,6 +1,7 @@ #include "cache.h" #include "abspath.h" #include "alloc.h" +#include "environment.h" #include "gettext.h" #include "repository.h" #include "refs.h" -- cgit v1.2.3 From e38da487cc50ce4b5b48085eebcab8268c541579 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 21 Mar 2023 06:26:05 +0000 Subject: setup.h: move declarations for setup.c functions from cache.h Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- apply.c | 1 + archive.c | 1 + attr.c | 1 + blame.c | 1 + builtin/blame.c | 1 + builtin/bugreport.c | 1 + builtin/bundle.c | 1 + builtin/check-attr.c | 1 + builtin/check-ref-format.c | 1 + builtin/checkout-index.c | 1 + builtin/checkout.c | 1 + builtin/clean.c | 1 + builtin/clone.c | 1 + builtin/config.c | 1 + builtin/describe.c | 1 + builtin/diff-index.c | 1 + builtin/diff.c | 1 + builtin/difftool.c | 1 + builtin/gc.c | 1 + builtin/grep.c | 1 + builtin/hash-object.c | 1 + builtin/help.c | 1 + builtin/index-pack.c | 1 + builtin/init-db.c | 1 + builtin/ls-files.c | 1 + builtin/merge-file.c | 1 + builtin/mv.c | 1 + builtin/read-tree.c | 1 + builtin/reset.c | 1 + builtin/rev-parse.c | 1 + builtin/rm.c | 1 + builtin/shortlog.c | 1 + builtin/sparse-checkout.c | 1 + builtin/stash.c | 1 + builtin/stripspace.c | 1 + builtin/submodule--helper.c | 1 + builtin/update-index.c | 1 + cache.h | 163 -------------------------- commit.c | 1 + common-main.c | 1 + config.c | 1 + daemon.c | 1 + diff.c | 1 + dir.c | 1 + environment.c | 1 + git.c | 1 + http-fetch.c | 1 + http-push.c | 1 + imap-send.c | 1 + line-log.c | 1 + mailmap.c | 1 + object-file.c | 1 + object-name.c | 1 + path.c | 1 + pathspec.c | 1 + refs.c | 1 + refs/files-backend.c | 1 + remote-curl.c | 1 + remote.c | 1 + repository.c | 1 + revision.c | 1 + scalar.c | 1 + setup.c | 1 + setup.h | 168 +++++++++++++++++++++++++++ submodule.c | 1 + symlinks.c | 1 + t/helper/test-advise.c | 1 + t/helper/test-bitmap.c | 1 + t/helper/test-bloom.c | 1 + t/helper/test-cache-tree.c | 1 + t/helper/test-config.c | 1 + t/helper/test-dump-cache-tree.c | 2 +- t/helper/test-dump-fsmonitor.c | 1 + t/helper/test-dump-split-index.c | 1 + t/helper/test-dump-untracked-cache.c | 1 + t/helper/test-fast-rebase.c | 1 + t/helper/test-fsmonitor-client.c | 1 + t/helper/test-lazy-init-name-hash.c | 1 + t/helper/test-match-trees.c | 1 + t/helper/test-oid-array.c | 1 + t/helper/test-oidmap.c | 1 + t/helper/test-oidtree.c | 1 + t/helper/test-pack-mtimes.c | 1 + t/helper/test-partial-clone.c | 1 + t/helper/test-path-utils.c | 1 + t/helper/test-proc-receive.c | 1 + t/helper/test-reach.c | 1 + t/helper/test-read-cache.c | 1 + t/helper/test-read-graph.c | 1 + t/helper/test-read-midx.c | 1 + t/helper/test-ref-store.c | 1 + t/helper/test-repository.c | 1 + t/helper/test-revision-walking.c | 1 + t/helper/test-scrap-cache-tree.c | 1 + t/helper/test-serve-v2.c | 1 + t/helper/test-submodule-config.c | 1 + t/helper/test-submodule-nested-repo-config.c | 1 + t/helper/test-submodule.c | 1 + t/helper/test-subprocess.c | 1 + t/helper/test-userdiff.c | 1 + t/helper/test-write-cache.c | 1 + trace.c | 1 + unpack-trees.c | 1 + worktree.c | 1 + wt-status.c | 1 + 105 files changed, 271 insertions(+), 164 deletions(-) create mode 100644 setup.h (limited to 'diff.c') diff --git a/apply.c b/apply.c index a7c0bccb15..caa2e0a3bc 100644 --- a/apply.c +++ b/apply.c @@ -27,6 +27,7 @@ #include "rerere.h" #include "apply.h" #include "entry.h" +#include "setup.h" #include "wrapper.h" struct gitdiff_data { diff --git a/archive.c b/archive.c index 7aeaaf368f..cdce5b783a 100644 --- a/archive.c +++ b/archive.c @@ -5,6 +5,7 @@ #include "environment.h" #include "gettext.h" #include "hex.h" +#include "setup.h" #include "refs.h" #include "object-store.h" #include "commit.h" diff --git a/attr.c b/attr.c index 62127196cb..2d8aeb8b58 100644 --- a/attr.c +++ b/attr.c @@ -18,6 +18,7 @@ #include "quote.h" #include "revision.h" #include "object-store.h" +#include "setup.h" #include "thread-utils.h" const char git_attr__true[] = "(builtin)true"; diff --git a/blame.c b/blame.c index b7cd849bb6..838eb128f0 100644 --- a/blame.c +++ b/blame.c @@ -7,6 +7,7 @@ #include "diffcore.h" #include "gettext.h" #include "hex.h" +#include "setup.h" #include "tag.h" #include "blame.h" #include "alloc.h" diff --git a/builtin/blame.c b/builtin/blame.c index 9ec82edcbd..fb271bae70 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -31,6 +31,7 @@ #include "object-store.h" #include "blame.h" #include "refs.h" +#include "setup.h" #include "tag.h" static char blame_usage[] = N_("git blame [] [] [] [--] "); diff --git a/builtin/bugreport.c b/builtin/bugreport.c index 160590e4ef..52955e1d38 100644 --- a/builtin/bugreport.c +++ b/builtin/bugreport.c @@ -8,6 +8,7 @@ #include "hook.h" #include "hook-list.h" #include "diagnose.h" +#include "setup.h" #include "wrapper.h" static void get_system_info(struct strbuf *sys_info) diff --git a/builtin/bundle.c b/builtin/bundle.c index 9e2aecadf7..e68fc83d94 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -1,6 +1,7 @@ #include "builtin.h" #include "abspath.h" #include "gettext.h" +#include "setup.h" #include "strvec.h" #include "parse-options.h" #include "cache.h" diff --git a/builtin/check-attr.c b/builtin/check-attr.c index 5870c4683a..ec37b8164a 100644 --- a/builtin/check-attr.c +++ b/builtin/check-attr.c @@ -6,6 +6,7 @@ #include "environment.h" #include "gettext.h" #include "quote.h" +#include "setup.h" #include "parse-options.h" static int all_attrs; diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c index fd0e5f8683..b026346742 100644 --- a/builtin/check-ref-format.c +++ b/builtin/check-ref-format.c @@ -5,6 +5,7 @@ #include "cache.h" #include "refs.h" #include "builtin.h" +#include "setup.h" #include "strbuf.h" static const char builtin_check_ref_format_usage[] = diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 828c0363f8..7df673e3e7 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -15,6 +15,7 @@ #include "parse-options.h" #include "entry.h" #include "parallel-checkout.h" +#include "setup.h" #define CHECKOUT_ALL 4 static int nul_term_line; diff --git a/builtin/checkout.c b/builtin/checkout.c index 5541e76c33..73b6e581f3 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -23,6 +23,7 @@ #include "resolve-undo.h" #include "revision.h" #include "run-command.h" +#include "setup.h" #include "submodule.h" #include "submodule-config.h" #include "tree.h" diff --git a/builtin/clean.c b/builtin/clean.c index fdcf62c5df..14c0d555ea 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -14,6 +14,7 @@ #include "dir.h" #include "gettext.h" #include "parse-options.h" +#include "setup.h" #include "string-list.h" #include "quote.h" #include "column.h" diff --git a/builtin/clone.c b/builtin/clone.c index 15dc15408e..34f46965b9 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -33,6 +33,7 @@ #include "branch.h" #include "remote.h" #include "run-command.h" +#include "setup.h" #include "connected.h" #include "packfile.h" #include "list-objects-filter-options.h" diff --git a/builtin/config.c b/builtin/config.c index cf994a216c..fe79fb60c4 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -9,6 +9,7 @@ #include "parse-options.h" #include "urlmatch.h" #include "quote.h" +#include "setup.h" #include "worktree.h" #include "wrapper.h" diff --git a/builtin/describe.c b/builtin/describe.c index 27c6670e93..43b62348bc 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -15,6 +15,7 @@ #include "revision.h" #include "diff.h" #include "hashmap.h" +#include "setup.h" #include "strvec.h" #include "run-command.h" #include "object-store.h" diff --git a/builtin/diff-index.c b/builtin/diff-index.c index 35dc9b23ee..b9a19bb7d3 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -5,6 +5,7 @@ #include "commit.h" #include "revision.h" #include "builtin.h" +#include "setup.h" #include "submodule.h" static const char diff_cache_usage[] = diff --git a/builtin/diff.c b/builtin/diff.c index 20bdb6e6ce..3945683bfe 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -19,6 +19,7 @@ #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 3613de6389..176437d6da 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -28,6 +28,7 @@ #include "object-store.h" #include "dir.h" #include "entry.h" +#include "setup.h" #include "wrapper.h" static int trust_exit_code; diff --git a/builtin/gc.c b/builtin/gc.c index 525c5de5b2..a85f9e3ed3 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -36,6 +36,7 @@ #include "exec-cmd.h" #include "gettext.h" #include "hook.h" +#include "setup.h" #include "wrapper.h" #define FAILED_RUN "failed to run %s" diff --git a/builtin/grep.c b/builtin/grep.c index 3c9c6b3803..b8ebf014f4 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -23,6 +23,7 @@ #include "quote.h" #include "dir.h" #include "pathspec.h" +#include "setup.h" #include "submodule.h" #include "submodule-config.h" #include "object-store.h" diff --git a/builtin/hash-object.c b/builtin/hash-object.c index 7651a7a5f5..a2e160db02 100644 --- a/builtin/hash-object.c +++ b/builtin/hash-object.c @@ -14,6 +14,7 @@ #include "quote.h" #include "parse-options.h" #include "exec-cmd.h" +#include "setup.h" /* * This is to create corrupt objects for debugging and as such it diff --git a/builtin/help.c b/builtin/help.c index 3fde5c4fd3..87333a02ec 100644 --- a/builtin/help.c +++ b/builtin/help.c @@ -11,6 +11,7 @@ #include "config-list.h" #include "help.h" #include "alias.h" +#include "setup.h" #ifndef DEFAULT_HELP_FORMAT #define DEFAULT_HELP_FORMAT "man" diff --git a/builtin/index-pack.c b/builtin/index-pack.c index fdce8f8872..823dc5aefb 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -20,6 +20,7 @@ #include "object-store.h" #include "replace-object.h" #include "promisor-remote.h" +#include "setup.h" #include "wrapper.h" static const char index_pack_usage[] = diff --git a/builtin/init-db.c b/builtin/init-db.c index 2ebc9023f5..ba6e0b20fa 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -12,6 +12,7 @@ #include "builtin.h" #include "exec-cmd.h" #include "parse-options.h" +#include "setup.h" #include "worktree.h" #include "wrapper.h" diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 09deb752ab..4a8de95ddc 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -20,6 +20,7 @@ #include "string-list.h" #include "pathspec.h" #include "run-command.h" +#include "setup.h" #include "submodule.h" #include "submodule-config.h" diff --git a/builtin/merge-file.c b/builtin/merge-file.c index c0096ee081..781818d08f 100644 --- a/builtin/merge-file.c +++ b/builtin/merge-file.c @@ -3,6 +3,7 @@ #include "cache.h" #include "config.h" #include "gettext.h" +#include "setup.h" #include "xdiff/xdiff.h" #include "xdiff-interface.h" #include "parse-options.h" diff --git a/builtin/mv.c b/builtin/mv.c index c2dd42efbf..b7c5ffbd8c 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -16,6 +16,7 @@ #include "cache-tree.h" #include "string-list.h" #include "parse-options.h" +#include "setup.h" #include "submodule.h" #include "entry.h" diff --git a/builtin/read-tree.c b/builtin/read-tree.c index ec66008d07..5f24453dcd 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -19,6 +19,7 @@ #include "builtin.h" #include "parse-options.h" #include "resolve-undo.h" +#include "setup.h" #include "submodule.h" #include "submodule-config.h" diff --git a/builtin/reset.c b/builtin/reset.c index b5dfce1159..af2afc2c98 100644 --- a/builtin/reset.c +++ b/builtin/reset.c @@ -26,6 +26,7 @@ #include "parse-options.h" #include "unpack-trees.h" #include "cache-tree.h" +#include "setup.h" #include "submodule.h" #include "submodule-config.h" #include "dir.h" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index bba49d56b9..3a5a2ee5b2 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -18,6 +18,7 @@ #include "parse-options.h" #include "diff.h" #include "revision.h" +#include "setup.h" #include "split-index.h" #include "submodule.h" #include "commit-reach.h" diff --git a/builtin/rm.c b/builtin/rm.c index 5982c3d812..97775e4c4d 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -15,6 +15,7 @@ #include "tree-walk.h" #include "parse-options.h" #include "string-list.h" +#include "setup.h" #include "submodule.h" #include "pathspec.h" diff --git a/builtin/shortlog.c b/builtin/shortlog.c index 31f81c25ea..59d9c440fb 100644 --- a/builtin/shortlog.c +++ b/builtin/shortlog.c @@ -9,6 +9,7 @@ #include "revision.h" #include "utf8.h" #include "mailmap.h" +#include "setup.h" #include "shortlog.h" #include "parse-options.h" #include "trailer.h" diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c index f6a120c7c4..512df0f8f5 100644 --- a/builtin/sparse-checkout.c +++ b/builtin/sparse-checkout.c @@ -16,6 +16,7 @@ #include "unpack-trees.h" #include "wt-status.h" #include "quote.h" +#include "setup.h" #include "sparse-index.h" #include "worktree.h" diff --git a/builtin/stash.c b/builtin/stash.c index 94f81d75d0..30d547fff1 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -18,6 +18,7 @@ #include "entry.h" #include "rerere.h" #include "revision.h" +#include "setup.h" #include "log-tree.h" #include "diffcore.h" #include "exec-cmd.h" diff --git a/builtin/stripspace.c b/builtin/stripspace.c index d8e6145933..53930458ff 100644 --- a/builtin/stripspace.c +++ b/builtin/stripspace.c @@ -3,6 +3,7 @@ #include "config.h" #include "gettext.h" #include "parse-options.h" +#include "setup.h" #include "strbuf.h" static void comment_lines(struct strbuf *buf) diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 2bf2a1a8be..3cb4a3ce21 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -12,6 +12,7 @@ #include "quote.h" #include "pathspec.h" #include "dir.h" +#include "setup.h" #include "submodule.h" #include "submodule-config.h" #include "string-list.h" diff --git a/builtin/update-index.c b/builtin/update-index.c index 4642afaeb7..f97f8d4c9d 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -20,6 +20,7 @@ #include "parse-options.h" #include "pathspec.h" #include "dir.h" +#include "setup.h" #include "split-index.h" #include "fsmonitor.h" diff --git a/cache.h b/cache.h index 720c88f9fd..bffedd240e 100644 --- a/cache.h +++ b/cache.h @@ -452,67 +452,6 @@ static inline enum object_type object_type(unsigned int mode) OBJ_BLOB; } -int is_inside_git_dir(void); -int is_inside_work_tree(void); -int get_common_dir_noenv(struct strbuf *sb, const char *gitdir); -int get_common_dir(struct strbuf *sb, const char *gitdir); - -/* - * Return true if the given path is a git directory; note that this _just_ - * looks at the directory itself. If you want to know whether "foo/.git" - * is a repository, you must feed that path, not just "foo". - */ -int is_git_directory(const char *path); - -/* - * Return 1 if the given path is the root of a git repository or - * submodule, else 0. Will not return 1 for bare repositories with the - * exception of creating a bare repository in "foo/.git" and calling - * is_git_repository("foo"). - * - * If we run into read errors, we err on the side of saying "yes, it is", - * as we usually consider sub-repos precious, and would prefer to err on the - * side of not disrupting or deleting them. - */ -int is_nonbare_repository_dir(struct strbuf *path); - -#define READ_GITFILE_ERR_STAT_FAILED 1 -#define READ_GITFILE_ERR_NOT_A_FILE 2 -#define READ_GITFILE_ERR_OPEN_FAILED 3 -#define READ_GITFILE_ERR_READ_FAILED 4 -#define READ_GITFILE_ERR_INVALID_FORMAT 5 -#define READ_GITFILE_ERR_NO_PATH 6 -#define READ_GITFILE_ERR_NOT_A_REPO 7 -#define READ_GITFILE_ERR_TOO_LARGE 8 -void read_gitfile_error_die(int error_code, const char *path, const char *dir); -const char *read_gitfile_gently(const char *path, int *return_error_code); -#define read_gitfile(path) read_gitfile_gently((path), NULL) -const char *resolve_gitdir_gently(const char *suspect, int *return_error_code); -#define resolve_gitdir(path) resolve_gitdir_gently((path), NULL) - -void setup_work_tree(void); -/* - * Find the commondir and gitdir of the repository that contains the current - * working directory, without changing the working directory or other global - * state. The result is appended to commondir and gitdir. If the discovered - * gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will - * both have the same result appended to the buffer. The return value is - * either 0 upon success and non-zero if no repository was found. - */ -int discover_git_directory(struct strbuf *commondir, - struct strbuf *gitdir); -const char *setup_git_directory_gently(int *); -const char *setup_git_directory(void); -char *prefix_path(const char *prefix, int len, const char *path); -char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path); - -int check_filename(const char *prefix, const char *name); -void verify_filename(const char *prefix, - const char *name, - int diagnose_misspelt_rev); -void verify_non_filename(const char *prefix, const char *name); -int path_inside_repo(const char *prefix, const char *path); - #define INIT_DB_QUIET 0x0001 #define INIT_DB_EXIST_OK 0x0002 @@ -521,9 +460,6 @@ int init_db(const char *git_dir, const char *real_git_dir, const char *initial_branch, unsigned int flags); void initialize_repository_version(int hash_algo, int reinit); -void sanitize_stdfds(void); -int daemonize(void); - /* Initialize and use the cache information */ struct lock_file; void preload_index(struct index_state *index, @@ -807,79 +743,6 @@ enum fsync_method { extern enum fsync_method fsync_method; -/* - * GIT_REPO_VERSION is the version we write by default. The - * _READ variant is the highest number we know how to - * handle. - */ -#define GIT_REPO_VERSION 0 -#define GIT_REPO_VERSION_READ 1 - -/* - * You _have_ to initialize a `struct repository_format` using - * `= REPOSITORY_FORMAT_INIT` before calling `read_repository_format()`. - */ -struct repository_format { - int version; - int precious_objects; - char *partial_clone; /* value of extensions.partialclone */ - int worktree_config; - int is_bare; - int hash_algo; - int sparse_index; - char *work_tree; - struct string_list unknown_extensions; - struct string_list v1_only_extensions; -}; - -/* - * Always use this to initialize a `struct repository_format` - * to a well-defined, default state before calling - * `read_repository()`. - */ -#define REPOSITORY_FORMAT_INIT \ -{ \ - .version = -1, \ - .is_bare = -1, \ - .hash_algo = GIT_HASH_SHA1, \ - .unknown_extensions = STRING_LIST_INIT_DUP, \ - .v1_only_extensions = STRING_LIST_INIT_DUP, \ -} - -/* - * Read the repository format characteristics from the config file "path" into - * "format" struct. Returns the numeric version. On error, or if no version is - * found in the configuration, -1 is returned, format->version is set to -1, - * and all other fields in the struct are set to the default configuration - * (REPOSITORY_FORMAT_INIT). Always initialize the struct using - * REPOSITORY_FORMAT_INIT before calling this function. - */ -int read_repository_format(struct repository_format *format, const char *path); - -/* - * Free the memory held onto by `format`, but not the struct itself. - * (No need to use this after `read_repository_format()` fails.) - */ -void clear_repository_format(struct repository_format *format); - -/* - * Verify that the repository described by repository_format is something we - * can read. If it is, return 0. Otherwise, return -1, and "err" will describe - * any errors encountered. - */ -int verify_repository_format(const struct repository_format *format, - struct strbuf *err); - -/* - * Check the repository format version in the path found in get_git_dir(), - * and die if it is a version we don't understand. Generally one would - * set_git_dir() before calling this, and use it only for "are we in a valid - * repo?". - * - * If successful and fmt is not NULL, fill fmt with data. - */ -void check_repository_format(struct repository_format *fmt); - #define MTIME_CHANGED 0x0001 #define CTIME_CHANGED 0x0002 #define OWNER_CHANGED 0x0004 @@ -908,23 +771,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len); #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len) -/* - * NOTE NOTE NOTE!! - * - * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must - * not be changed. Old repositories have core.sharedrepository written in - * numeric format, and therefore these values are preserved for compatibility - * reasons. - */ -enum sharedrepo { - PERM_UMASK = 0, - OLD_PERM_GROUP = 1, - OLD_PERM_EVERYBODY = 2, - PERM_GROUP = 0660, - PERM_EVERYBODY = 0664 -}; -int git_config_perm(const char *var, const char *value); - /* * Create the directory containing the named path, using care to be * somewhat safe against races. Return one of the scld_error values to @@ -1283,15 +1129,6 @@ int ws_blank_line(const char *line, int len); void overlay_tree_on_index(struct index_state *istate, const char *tree_name, const char *prefix); -/* setup.c */ -struct startup_info { - int have_repository; - const char *prefix; - const char *original_cwd; -}; -extern struct startup_info *startup_info; -extern const char *tmp_original_cwd; - /* merge.c */ struct commit_list; int try_merge_command(struct repository *r, diff --git a/commit.c b/commit.c index f88fc5e1a2..3868f047f1 100644 --- a/commit.c +++ b/commit.c @@ -23,6 +23,7 @@ #include "refs.h" #include "commit-reach.h" #include "run-command.h" +#include "setup.h" #include "shallow.h" #include "hook.h" diff --git a/common-main.c b/common-main.c index 184d1534d2..b83cb5cf06 100644 --- a/common-main.c +++ b/common-main.c @@ -2,6 +2,7 @@ #include "exec-cmd.h" #include "gettext.h" #include "attr.h" +#include "setup.h" /* * Many parts of Git have subprograms communicate via pipe, expect the diff --git a/config.c b/config.c index 5b1a5d5205..03a4fcaba5 100644 --- a/config.c +++ b/config.c @@ -27,6 +27,7 @@ #include "color.h" #include "replace-object.h" #include "refs.h" +#include "setup.h" #include "worktree.h" #include "wrapper.h" diff --git a/daemon.c b/daemon.c index b56a8f9717..db8a31a6ea 100644 --- a/daemon.c +++ b/daemon.c @@ -5,6 +5,7 @@ #include "environment.h" #include "pkt-line.h" #include "run-command.h" +#include "setup.h" #include "strbuf.h" #include "string-list.h" #include "wrapper.h" diff --git a/diff.c b/diff.c index dcf1a94094..b858e59c5a 100644 --- a/diff.c +++ b/diff.c @@ -33,6 +33,7 @@ #include "help.h" #include "promisor-remote.h" #include "dir.h" +#include "setup.h" #include "strmap.h" #include "wrapper.h" diff --git a/dir.c b/dir.c index 06f8aa3c01..4cc2b1ead4 100644 --- a/dir.c +++ b/dir.c @@ -21,6 +21,7 @@ #include "varint.h" #include "ewah/ewok.h" #include "fsmonitor.h" +#include "setup.h" #include "submodule-config.h" #include "wrapper.h" diff --git a/environment.c b/environment.c index bf02f3cf48..649d16ac27 100644 --- a/environment.c +++ b/environment.c @@ -22,6 +22,7 @@ #include "replace-object.h" #include "tmp-objdir.h" #include "chdir-notify.h" +#include "setup.h" #include "shallow.h" #include "wrapper.h" diff --git a/git.c b/git.c index b24c105e83..77f920a6f6 100644 --- a/git.c +++ b/git.c @@ -7,6 +7,7 @@ #include "run-command.h" #include "alias.h" #include "replace-object.h" +#include "setup.h" #include "shallow.h" #define RUN_SETUP (1<<0) diff --git a/http-fetch.c b/http-fetch.c index 454933351b..c874d3402d 100644 --- a/http-fetch.c +++ b/http-fetch.c @@ -5,6 +5,7 @@ #include "hex.h" #include "http.h" #include "walker.h" +#include "setup.h" #include "strvec.h" #include "urlmatch.h" #include "trace2.h" diff --git a/http-push.c b/http-push.c index 40373bc486..e73864b51f 100644 --- a/http-push.c +++ b/http-push.c @@ -12,6 +12,7 @@ #include "exec-cmd.h" #include "remote.h" #include "list-objects.h" +#include "setup.h" #include "sigchain.h" #include "strvec.h" #include "packfile.h" diff --git a/imap-send.c b/imap-send.c index aa5b2f252d..a62424e90a 100644 --- a/imap-send.c +++ b/imap-send.c @@ -28,6 +28,7 @@ #include "gettext.h" #include "run-command.h" #include "parse-options.h" +#include "setup.h" #include "wrapper.h" #if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG) typedef void *SSL; diff --git a/line-log.c b/line-log.c index 6e7fc4b2e0..84c8093c51 100644 --- a/line-log.c +++ b/line-log.c @@ -16,6 +16,7 @@ #include "graph.h" #include "userdiff.h" #include "line-log.h" +#include "setup.h" #include "strvec.h" #include "bloom.h" diff --git a/mailmap.c b/mailmap.c index 2c6e9b238d..c24a16eaf4 100644 --- a/mailmap.c +++ b/mailmap.c @@ -3,6 +3,7 @@ #include "string-list.h" #include "mailmap.h" #include "object-store.h" +#include "setup.h" #define DEBUG_MAILMAP 0 #if DEBUG_MAILMAP diff --git a/object-file.c b/object-file.c index 3da6cd6886..05fff230f7 100644 --- a/object-file.c +++ b/object-file.c @@ -37,6 +37,7 @@ #include "packfile.h" #include "object-store.h" #include "promisor-remote.h" +#include "setup.h" #include "submodule.h" #include "fsck.h" #include "wrapper.h" diff --git a/object-name.c b/object-name.c index 3b0ce8ef05..ce973e0150 100644 --- a/object-name.c +++ b/object-name.c @@ -15,6 +15,7 @@ #include "packfile.h" #include "object-store.h" #include "repository.h" +#include "setup.h" #include "submodule.h" #include "midx.h" #include "commit-reach.h" diff --git a/path.c b/path.c index 5d5a15c13d..a170243497 100644 --- a/path.c +++ b/path.c @@ -11,6 +11,7 @@ #include "string-list.h" #include "dir.h" #include "worktree.h" +#include "setup.h" #include "submodule-config.h" #include "path.h" #include "packfile.h" diff --git a/pathspec.c b/pathspec.c index 5fb7b5f26c..6972d515f0 100644 --- a/pathspec.c +++ b/pathspec.c @@ -6,6 +6,7 @@ #include "gettext.h" #include "pathspec.h" #include "attr.h" +#include "setup.h" #include "strvec.h" #include "quote.h" diff --git a/refs.c b/refs.c index 04520e5a6b..21b317e815 100644 --- a/refs.c +++ b/refs.c @@ -22,6 +22,7 @@ #include "worktree.h" #include "strvec.h" #include "repository.h" +#include "setup.h" #include "sigchain.h" #include "date.h" #include "commit.h" diff --git a/refs/files-backend.c b/refs/files-backend.c index 0c3138ede8..d2b8925ebd 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -14,6 +14,7 @@ #include "../object.h" #include "../dir.h" #include "../chdir-notify.h" +#include "../setup.h" #include "../worktree.h" #include "../wrapper.h" diff --git a/remote-curl.c b/remote-curl.c index eb382a1e35..260ea200bb 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -18,6 +18,7 @@ #include "credential.h" #include "oid-array.h" #include "send-pack.h" +#include "setup.h" #include "protocol.h" #include "quote.h" #include "transport.h" diff --git a/remote.c b/remote.c index aeca3ff813..c29e2f5298 100644 --- a/remote.c +++ b/remote.c @@ -15,6 +15,7 @@ #include "revision.h" #include "dir.h" #include "tag.h" +#include "setup.h" #include "string-list.h" #include "strvec.h" #include "commit-reach.h" diff --git a/repository.c b/repository.c index 4412f63322..f6d9f5db08 100644 --- a/repository.c +++ b/repository.c @@ -11,6 +11,7 @@ #include "object.h" #include "lockfile.h" #include "remote.h" +#include "setup.h" #include "submodule-config.h" #include "sparse-index.h" #include "promisor-remote.h" diff --git a/revision.c b/revision.c index 53fdeef078..f98691a353 100644 --- a/revision.c +++ b/revision.c @@ -29,6 +29,7 @@ #include "bisect.h" #include "packfile.h" #include "worktree.h" +#include "setup.h" #include "strvec.h" #include "commit-reach.h" #include "commit-graph.h" diff --git a/scalar.c b/scalar.c index fe61a3ebdd..27635658c0 100644 --- a/scalar.c +++ b/scalar.c @@ -15,6 +15,7 @@ #include "dir.h" #include "packfile.h" #include "help.h" +#include "setup.h" static void setup_enlistment_directory(int argc, const char **argv, const char * const *usagestr, diff --git a/setup.c b/setup.c index cfdc849a78..6c5b85e96c 100644 --- a/setup.c +++ b/setup.c @@ -5,6 +5,7 @@ #include "repository.h" #include "config.h" #include "dir.h" +#include "setup.h" #include "string-list.h" #include "chdir-notify.h" #include "promisor-remote.h" diff --git a/setup.h b/setup.h new file mode 100644 index 0000000000..4c1ca9d0c9 --- /dev/null +++ b/setup.h @@ -0,0 +1,168 @@ +#ifndef SETUP_H +#define SETUP_H + +#include "string-list.h" + +int is_inside_git_dir(void); +int is_inside_work_tree(void); +int get_common_dir_noenv(struct strbuf *sb, const char *gitdir); +int get_common_dir(struct strbuf *sb, const char *gitdir); + +/* + * Return true if the given path is a git directory; note that this _just_ + * looks at the directory itself. If you want to know whether "foo/.git" + * is a repository, you must feed that path, not just "foo". + */ +int is_git_directory(const char *path); + +/* + * Return 1 if the given path is the root of a git repository or + * submodule, else 0. Will not return 1 for bare repositories with the + * exception of creating a bare repository in "foo/.git" and calling + * is_git_repository("foo"). + * + * If we run into read errors, we err on the side of saying "yes, it is", + * as we usually consider sub-repos precious, and would prefer to err on the + * side of not disrupting or deleting them. + */ +int is_nonbare_repository_dir(struct strbuf *path); + +#define READ_GITFILE_ERR_STAT_FAILED 1 +#define READ_GITFILE_ERR_NOT_A_FILE 2 +#define READ_GITFILE_ERR_OPEN_FAILED 3 +#define READ_GITFILE_ERR_READ_FAILED 4 +#define READ_GITFILE_ERR_INVALID_FORMAT 5 +#define READ_GITFILE_ERR_NO_PATH 6 +#define READ_GITFILE_ERR_NOT_A_REPO 7 +#define READ_GITFILE_ERR_TOO_LARGE 8 +void read_gitfile_error_die(int error_code, const char *path, const char *dir); +const char *read_gitfile_gently(const char *path, int *return_error_code); +#define read_gitfile(path) read_gitfile_gently((path), NULL) +const char *resolve_gitdir_gently(const char *suspect, int *return_error_code); +#define resolve_gitdir(path) resolve_gitdir_gently((path), NULL) + +void setup_work_tree(void); +/* + * Find the commondir and gitdir of the repository that contains the current + * working directory, without changing the working directory or other global + * state. The result is appended to commondir and gitdir. If the discovered + * gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will + * both have the same result appended to the buffer. The return value is + * either 0 upon success and non-zero if no repository was found. + */ +int discover_git_directory(struct strbuf *commondir, + struct strbuf *gitdir); +const char *setup_git_directory_gently(int *); +const char *setup_git_directory(void); +char *prefix_path(const char *prefix, int len, const char *path); +char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path); + +int check_filename(const char *prefix, const char *name); +void verify_filename(const char *prefix, + const char *name, + int diagnose_misspelt_rev); +void verify_non_filename(const char *prefix, const char *name); +int path_inside_repo(const char *prefix, const char *path); + +void sanitize_stdfds(void); +int daemonize(void); + +/* + * GIT_REPO_VERSION is the version we write by default. The + * _READ variant is the highest number we know how to + * handle. + */ +#define GIT_REPO_VERSION 0 +#define GIT_REPO_VERSION_READ 1 + +/* + * You _have_ to initialize a `struct repository_format` using + * `= REPOSITORY_FORMAT_INIT` before calling `read_repository_format()`. + */ +struct repository_format { + int version; + int precious_objects; + char *partial_clone; /* value of extensions.partialclone */ + int worktree_config; + int is_bare; + int hash_algo; + int sparse_index; + char *work_tree; + struct string_list unknown_extensions; + struct string_list v1_only_extensions; +}; + +/* + * Always use this to initialize a `struct repository_format` + * to a well-defined, default state before calling + * `read_repository()`. + */ +#define REPOSITORY_FORMAT_INIT \ +{ \ + .version = -1, \ + .is_bare = -1, \ + .hash_algo = GIT_HASH_SHA1, \ + .unknown_extensions = STRING_LIST_INIT_DUP, \ + .v1_only_extensions = STRING_LIST_INIT_DUP, \ +} + +/* + * Read the repository format characteristics from the config file "path" into + * "format" struct. Returns the numeric version. On error, or if no version is + * found in the configuration, -1 is returned, format->version is set to -1, + * and all other fields in the struct are set to the default configuration + * (REPOSITORY_FORMAT_INIT). Always initialize the struct using + * REPOSITORY_FORMAT_INIT before calling this function. + */ +int read_repository_format(struct repository_format *format, const char *path); + +/* + * Free the memory held onto by `format`, but not the struct itself. + * (No need to use this after `read_repository_format()` fails.) + */ +void clear_repository_format(struct repository_format *format); + +/* + * Verify that the repository described by repository_format is something we + * can read. If it is, return 0. Otherwise, return -1, and "err" will describe + * any errors encountered. + */ +int verify_repository_format(const struct repository_format *format, + struct strbuf *err); + +/* + * Check the repository format version in the path found in get_git_dir(), + * and die if it is a version we don't understand. Generally one would + * set_git_dir() before calling this, and use it only for "are we in a valid + * repo?". + * + * If successful and fmt is not NULL, fill fmt with data. + */ +void check_repository_format(struct repository_format *fmt); + +/* + * NOTE NOTE NOTE!! + * + * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must + * not be changed. Old repositories have core.sharedrepository written in + * numeric format, and therefore these values are preserved for compatibility + * reasons. + */ +enum sharedrepo { + PERM_UMASK = 0, + OLD_PERM_GROUP = 1, + OLD_PERM_EVERYBODY = 2, + PERM_GROUP = 0660, + PERM_EVERYBODY = 0664 +}; +int git_config_perm(const char *var, const char *value); + +struct startup_info { + int have_repository; + const char *prefix; + const char *original_cwd; +}; +extern struct startup_info *startup_info; +extern const char *tmp_original_cwd; + +#endif /* SETUP_H */ diff --git a/submodule.c b/submodule.c index acf030b95e..75e0d45cbc 100644 --- a/submodule.c +++ b/submodule.c @@ -26,6 +26,7 @@ #include "parse-options.h" #include "object-store.h" #include "commit-reach.h" +#include "setup.h" #include "shallow.h" static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF; diff --git a/symlinks.c b/symlinks.c index c35c8d4408..27ecc93693 100644 --- a/symlinks.c +++ b/symlinks.c @@ -1,5 +1,6 @@ #include "cache.h" #include "gettext.h" +#include "setup.h" static int threaded_check_leading_path(struct cache_def *cache, const char *name, int len, int warn_on_lstat_err); diff --git a/t/helper/test-advise.c b/t/helper/test-advise.c index cb881139f7..4e6ed30afa 100644 --- a/t/helper/test-advise.c +++ b/t/helper/test-advise.c @@ -2,6 +2,7 @@ #include "cache.h" #include "advice.h" #include "config.h" +#include "setup.h" int cmd__advise_if_enabled(int argc, const char **argv) { diff --git a/t/helper/test-bitmap.c b/t/helper/test-bitmap.c index 5bb489882d..af43ee1cb5 100644 --- a/t/helper/test-bitmap.c +++ b/t/helper/test-bitmap.c @@ -1,6 +1,7 @@ #include "test-tool.h" #include "git-compat-util.h" #include "pack-bitmap.h" +#include "setup.h" static int bitmap_list_commits(void) { diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c index 127f134a2a..e5754b8da6 100644 --- a/t/helper/test-bloom.c +++ b/t/helper/test-bloom.c @@ -3,6 +3,7 @@ #include "hex.h" #include "test-tool.h" #include "commit.h" +#include "setup.h" static struct bloom_filter_settings settings = DEFAULT_BLOOM_FILTER_SETTINGS; diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c index 8b7a8fce1e..cdaf5046f5 100644 --- a/t/helper/test-cache-tree.c +++ b/t/helper/test-cache-tree.c @@ -6,6 +6,7 @@ #include "tree.h" #include "cache-tree.h" #include "parse-options.h" +#include "setup.h" static char const * const test_cache_tree_usage[] = { N_("test-tool cache-tree (control|prime|update)"), diff --git a/t/helper/test-config.c b/t/helper/test-config.c index 4ba9eb6560..5877188f3a 100644 --- a/t/helper/test-config.c +++ b/t/helper/test-config.c @@ -1,6 +1,7 @@ #include "test-tool.h" #include "cache.h" #include "config.h" +#include "setup.h" #include "string-list.h" /* diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c index 92dfc1aa8c..715aabfbae 100644 --- a/t/helper/test-dump-cache-tree.c +++ b/t/helper/test-dump-cache-tree.c @@ -4,7 +4,7 @@ #include "hex.h" #include "tree.h" #include "cache-tree.h" - +#include "setup.h" static void dump_one(struct cache_tree *it, const char *pfx, const char *x) { diff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c index 975f0ac890..7e9de296db 100644 --- a/t/helper/test-dump-fsmonitor.c +++ b/t/helper/test-dump-fsmonitor.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "setup.h" int cmd__dump_fsmonitor(int ac, const char **av) { diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c index 813d0a38fa..289a01c10a 100644 --- a/t/helper/test-dump-split-index.c +++ b/t/helper/test-dump-split-index.c @@ -2,6 +2,7 @@ #include "test-tool.h" #include "cache.h" #include "hex.h" +#include "setup.h" #include "split-index.h" #include "ewah/ewok.h" diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c index af953fabe8..415f55f31d 100644 --- a/t/helper/test-dump-untracked-cache.c +++ b/t/helper/test-dump-untracked-cache.c @@ -3,6 +3,7 @@ #include "cache.h" #include "dir.h" #include "hex.h" +#include "setup.h" static int compare_untracked(const void *a_, const void *b_) { diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c index 627a6bdc3d..e402c35a70 100644 --- a/t/helper/test-fast-rebase.c +++ b/t/helper/test-fast-rebase.c @@ -23,6 +23,7 @@ #include "refs.h" #include "revision.h" #include "sequencer.h" +#include "setup.h" #include "strvec.h" #include "tree.h" diff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c index c43fc976b8..a37236cd0a 100644 --- a/t/helper/test-fsmonitor-client.c +++ b/t/helper/test-fsmonitor-client.c @@ -7,6 +7,7 @@ #include "cache.h" #include "parse-options.h" #include "fsmonitor-ipc.h" +#include "setup.h" #include "thread-utils.h" #include "trace2.h" #include "wrapper.h" diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c index 2b678a4579..06ce3a47cc 100644 --- a/t/helper/test-lazy-init-name-hash.c +++ b/t/helper/test-lazy-init-name-hash.c @@ -3,6 +3,7 @@ #include "cache.h" #include "environment.h" #include "parse-options.h" +#include "setup.h" static int single; static int multi; diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c index 04bc2563f3..64705734df 100644 --- a/t/helper/test-match-trees.c +++ b/t/helper/test-match-trees.c @@ -1,6 +1,7 @@ #include "test-tool.h" #include "cache.h" #include "hex.h" +#include "setup.h" #include "tree.h" int cmd__match_trees(int ac, const char **av) diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c index 0906993ad5..fd6f73ea03 100644 --- a/t/helper/test-oid-array.c +++ b/t/helper/test-oid-array.c @@ -2,6 +2,7 @@ #include "cache.h" #include "hex.h" #include "oid-array.h" +#include "setup.h" static int print_oid(const struct object_id *oid, void *data) { diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c index 883d40efd4..f1b3dbe376 100644 --- a/t/helper/test-oidmap.c +++ b/t/helper/test-oidmap.c @@ -2,6 +2,7 @@ #include "cache.h" #include "hex.h" #include "oidmap.h" +#include "setup.h" #include "strbuf.h" /* key is an oid and value is a name (could be a refname for example) */ diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c index 0b82431a70..edcb7e9f44 100644 --- a/t/helper/test-oidtree.c +++ b/t/helper/test-oidtree.c @@ -2,6 +2,7 @@ #include "cache.h" #include "hex.h" #include "oidtree.h" +#include "setup.h" static enum cb_next print_oid(const struct object_id *oid, void *data) { diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c index 0e53dee9e5..75ca1505a3 100644 --- a/t/helper/test-pack-mtimes.c +++ b/t/helper/test-pack-mtimes.c @@ -5,6 +5,7 @@ #include "object-store.h" #include "packfile.h" #include "pack-mtimes.h" +#include "setup.h" static void dump_mtimes(struct packed_git *p) { diff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c index da17fd37eb..cce496944a 100644 --- a/t/helper/test-partial-clone.c +++ b/t/helper/test-partial-clone.c @@ -3,6 +3,7 @@ #include "test-tool.h" #include "repository.h" #include "object-store.h" +#include "setup.h" /* * Prints the size of the object corresponding to the given hash in a specific diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c index cc266e3ec0..4f5ac2fadc 100644 --- a/t/helper/test-path-utils.c +++ b/t/helper/test-path-utils.c @@ -2,6 +2,7 @@ #include "cache.h" #include "abspath.h" #include "environment.h" +#include "setup.h" #include "string-list.h" #include "utf8.h" diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c index 7e12d4f9aa..7c8de7b562 100644 --- a/t/helper/test-proc-receive.c +++ b/t/helper/test-proc-receive.c @@ -3,6 +3,7 @@ #include "hex.h" #include "parse-options.h" #include "pkt-line.h" +#include "setup.h" #include "sigchain.h" #include "test-tool.h" diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c index 09c711038c..91bb2dec1d 100644 --- a/t/helper/test-reach.c +++ b/t/helper/test-reach.c @@ -8,6 +8,7 @@ #include "hex.h" #include "parse-options.h" #include "ref-filter.h" +#include "setup.h" #include "string-list.h" #include "tag.h" diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index 84818363d5..a4c24d0e42 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -2,6 +2,7 @@ #include "test-tool.h" #include "cache.h" #include "config.h" +#include "setup.h" #include "wrapper.h" int cmd__read_cache(int argc, const char **argv) diff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c index 98b73bb8f2..e21b0805f3 100644 --- a/t/helper/test-read-graph.c +++ b/t/helper/test-read-graph.c @@ -4,6 +4,7 @@ #include "repository.h" #include "object-store.h" #include "bloom.h" +#include "setup.h" int cmd__read_graph(int argc, const char **argv) { diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c index 0a883cdf26..05c4f2b262 100644 --- a/t/helper/test-read-midx.c +++ b/t/helper/test-read-midx.c @@ -5,6 +5,7 @@ #include "repository.h" #include "object-store.h" #include "pack-bitmap.h" +#include "setup.h" static int read_midx_file(const char *object_dir, int show_objects) { diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 1745b088b7..8717b95e84 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -2,6 +2,7 @@ #include "cache.h" #include "hex.h" #include "refs.h" +#include "setup.h" #include "worktree.h" #include "object-store.h" #include "repository.h" diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c index c444775eb0..6774f6245f 100644 --- a/t/helper/test-repository.c +++ b/t/helper/test-repository.c @@ -8,6 +8,7 @@ #include "object-store.h" #include "object.h" #include "repository.h" +#include "setup.h" #include "tree.h" static void test_parse_commit_in_graph(const char *gitdir, const char *worktree, diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c index 4a45d5bac2..f2df433406 100644 --- a/t/helper/test-revision-walking.c +++ b/t/helper/test-revision-walking.c @@ -13,6 +13,7 @@ #include "commit.h" #include "diff.h" #include "revision.h" +#include "setup.h" static void print_commit(struct commit *commit) { diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c index a26107ed70..15b7688774 100644 --- a/t/helper/test-scrap-cache-tree.c +++ b/t/helper/test-scrap-cache-tree.c @@ -2,6 +2,7 @@ #include "test-tool.h" #include "cache.h" #include "lockfile.h" +#include "setup.h" #include "tree.h" #include "cache-tree.h" diff --git a/t/helper/test-serve-v2.c b/t/helper/test-serve-v2.c index 497d72058d..7d590ab722 100644 --- a/t/helper/test-serve-v2.c +++ b/t/helper/test-serve-v2.c @@ -3,6 +3,7 @@ #include "gettext.h" #include "parse-options.h" #include "serve.h" +#include "setup.h" static char const * const serve_usage[] = { N_("test-tool serve-v2 []"), diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c index 22a41c4092..256bfa6e9e 100644 --- a/t/helper/test-submodule-config.c +++ b/t/helper/test-submodule-config.c @@ -1,6 +1,7 @@ #include "test-tool.h" #include "cache.h" #include "config.h" +#include "setup.h" #include "submodule-config.h" #include "submodule.h" diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c index a3848a8b66..aaffd422d6 100644 --- a/t/helper/test-submodule-nested-repo-config.c +++ b/t/helper/test-submodule-nested-repo-config.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "setup.h" #include "submodule-config.h" static void die_usage(const char **argv, const char *msg) diff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c index e060cc6226..f18ca46dce 100644 --- a/t/helper/test-submodule.c +++ b/t/helper/test-submodule.c @@ -3,6 +3,7 @@ #include "cache.h" #include "parse-options.h" #include "remote.h" +#include "setup.h" #include "submodule-config.h" #include "submodule.h" diff --git a/t/helper/test-subprocess.c b/t/helper/test-subprocess.c index ff22f2fa2c..65a355cc59 100644 --- a/t/helper/test-subprocess.c +++ b/t/helper/test-subprocess.c @@ -1,6 +1,7 @@ #include "test-tool.h" #include "cache.h" #include "run-command.h" +#include "setup.h" int cmd__subprocess(int argc, const char **argv) { diff --git a/t/helper/test-userdiff.c b/t/helper/test-userdiff.c index a2b56b9cae..0cd7ee12b7 100644 --- a/t/helper/test-userdiff.c +++ b/t/helper/test-userdiff.c @@ -1,5 +1,6 @@ #include "test-tool.h" #include "cache.h" +#include "setup.h" #include "userdiff.h" #include "config.h" diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c index 7d45cd61e8..a93417ed3a 100644 --- a/t/helper/test-write-cache.c +++ b/t/helper/test-write-cache.c @@ -2,6 +2,7 @@ #include "test-tool.h" #include "cache.h" #include "lockfile.h" +#include "setup.h" int cmd__write_cache(int argc, const char **argv) { diff --git a/trace.c b/trace.c index 9c85b71ec6..81318a2455 100644 --- a/trace.c +++ b/trace.c @@ -25,6 +25,7 @@ #include "abspath.h" #include "environment.h" #include "quote.h" +#include "setup.h" #include "wrapper.h" struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 }; diff --git a/unpack-trees.c b/unpack-trees.c index 0ff4bbc6b9..a26fda3493 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -22,6 +22,7 @@ #include "promisor-remote.h" #include "entry.h" #include "parallel-checkout.h" +#include "setup.h" /* * Error messages expected by scripts out of plumbing commands such as diff --git a/worktree.c b/worktree.c index c2671b0cdf..7f0f04eab5 100644 --- a/worktree.c +++ b/worktree.c @@ -5,6 +5,7 @@ #include "gettext.h" #include "repository.h" #include "refs.h" +#include "setup.h" #include "strbuf.h" #include "worktree.h" #include "dir.h" diff --git a/wt-status.c b/wt-status.c index 106e46480a..16e0df5736 100644 --- a/wt-status.c +++ b/wt-status.c @@ -16,6 +16,7 @@ #include "refs.h" #include "submodule.h" #include "column.h" +#include "setup.h" #include "strbuf.h" #include "utf8.h" #include "worktree.h" -- cgit v1.2.3