setup.h: move declarations for setup.c functions from cache.h
Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Mar 21, 2023 at 06:26 UTC
e38da487cc50ce4b5b48085eebcab8268c541579
105 files changed
+271
-164
apply.c
+1
@@ -27,6 +27,7 @@
27
#include "rerere.h"
28
#include "apply.h"
29
#include "entry.h"
30
+#include "setup.h"
31
#include "wrapper.h"
32
33
struct gitdiff_data {
archive.c
+1
@@ -5,6 +5,7 @@
5
#include "environment.h"
6
#include "gettext.h"
7
#include "hex.h"
8
+#include "setup.h"
9
#include "refs.h"
10
#include "object-store.h"
11
#include "commit.h"
attr.c
+1
@@ -18,6 +18,7 @@
18
#include "quote.h"
19
#include "revision.h"
20
#include "object-store.h"
21
+#include "setup.h"
22
#include "thread-utils.h"
23
24
const char git_attr__true[] = "(builtin)true";
blame.c
+1
@@ -7,6 +7,7 @@
7
#include "diffcore.h"
8
#include "gettext.h"
9
#include "hex.h"
10
+#include "setup.h"
11
#include "tag.h"
12
#include "blame.h"
13
#include "alloc.h"
builtin/blame.c
+1
@@ -31,6 +31,7 @@
31
#include "object-store.h"
32
#include "blame.h"
33
#include "refs.h"
34
+#include "setup.h"
35
#include "tag.h"
36
37
static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");
builtin/bugreport.c
+1
@@ -8,6 +8,7 @@
8
#include "hook.h"
9
#include "hook-list.h"
10
#include "diagnose.h"
11
+#include "setup.h"
12
#include "wrapper.h"
13
14
static void get_system_info(struct strbuf *sys_info)
builtin/bundle.c
+1
@@ -1,6 +1,7 @@
1
#include "builtin.h"
2
#include "abspath.h"
3
#include "gettext.h"
4
+#include "setup.h"
5
#include "strvec.h"
6
#include "parse-options.h"
7
#include "cache.h"
builtin/check-attr.c
+1
@@ -6,6 +6,7 @@
6
#include "environment.h"
7
#include "gettext.h"
8
#include "quote.h"
9
+#include "setup.h"
10
#include "parse-options.h"
11
12
static int all_attrs;
builtin/check-ref-format.c
+1
@@ -5,6 +5,7 @@
5
#include "cache.h"
6
#include "refs.h"
7
#include "builtin.h"
8
+#include "setup.h"
9
#include "strbuf.h"
10
11
static const char builtin_check_ref_format_usage[] =
builtin/checkout-index.c
+1
@@ -15,6 +15,7 @@
15
#include "parse-options.h"
16
#include "entry.h"
17
#include "parallel-checkout.h"
18
+#include "setup.h"
19
20
#define CHECKOUT_ALL 4
21
static int nul_term_line;
builtin/checkout.c
+1
@@ -23,6 +23,7 @@
23
#include "resolve-undo.h"
24
#include "revision.h"
25
#include "run-command.h"
26
+#include "setup.h"
27
#include "submodule.h"
28
#include "submodule-config.h"
29
#include "tree.h"
builtin/clean.c
+1
@@ -14,6 +14,7 @@
14
#include "dir.h"
15
#include "gettext.h"
16
#include "parse-options.h"
17
+#include "setup.h"
18
#include "string-list.h"
19
#include "quote.h"
20
#include "column.h"
builtin/clone.c
+1
@@ -33,6 +33,7 @@
33
#include "branch.h"
34
#include "remote.h"
35
#include "run-command.h"
36
+#include "setup.h"
37
#include "connected.h"
38
#include "packfile.h"
39
#include "list-objects-filter-options.h"
builtin/config.c
+1
@@ -9,6 +9,7 @@
9
#include "parse-options.h"
10
#include "urlmatch.h"
11
#include "quote.h"
12
+#include "setup.h"
13
#include "worktree.h"
14
#include "wrapper.h"
15
builtin/describe.c
+1
@@ -15,6 +15,7 @@
15
#include "revision.h"
16
#include "diff.h"
17
#include "hashmap.h"
18
+#include "setup.h"
19
#include "strvec.h"
20
#include "run-command.h"
21
#include "object-store.h"
builtin/diff-index.c
+1
@@ -5,6 +5,7 @@
5
#include "commit.h"
6
#include "revision.h"
7
#include "builtin.h"
8
+#include "setup.h"
9
#include "submodule.h"
10
11
static const char diff_cache_usage[] =
builtin/diff.c
+1
@@ -19,6 +19,7 @@
19
#include "revision.h"
20
#include "log-tree.h"
21
#include "builtin.h"
22
+#include "setup.h"
23
#include "submodule.h"
24
#include "oid-array.h"
25
builtin/difftool.c
+1
@@ -28,6 +28,7 @@
28
#include "object-store.h"
29
#include "dir.h"
30
#include "entry.h"
31
+#include "setup.h"
32
#include "wrapper.h"
33
34
static int trust_exit_code;
builtin/gc.c
+1
@@ -36,6 +36,7 @@
36
#include "exec-cmd.h"
37
#include "gettext.h"
38
#include "hook.h"
39
+#include "setup.h"
40
#include "wrapper.h"
41
42
#define FAILED_RUN "failed to run %s"
builtin/grep.c
+1
@@ -23,6 +23,7 @@
23
#include "quote.h"
24
#include "dir.h"
25
#include "pathspec.h"
26
+#include "setup.h"
27
#include "submodule.h"
28
#include "submodule-config.h"
29
#include "object-store.h"
builtin/hash-object.c
+1
@@ -14,6 +14,7 @@
14
#include "quote.h"
15
#include "parse-options.h"
16
#include "exec-cmd.h"
17
+#include "setup.h"
18
19
/*
20
* This is to create corrupt objects for debugging and as such it
builtin/help.c
+1
@@ -11,6 +11,7 @@
11
#include "config-list.h"
12
#include "help.h"
13
#include "alias.h"
14
+#include "setup.h"
15
16
#ifndef DEFAULT_HELP_FORMAT
17
#define DEFAULT_HELP_FORMAT "man"
builtin/index-pack.c
+1
@@ -20,6 +20,7 @@
20
#include "object-store.h"
21
#include "replace-object.h"
22
#include "promisor-remote.h"
23
+#include "setup.h"
24
#include "wrapper.h"
25
26
static const char index_pack_usage[] =
builtin/init-db.c
+1
@@ -12,6 +12,7 @@
12
#include "builtin.h"
13
#include "exec-cmd.h"
14
#include "parse-options.h"
15
+#include "setup.h"
16
#include "worktree.h"
17
#include "wrapper.h"
18
builtin/ls-files.c
+1
@@ -20,6 +20,7 @@
20
#include "string-list.h"
21
#include "pathspec.h"
22
#include "run-command.h"
23
+#include "setup.h"
24
#include "submodule.h"
25
#include "submodule-config.h"
26
builtin/merge-file.c
+1
@@ -3,6 +3,7 @@
3
#include "cache.h"
4
#include "config.h"
5
#include "gettext.h"
6
+#include "setup.h"
7
#include "xdiff/xdiff.h"
8
#include "xdiff-interface.h"
9
#include "parse-options.h"
builtin/mv.c
+1
@@ -16,6 +16,7 @@
16
#include "cache-tree.h"
17
#include "string-list.h"
18
#include "parse-options.h"
19
+#include "setup.h"
20
#include "submodule.h"
21
#include "entry.h"
22
builtin/read-tree.c
+1
@@ -19,6 +19,7 @@
19
#include "builtin.h"
20
#include "parse-options.h"
21
#include "resolve-undo.h"
22
+#include "setup.h"
23
#include "submodule.h"
24
#include "submodule-config.h"
25
builtin/reset.c
+1
@@ -26,6 +26,7 @@
26
#include "parse-options.h"
27
#include "unpack-trees.h"
28
#include "cache-tree.h"
29
+#include "setup.h"
30
#include "submodule.h"
31
#include "submodule-config.h"
32
#include "dir.h"
builtin/rev-parse.c
+1
@@ -18,6 +18,7 @@
18
#include "parse-options.h"
19
#include "diff.h"
20
#include "revision.h"
21
+#include "setup.h"
22
#include "split-index.h"
23
#include "submodule.h"
24
#include "commit-reach.h"
builtin/rm.c
+1
@@ -15,6 +15,7 @@
15
#include "tree-walk.h"
16
#include "parse-options.h"
17
#include "string-list.h"
18
+#include "setup.h"
19
#include "submodule.h"
20
#include "pathspec.h"
21
builtin/shortlog.c
+1
@@ -9,6 +9,7 @@
9
#include "revision.h"
10
#include "utf8.h"
11
#include "mailmap.h"
12
+#include "setup.h"
13
#include "shortlog.h"
14
#include "parse-options.h"
15
#include "trailer.h"
builtin/sparse-checkout.c
+1
@@ -16,6 +16,7 @@
16
#include "unpack-trees.h"
17
#include "wt-status.h"
18
#include "quote.h"
19
+#include "setup.h"
20
#include "sparse-index.h"
21
#include "worktree.h"
22
builtin/stash.c
+1
@@ -18,6 +18,7 @@
18
#include "entry.h"
19
#include "rerere.h"
20
#include "revision.h"
21
+#include "setup.h"
22
#include "log-tree.h"
23
#include "diffcore.h"
24
#include "exec-cmd.h"
builtin/stripspace.c
+1
@@ -3,6 +3,7 @@
3
#include "config.h"
4
#include "gettext.h"
5
#include "parse-options.h"
6
+#include "setup.h"
7
#include "strbuf.h"
8
9
static void comment_lines(struct strbuf *buf)
builtin/submodule--helper.c
+1
@@ -12,6 +12,7 @@
12
#include "quote.h"
13
#include "pathspec.h"
14
#include "dir.h"
15
+#include "setup.h"
16
#include "submodule.h"
17
#include "submodule-config.h"
18
#include "string-list.h"
builtin/update-index.c
+1
@@ -20,6 +20,7 @@
20
#include "parse-options.h"
21
#include "pathspec.h"
22
#include "dir.h"
23
+#include "setup.h"
24
#include "split-index.h"
25
#include "fsmonitor.h"
26
cache.h
-163
@@ -452,67 +452,6 @@ static inline enum object_type object_type(unsigned int mode)
452
OBJ_BLOB;
453
}
454
455
-int is_inside_git_dir(void);
456
-int is_inside_work_tree(void);
457
-int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
458
-int get_common_dir(struct strbuf *sb, const char *gitdir);
459
-
460
-/*
461
- * Return true if the given path is a git directory; note that this _just_
462
- * looks at the directory itself. If you want to know whether "foo/.git"
463
- * is a repository, you must feed that path, not just "foo".
464
- */
465
-int is_git_directory(const char *path);
466
-
467
-/*
468
- * Return 1 if the given path is the root of a git repository or
469
- * submodule, else 0. Will not return 1 for bare repositories with the
470
- * exception of creating a bare repository in "foo/.git" and calling
471
- * is_git_repository("foo").
472
- *
473
- * If we run into read errors, we err on the side of saying "yes, it is",
474
- * as we usually consider sub-repos precious, and would prefer to err on the
475
- * side of not disrupting or deleting them.
476
- */
477
-int is_nonbare_repository_dir(struct strbuf *path);
478
-
479
-#define READ_GITFILE_ERR_STAT_FAILED 1
480
-#define READ_GITFILE_ERR_NOT_A_FILE 2
481
-#define READ_GITFILE_ERR_OPEN_FAILED 3
482
-#define READ_GITFILE_ERR_READ_FAILED 4
483
-#define READ_GITFILE_ERR_INVALID_FORMAT 5
484
-#define READ_GITFILE_ERR_NO_PATH 6
485
-#define READ_GITFILE_ERR_NOT_A_REPO 7
486
-#define READ_GITFILE_ERR_TOO_LARGE 8
487
-void read_gitfile_error_die(int error_code, const char *path, const char *dir);
488
-const char *read_gitfile_gently(const char *path, int *return_error_code);
489
-#define read_gitfile(path) read_gitfile_gently((path), NULL)
490
-const char *resolve_gitdir_gently(const char *suspect, int *return_error_code);
491
-#define resolve_gitdir(path) resolve_gitdir_gently((path), NULL)
492
-
493
-void setup_work_tree(void);
494
-/*
495
- * Find the commondir and gitdir of the repository that contains the current
496
- * working directory, without changing the working directory or other global
497
- * state. The result is appended to commondir and gitdir. If the discovered
498
- * gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will
499
- * both have the same result appended to the buffer. The return value is
500
- * either 0 upon success and non-zero if no repository was found.
501
- */
502
-int discover_git_directory(struct strbuf *commondir,
503
- struct strbuf *gitdir);
504
-const char *setup_git_directory_gently(int *);
505
-const char *setup_git_directory(void);
506
-char *prefix_path(const char *prefix, int len, const char *path);
507
-char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path);
508
-
509
-int check_filename(const char *prefix, const char *name);
510
-void verify_filename(const char *prefix,
511
- const char *name,
512
- int diagnose_misspelt_rev);
513
-void verify_non_filename(const char *prefix, const char *name);
514
-int path_inside_repo(const char *prefix, const char *path);
515
-
455
#define INIT_DB_QUIET 0x0001
456
#define INIT_DB_EXIST_OK 0x0002
457
@@ -521,9 +460,6 @@ int init_db(const char *git_dir, const char *real_git_dir,
460
const char *initial_branch, unsigned int flags);
461
void initialize_repository_version(int hash_algo, int reinit);
462
524
-void sanitize_stdfds(void);
525
-int daemonize(void);
526
-
463
/* Initialize and use the cache information */
464
struct lock_file;
465
void preload_index(struct index_state *index,
@@ -807,79 +743,6 @@ enum fsync_method {
743
744
extern enum fsync_method fsync_method;
745
810
-/*
811
- * GIT_REPO_VERSION is the version we write by default. The
812
- * _READ variant is the highest number we know how to
813
- * handle.
814
- */
815
-#define GIT_REPO_VERSION 0
816
-#define GIT_REPO_VERSION_READ 1
817
-
818
-/*
819
- * You _have_ to initialize a `struct repository_format` using
820
- * `= REPOSITORY_FORMAT_INIT` before calling `read_repository_format()`.
821
- */
822
-struct repository_format {
823
- int version;
824
- int precious_objects;
825
- char *partial_clone; /* value of extensions.partialclone */
826
- int worktree_config;
827
- int is_bare;
828
- int hash_algo;
829
- int sparse_index;
830
- char *work_tree;
831
- struct string_list unknown_extensions;
832
- struct string_list v1_only_extensions;
833
-};
834
-
835
-/*
836
- * Always use this to initialize a `struct repository_format`
837
- * to a well-defined, default state before calling
838
- * `read_repository()`.
839
- */
840
-#define REPOSITORY_FORMAT_INIT \
841
-{ \
842
- .version = -1, \
843
- .is_bare = -1, \
844
- .hash_algo = GIT_HASH_SHA1, \
845
- .unknown_extensions = STRING_LIST_INIT_DUP, \
846
- .v1_only_extensions = STRING_LIST_INIT_DUP, \
847
-}
848
-
849
-/*
850
- * Read the repository format characteristics from the config file "path" into
851
- * "format" struct. Returns the numeric version. On error, or if no version is
852
- * found in the configuration, -1 is returned, format->version is set to -1,
853
- * and all other fields in the struct are set to the default configuration
854
- * (REPOSITORY_FORMAT_INIT). Always initialize the struct using
855
- * REPOSITORY_FORMAT_INIT before calling this function.
856
- */
857
-int read_repository_format(struct repository_format *format, const char *path);
858
-
859
-/*
860
- * Free the memory held onto by `format`, but not the struct itself.
861
- * (No need to use this after `read_repository_format()` fails.)
862
- */
863
-void clear_repository_format(struct repository_format *format);
864
-
865
-/*
866
- * Verify that the repository described by repository_format is something we
867
- * can read. If it is, return 0. Otherwise, return -1, and "err" will describe
868
- * any errors encountered.
869
- */
870
-int verify_repository_format(const struct repository_format *format,
871
- struct strbuf *err);
872
-
873
-/*
874
- * Check the repository format version in the path found in get_git_dir(),
875
- * and die if it is a version we don't understand. Generally one would
876
- * set_git_dir() before calling this, and use it only for "are we in a valid
877
- * repo?".
878
- *
879
- * If successful and fmt is not NULL, fill fmt with data.
880
- */
881
-void check_repository_format(struct repository_format *fmt);
882
-
746
#define MTIME_CHANGED 0x0001
747
#define CTIME_CHANGED 0x0002
748
#define OWNER_CHANGED 0x0004
@@ -908,23 +771,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id
771
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
772
#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
773
911
-/*
912
- * NOTE NOTE NOTE!!
913
- *
914
- * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must
915
- * not be changed. Old repositories have core.sharedrepository written in
916
- * numeric format, and therefore these values are preserved for compatibility
917
- * reasons.
918
- */
919
-enum sharedrepo {
920
- PERM_UMASK = 0,
921
- OLD_PERM_GROUP = 1,
922
- OLD_PERM_EVERYBODY = 2,
923
- PERM_GROUP = 0660,
924
- PERM_EVERYBODY = 0664
925
-};
926
-int git_config_perm(const char *var, const char *value);
927
-
774
/*
775
* Create the directory containing the named path, using care to be
776
* 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);
1129
void overlay_tree_on_index(struct index_state *istate,
1130
const char *tree_name, const char *prefix);
1131
1286
-/* setup.c */
1287
-struct startup_info {
1288
- int have_repository;
1289
- const char *prefix;
1290
- const char *original_cwd;
1291
-};
1292
-extern struct startup_info *startup_info;
1293
-extern const char *tmp_original_cwd;
1294
-
1132
/* merge.c */
1133
struct commit_list;
1134
int try_merge_command(struct repository *r,
commit.c
+1
@@ -23,6 +23,7 @@
23
#include "refs.h"
24
#include "commit-reach.h"
25
#include "run-command.h"
26
+#include "setup.h"
27
#include "shallow.h"
28
#include "hook.h"
29
common-main.c
+1
@@ -2,6 +2,7 @@
2
#include "exec-cmd.h"
3
#include "gettext.h"
4
#include "attr.h"
5
+#include "setup.h"
6
7
/*
8
* Many parts of Git have subprograms communicate via pipe, expect the
config.c
+1
@@ -27,6 +27,7 @@
27
#include "color.h"
28
#include "replace-object.h"
29
#include "refs.h"
30
+#include "setup.h"
31
#include "worktree.h"
32
#include "wrapper.h"
33
daemon.c
+1
@@ -5,6 +5,7 @@
5
#include "environment.h"
6
#include "pkt-line.h"
7
#include "run-command.h"
8
+#include "setup.h"
9
#include "strbuf.h"
10
#include "string-list.h"
11
#include "wrapper.h"
diff.c
+1
@@ -33,6 +33,7 @@
33
#include "help.h"
34
#include "promisor-remote.h"
35
#include "dir.h"
36
+#include "setup.h"
37
#include "strmap.h"
38
#include "wrapper.h"
39
dir.c
+1
@@ -21,6 +21,7 @@
21
#include "varint.h"
22
#include "ewah/ewok.h"
23
#include "fsmonitor.h"
24
+#include "setup.h"
25
#include "submodule-config.h"
26
#include "wrapper.h"
27
environment.c
+1
@@ -22,6 +22,7 @@
22
#include "replace-object.h"
23
#include "tmp-objdir.h"
24
#include "chdir-notify.h"
25
+#include "setup.h"
26
#include "shallow.h"
27
#include "wrapper.h"
28
git.c
+1
@@ -7,6 +7,7 @@
7
#include "run-command.h"
8
#include "alias.h"
9
#include "replace-object.h"
10
+#include "setup.h"
11
#include "shallow.h"
12
13
#define RUN_SETUP (1<<0)
http-fetch.c
+1
@@ -5,6 +5,7 @@
5
#include "hex.h"
6
#include "http.h"
7
#include "walker.h"
8
+#include "setup.h"
9
#include "strvec.h"
10
#include "urlmatch.h"
11
#include "trace2.h"
http-push.c
+1
@@ -12,6 +12,7 @@
12
#include "exec-cmd.h"
13
#include "remote.h"
14
#include "list-objects.h"
15
+#include "setup.h"
16
#include "sigchain.h"
17
#include "strvec.h"
18
#include "packfile.h"
imap-send.c
+1
@@ -28,6 +28,7 @@
28
#include "gettext.h"
29
#include "run-command.h"
30
#include "parse-options.h"
31
+#include "setup.h"
32
#include "wrapper.h"
33
#if defined(NO_OPENSSL) && !defined(HAVE_OPENSSL_CSPRNG)
34
typedef void *SSL;
line-log.c
+1
@@ -16,6 +16,7 @@
16
#include "graph.h"
17
#include "userdiff.h"
18
#include "line-log.h"
19
+#include "setup.h"
20
#include "strvec.h"
21
#include "bloom.h"
22
mailmap.c
+1
@@ -3,6 +3,7 @@
3
#include "string-list.h"
4
#include "mailmap.h"
5
#include "object-store.h"
6
+#include "setup.h"
7
8
#define DEBUG_MAILMAP 0
9
#if DEBUG_MAILMAP
object-file.c
+1
@@ -37,6 +37,7 @@
37
#include "packfile.h"
38
#include "object-store.h"
39
#include "promisor-remote.h"
40
+#include "setup.h"
41
#include "submodule.h"
42
#include "fsck.h"
43
#include "wrapper.h"
object-name.c
+1
@@ -15,6 +15,7 @@
15
#include "packfile.h"
16
#include "object-store.h"
17
#include "repository.h"
18
+#include "setup.h"
19
#include "submodule.h"
20
#include "midx.h"
21
#include "commit-reach.h"
path.c
+1
@@ -11,6 +11,7 @@
11
#include "string-list.h"
12
#include "dir.h"
13
#include "worktree.h"
14
+#include "setup.h"
15
#include "submodule-config.h"
16
#include "path.h"
17
#include "packfile.h"
pathspec.c
+1
@@ -6,6 +6,7 @@
6
#include "gettext.h"
7
#include "pathspec.h"
8
#include "attr.h"
9
+#include "setup.h"
10
#include "strvec.h"
11
#include "quote.h"
12
refs.c
+1
@@ -22,6 +22,7 @@
22
#include "worktree.h"
23
#include "strvec.h"
24
#include "repository.h"
25
+#include "setup.h"
26
#include "sigchain.h"
27
#include "date.h"
28
#include "commit.h"
refs/files-backend.c
+1
@@ -14,6 +14,7 @@
14
#include "../object.h"
15
#include "../dir.h"
16
#include "../chdir-notify.h"
17
+#include "../setup.h"
18
#include "../worktree.h"
19
#include "../wrapper.h"
20
remote-curl.c
+1
@@ -18,6 +18,7 @@
18
#include "credential.h"
19
#include "oid-array.h"
20
#include "send-pack.h"
21
+#include "setup.h"
22
#include "protocol.h"
23
#include "quote.h"
24
#include "transport.h"
remote.c
+1
@@ -15,6 +15,7 @@
15
#include "revision.h"
16
#include "dir.h"
17
#include "tag.h"
18
+#include "setup.h"
19
#include "string-list.h"
20
#include "strvec.h"
21
#include "commit-reach.h"
repository.c
+1
@@ -11,6 +11,7 @@
11
#include "object.h"
12
#include "lockfile.h"
13
#include "remote.h"
14
+#include "setup.h"
15
#include "submodule-config.h"
16
#include "sparse-index.h"
17
#include "promisor-remote.h"
revision.c
+1
@@ -29,6 +29,7 @@
29
#include "bisect.h"
30
#include "packfile.h"
31
#include "worktree.h"
32
+#include "setup.h"
33
#include "strvec.h"
34
#include "commit-reach.h"
35
#include "commit-graph.h"
scalar.c
+1
@@ -15,6 +15,7 @@
15
#include "dir.h"
16
#include "packfile.h"
17
#include "help.h"
18
+#include "setup.h"
19
20
static void setup_enlistment_directory(int argc, const char **argv,
21
const char * const *usagestr,
setup.c
+1
@@ -5,6 +5,7 @@
5
#include "repository.h"
6
#include "config.h"
7
#include "dir.h"
8
+#include "setup.h"
9
#include "string-list.h"
10
#include "chdir-notify.h"
11
#include "promisor-remote.h"
setup.h
new
+168
@@ -0,0 +1,168 @@
1
+#ifndef SETUP_H
2
+#define SETUP_H
3
+
4
+#include "string-list.h"
5
+
6
+int is_inside_git_dir(void);
7
+int is_inside_work_tree(void);
8
+int get_common_dir_noenv(struct strbuf *sb, const char *gitdir);
9
+int get_common_dir(struct strbuf *sb, const char *gitdir);
10
+
11
+/*
12
+ * Return true if the given path is a git directory; note that this _just_
13
+ * looks at the directory itself. If you want to know whether "foo/.git"
14
+ * is a repository, you must feed that path, not just "foo".
15
+ */
16
+int is_git_directory(const char *path);
17
+
18
+/*
19
+ * Return 1 if the given path is the root of a git repository or
20
+ * submodule, else 0. Will not return 1 for bare repositories with the
21
+ * exception of creating a bare repository in "foo/.git" and calling
22
+ * is_git_repository("foo").
23
+ *
24
+ * If we run into read errors, we err on the side of saying "yes, it is",
25
+ * as we usually consider sub-repos precious, and would prefer to err on the
26
+ * side of not disrupting or deleting them.
27
+ */
28
+int is_nonbare_repository_dir(struct strbuf *path);
29
+
30
+#define READ_GITFILE_ERR_STAT_FAILED 1
31
+#define READ_GITFILE_ERR_NOT_A_FILE 2
32
+#define READ_GITFILE_ERR_OPEN_FAILED 3
33
+#define READ_GITFILE_ERR_READ_FAILED 4
34
+#define READ_GITFILE_ERR_INVALID_FORMAT 5
35
+#define READ_GITFILE_ERR_NO_PATH 6
36
+#define READ_GITFILE_ERR_NOT_A_REPO 7
37
+#define READ_GITFILE_ERR_TOO_LARGE 8
38
+void read_gitfile_error_die(int error_code, const char *path, const char *dir);
39
+const char *read_gitfile_gently(const char *path, int *return_error_code);
40
+#define read_gitfile(path) read_gitfile_gently((path), NULL)
41
+const char *resolve_gitdir_gently(const char *suspect, int *return_error_code);
42
+#define resolve_gitdir(path) resolve_gitdir_gently((path), NULL)
43
+
44
+void setup_work_tree(void);
45
+/*
46
+ * Find the commondir and gitdir of the repository that contains the current
47
+ * working directory, without changing the working directory or other global
48
+ * state. The result is appended to commondir and gitdir. If the discovered
49
+ * gitdir does not correspond to a worktree, then 'commondir' and 'gitdir' will
50
+ * both have the same result appended to the buffer. The return value is
51
+ * either 0 upon success and non-zero if no repository was found.
52
+ */
53
+int discover_git_directory(struct strbuf *commondir,
54
+ struct strbuf *gitdir);
55
+const char *setup_git_directory_gently(int *);
56
+const char *setup_git_directory(void);
57
+char *prefix_path(const char *prefix, int len, const char *path);
58
+char *prefix_path_gently(const char *prefix, int len, int *remaining, const char *path);
59
+
60
+int check_filename(const char *prefix, const char *name);
61
+void verify_filename(const char *prefix,
62
+ const char *name,
63
+ int diagnose_misspelt_rev);
64
+void verify_non_filename(const char *prefix, const char *name);
65
+int path_inside_repo(const char *prefix, const char *path);
66
+
67
+void sanitize_stdfds(void);
68
+int daemonize(void);
69
+
70
+/*
71
+ * GIT_REPO_VERSION is the version we write by default. The
72
+ * _READ variant is the highest number we know how to
73
+ * handle.
74
+ */
75
+#define GIT_REPO_VERSION 0
76
+#define GIT_REPO_VERSION_READ 1
77
+
78
+/*
79
+ * You _have_ to initialize a `struct repository_format` using
80
+ * `= REPOSITORY_FORMAT_INIT` before calling `read_repository_format()`.
81
+ */
82
+struct repository_format {
83
+ int version;
84
+ int precious_objects;
85
+ char *partial_clone; /* value of extensions.partialclone */
86
+ int worktree_config;
87
+ int is_bare;
88
+ int hash_algo;
89
+ int sparse_index;
90
+ char *work_tree;
91
+ struct string_list unknown_extensions;
92
+ struct string_list v1_only_extensions;
93
+};
94
+
95
+/*
96
+ * Always use this to initialize a `struct repository_format`
97
+ * to a well-defined, default state before calling
98
+ * `read_repository()`.
99
+ */
100
+#define REPOSITORY_FORMAT_INIT \
101
+{ \
102
+ .version = -1, \
103
+ .is_bare = -1, \
104
+ .hash_algo = GIT_HASH_SHA1, \
105
+ .unknown_extensions = STRING_LIST_INIT_DUP, \
106
+ .v1_only_extensions = STRING_LIST_INIT_DUP, \
107
+}
108
+
109
+/*
110
+ * Read the repository format characteristics from the config file "path" into
111
+ * "format" struct. Returns the numeric version. On error, or if no version is
112
+ * found in the configuration, -1 is returned, format->version is set to -1,
113
+ * and all other fields in the struct are set to the default configuration
114
+ * (REPOSITORY_FORMAT_INIT). Always initialize the struct using
115
+ * REPOSITORY_FORMAT_INIT before calling this function.
116
+ */
117
+int read_repository_format(struct repository_format *format, const char *path);
118
+
119
+/*
120
+ * Free the memory held onto by `format`, but not the struct itself.
121
+ * (No need to use this after `read_repository_format()` fails.)
122
+ */
123
+void clear_repository_format(struct repository_format *format);
124
+
125
+/*
126
+ * Verify that the repository described by repository_format is something we
127
+ * can read. If it is, return 0. Otherwise, return -1, and "err" will describe
128
+ * any errors encountered.
129
+ */
130
+int verify_repository_format(const struct repository_format *format,
131
+ struct strbuf *err);
132
+
133
+/*
134
+ * Check the repository format version in the path found in get_git_dir(),
135
+ * and die if it is a version we don't understand. Generally one would
136
+ * set_git_dir() before calling this, and use it only for "are we in a valid
137
+ * repo?".
138
+ *
139
+ * If successful and fmt is not NULL, fill fmt with data.
140
+ */
141
+void check_repository_format(struct repository_format *fmt);
142
+
143
+/*
144
+ * NOTE NOTE NOTE!!
145
+ *
146
+ * PERM_UMASK, OLD_PERM_GROUP and OLD_PERM_EVERYBODY enumerations must
147
+ * not be changed. Old repositories have core.sharedrepository written in
148
+ * numeric format, and therefore these values are preserved for compatibility
149
+ * reasons.
150
+ */
151
+enum sharedrepo {
152
+ PERM_UMASK = 0,
153
+ OLD_PERM_GROUP = 1,
154
+ OLD_PERM_EVERYBODY = 2,
155
+ PERM_GROUP = 0660,
156
+ PERM_EVERYBODY = 0664
157
+};
158
+int git_config_perm(const char *var, const char *value);
159
+
160
+struct startup_info {
161
+ int have_repository;
162
+ const char *prefix;
163
+ const char *original_cwd;
164
+};
165
+extern struct startup_info *startup_info;
166
+extern const char *tmp_original_cwd;
167
+
168
+#endif /* SETUP_H */
submodule.c
+1
@@ -26,6 +26,7 @@
26
#include "parse-options.h"
27
#include "object-store.h"
28
#include "commit-reach.h"
29
+#include "setup.h"
30
#include "shallow.h"
31
32
static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
symlinks.c
+1
@@ -1,5 +1,6 @@
1
#include "cache.h"
2
#include "gettext.h"
3
+#include "setup.h"
4
5
static int threaded_check_leading_path(struct cache_def *cache, const char *name,
6
int len, int warn_on_lstat_err);
t/helper/test-advise.c
+1
@@ -2,6 +2,7 @@
2
#include "cache.h"
3
#include "advice.h"
4
#include "config.h"
5
+#include "setup.h"
6
7
int cmd__advise_if_enabled(int argc, const char **argv)
8
{
t/helper/test-bitmap.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "git-compat-util.h"
3
#include "pack-bitmap.h"
4
+#include "setup.h"
5
6
static int bitmap_list_commits(void)
7
{
t/helper/test-bloom.c
+1
@@ -3,6 +3,7 @@
3
#include "hex.h"
4
#include "test-tool.h"
5
#include "commit.h"
6
+#include "setup.h"
7
8
static struct bloom_filter_settings settings = DEFAULT_BLOOM_FILTER_SETTINGS;
9
t/helper/test-cache-tree.c
+1
@@ -6,6 +6,7 @@
6
#include "tree.h"
7
#include "cache-tree.h"
8
#include "parse-options.h"
9
+#include "setup.h"
10
11
static char const * const test_cache_tree_usage[] = {
12
N_("test-tool cache-tree <options> (control|prime|update)"),
t/helper/test-config.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
#include "config.h"
4
+#include "setup.h"
5
#include "string-list.h"
6
7
/*
t/helper/test-dump-cache-tree.c
+1
-1
@@ -4,7 +4,7 @@
4
#include "hex.h"
5
#include "tree.h"
6
#include "cache-tree.h"
7
-
7
+#include "setup.h"
8
9
static void dump_one(struct cache_tree *it, const char *pfx, const char *x)
10
{
t/helper/test-dump-fsmonitor.c
+1
@@ -1,5 +1,6 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
+#include "setup.h"
4
5
int cmd__dump_fsmonitor(int ac, const char **av)
6
{
t/helper/test-dump-split-index.c
+1
@@ -2,6 +2,7 @@
2
#include "test-tool.h"
3
#include "cache.h"
4
#include "hex.h"
5
+#include "setup.h"
6
#include "split-index.h"
7
#include "ewah/ewok.h"
8
t/helper/test-dump-untracked-cache.c
+1
@@ -3,6 +3,7 @@
3
#include "cache.h"
4
#include "dir.h"
5
#include "hex.h"
6
+#include "setup.h"
7
8
static int compare_untracked(const void *a_, const void *b_)
9
{
t/helper/test-fast-rebase.c
+1
@@ -23,6 +23,7 @@
23
#include "refs.h"
24
#include "revision.h"
25
#include "sequencer.h"
26
+#include "setup.h"
27
#include "strvec.h"
28
#include "tree.h"
29
t/helper/test-fsmonitor-client.c
+1
@@ -7,6 +7,7 @@
7
#include "cache.h"
8
#include "parse-options.h"
9
#include "fsmonitor-ipc.h"
10
+#include "setup.h"
11
#include "thread-utils.h"
12
#include "trace2.h"
13
#include "wrapper.h"
t/helper/test-lazy-init-name-hash.c
+1
@@ -3,6 +3,7 @@
3
#include "cache.h"
4
#include "environment.h"
5
#include "parse-options.h"
6
+#include "setup.h"
7
8
static int single;
9
static int multi;
t/helper/test-match-trees.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
#include "hex.h"
4
+#include "setup.h"
5
#include "tree.h"
6
7
int cmd__match_trees(int ac, const char **av)
t/helper/test-oid-array.c
+1
@@ -2,6 +2,7 @@
2
#include "cache.h"
3
#include "hex.h"
4
#include "oid-array.h"
5
+#include "setup.h"
6
7
static int print_oid(const struct object_id *oid, void *data)
8
{
t/helper/test-oidmap.c
+1
@@ -2,6 +2,7 @@
2
#include "cache.h"
3
#include "hex.h"
4
#include "oidmap.h"
5
+#include "setup.h"
6
#include "strbuf.h"
7
8
/* key is an oid and value is a name (could be a refname for example) */
t/helper/test-oidtree.c
+1
@@ -2,6 +2,7 @@
2
#include "cache.h"
3
#include "hex.h"
4
#include "oidtree.h"
5
+#include "setup.h"
6
7
static enum cb_next print_oid(const struct object_id *oid, void *data)
8
{
t/helper/test-pack-mtimes.c
+1
@@ -5,6 +5,7 @@
5
#include "object-store.h"
6
#include "packfile.h"
7
#include "pack-mtimes.h"
8
+#include "setup.h"
9
10
static void dump_mtimes(struct packed_git *p)
11
{
t/helper/test-partial-clone.c
+1
@@ -3,6 +3,7 @@
3
#include "test-tool.h"
4
#include "repository.h"
5
#include "object-store.h"
6
+#include "setup.h"
7
8
/*
9
* Prints the size of the object corresponding to the given hash in a specific
t/helper/test-path-utils.c
+1
@@ -2,6 +2,7 @@
2
#include "cache.h"
3
#include "abspath.h"
4
#include "environment.h"
5
+#include "setup.h"
6
#include "string-list.h"
7
#include "utf8.h"
8
t/helper/test-proc-receive.c
+1
@@ -3,6 +3,7 @@
3
#include "hex.h"
4
#include "parse-options.h"
5
#include "pkt-line.h"
6
+#include "setup.h"
7
#include "sigchain.h"
8
#include "test-tool.h"
9
t/helper/test-reach.c
+1
@@ -8,6 +8,7 @@
8
#include "hex.h"
9
#include "parse-options.h"
10
#include "ref-filter.h"
11
+#include "setup.h"
12
#include "string-list.h"
13
#include "tag.h"
14
t/helper/test-read-cache.c
+1
@@ -2,6 +2,7 @@
2
#include "test-tool.h"
3
#include "cache.h"
4
#include "config.h"
5
+#include "setup.h"
6
#include "wrapper.h"
7
8
int cmd__read_cache(int argc, const char **argv)
t/helper/test-read-graph.c
+1
@@ -4,6 +4,7 @@
4
#include "repository.h"
5
#include "object-store.h"
6
#include "bloom.h"
7
+#include "setup.h"
8
9
int cmd__read_graph(int argc, const char **argv)
10
{
t/helper/test-read-midx.c
+1
@@ -5,6 +5,7 @@
5
#include "repository.h"
6
#include "object-store.h"
7
#include "pack-bitmap.h"
8
+#include "setup.h"
9
10
static int read_midx_file(const char *object_dir, int show_objects)
11
{
t/helper/test-ref-store.c
+1
@@ -2,6 +2,7 @@
2
#include "cache.h"
3
#include "hex.h"
4
#include "refs.h"
5
+#include "setup.h"
6
#include "worktree.h"
7
#include "object-store.h"
8
#include "repository.h"
t/helper/test-repository.c
+1
@@ -8,6 +8,7 @@
8
#include "object-store.h"
9
#include "object.h"
10
#include "repository.h"
11
+#include "setup.h"
12
#include "tree.h"
13
14
static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
t/helper/test-revision-walking.c
+1
@@ -13,6 +13,7 @@
13
#include "commit.h"
14
#include "diff.h"
15
#include "revision.h"
16
+#include "setup.h"
17
18
static void print_commit(struct commit *commit)
19
{
t/helper/test-scrap-cache-tree.c
+1
@@ -2,6 +2,7 @@
2
#include "test-tool.h"
3
#include "cache.h"
4
#include "lockfile.h"
5
+#include "setup.h"
6
#include "tree.h"
7
#include "cache-tree.h"
8
t/helper/test-serve-v2.c
+1
@@ -3,6 +3,7 @@
3
#include "gettext.h"
4
#include "parse-options.h"
5
#include "serve.h"
6
+#include "setup.h"
7
8
static char const * const serve_usage[] = {
9
N_("test-tool serve-v2 [<options>]"),
t/helper/test-submodule-config.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
#include "config.h"
4
+#include "setup.h"
5
#include "submodule-config.h"
6
#include "submodule.h"
7
t/helper/test-submodule-nested-repo-config.c
+1
@@ -1,5 +1,6 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
+#include "setup.h"
4
#include "submodule-config.h"
5
6
static void die_usage(const char **argv, const char *msg)
t/helper/test-submodule.c
+1
@@ -3,6 +3,7 @@
3
#include "cache.h"
4
#include "parse-options.h"
5
#include "remote.h"
6
+#include "setup.h"
7
#include "submodule-config.h"
8
#include "submodule.h"
9
t/helper/test-subprocess.c
+1
@@ -1,6 +1,7 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
#include "run-command.h"
4
+#include "setup.h"
5
6
int cmd__subprocess(int argc, const char **argv)
7
{
t/helper/test-userdiff.c
+1
@@ -1,5 +1,6 @@
1
#include "test-tool.h"
2
#include "cache.h"
3
+#include "setup.h"
4
#include "userdiff.h"
5
#include "config.h"
6
t/helper/test-write-cache.c
+1
@@ -2,6 +2,7 @@
2
#include "test-tool.h"
3
#include "cache.h"
4
#include "lockfile.h"
5
+#include "setup.h"
6
7
int cmd__write_cache(int argc, const char **argv)
8
{
trace.c
+1
@@ -25,6 +25,7 @@
25
#include "abspath.h"
26
#include "environment.h"
27
#include "quote.h"
28
+#include "setup.h"
29
#include "wrapper.h"
30
31
struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
unpack-trees.c
+1
@@ -22,6 +22,7 @@
22
#include "promisor-remote.h"
23
#include "entry.h"
24
#include "parallel-checkout.h"
25
+#include "setup.h"
26
27
/*
28
* Error messages expected by scripts out of plumbing commands such as
worktree.c
+1
@@ -5,6 +5,7 @@
5
#include "gettext.h"
6
#include "repository.h"
7
#include "refs.h"
8
+#include "setup.h"
9
#include "strbuf.h"
10
#include "worktree.h"
11
#include "dir.h"
wt-status.c
+1
@@ -16,6 +16,7 @@
16
#include "refs.h"
17
#include "submodule.h"
18
#include "column.h"
19
+#include "setup.h"
20
#include "strbuf.h"
21
#include "utf8.h"
22
#include "worktree.h"