Git fork
1#ifndef ENVIRONMENT_H
2#define ENVIRONMENT_H
3
4#include "repo-settings.h"
5
6/* Double-check local_repo_env below if you add to this list. */
7#define GIT_DIR_ENVIRONMENT "GIT_DIR"
8#define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR"
9#define GIT_NAMESPACE_ENVIRONMENT "GIT_NAMESPACE"
10#define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
11#define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX"
12#define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
13#define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
14#define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
15#define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
16#define GIT_SHALLOW_FILE_ENVIRONMENT "GIT_SHALLOW_FILE"
17#define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
18#define CONFIG_ENVIRONMENT "GIT_CONFIG"
19#define CONFIG_DATA_ENVIRONMENT "GIT_CONFIG_PARAMETERS"
20#define CONFIG_COUNT_ENVIRONMENT "GIT_CONFIG_COUNT"
21#define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
22#define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
23#define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS"
24#define GIT_REPLACE_REF_BASE_ENVIRONMENT "GIT_REPLACE_REF_BASE"
25#define NO_LAZY_FETCH_ENVIRONMENT "GIT_NO_LAZY_FETCH"
26#define GITATTRIBUTES_FILE ".gitattributes"
27#define INFOATTRIBUTES_FILE "info/attributes"
28#define ATTRIBUTE_MACRO_PREFIX "[attr]"
29#define GITMODULES_FILE ".gitmodules"
30#define GITMODULES_INDEX ":.gitmodules"
31#define GITMODULES_HEAD "HEAD:.gitmodules"
32#define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF"
33#define GIT_NOTES_DEFAULT_REF "refs/notes/commits"
34#define GIT_NOTES_DISPLAY_REF_ENVIRONMENT "GIT_NOTES_DISPLAY_REF"
35#define GIT_NOTES_REWRITE_REF_ENVIRONMENT "GIT_NOTES_REWRITE_REF"
36#define GIT_NOTES_REWRITE_MODE_ENVIRONMENT "GIT_NOTES_REWRITE_MODE"
37#define GIT_LITERAL_PATHSPECS_ENVIRONMENT "GIT_LITERAL_PATHSPECS"
38#define GIT_GLOB_PATHSPECS_ENVIRONMENT "GIT_GLOB_PATHSPECS"
39#define GIT_NOGLOB_PATHSPECS_ENVIRONMENT "GIT_NOGLOB_PATHSPECS"
40#define GIT_ICASE_PATHSPECS_ENVIRONMENT "GIT_ICASE_PATHSPECS"
41#define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH"
42#define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS"
43#define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR"
44#define GIT_ATTR_SOURCE_ENVIRONMENT "GIT_ATTR_SOURCE"
45
46/*
47 * Environment variable used to propagate the --no-advice global option to the
48 * advice_enabled() helper, even when run in a subprocess.
49 * This is an internal variable that should not be set by the user.
50 */
51#define GIT_ADVICE_ENVIRONMENT "GIT_ADVICE"
52
53/*
54 * Environment variable used in handshaking the wire protocol.
55 * Contains a colon ':' separated list of keys with optional values
56 * 'key[=value]'. Presence of unknown keys and values must be
57 * ignored.
58 */
59#define GIT_PROTOCOL_ENVIRONMENT "GIT_PROTOCOL"
60/* HTTP header used to handshake the wire protocol */
61#define GIT_PROTOCOL_HEADER "Git-Protocol"
62
63/*
64 * This environment variable is expected to contain a boolean indicating
65 * whether we should or should not treat:
66 *
67 * GIT_DIR=foo.git git ...
68 *
69 * as if GIT_WORK_TREE=. was given. It's not expected that users will make use
70 * of this, but we use it internally to communicate to sub-processes that we
71 * are in a bare repo. If not set, defaults to true.
72 */
73#define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE"
74
75#define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
76
77/*
78 * Repository-local GIT_* environment variables; these will be cleared
79 * when git spawns a sub-process that runs inside another repository.
80 * The array is NULL-terminated, which makes it easy to pass in the "env"
81 * parameter of a run-command invocation, or to do a simple walk.
82 */
83extern const char * const local_repo_env[];
84
85struct strvec;
86
87/*
88 * Wrapper of getenv() that returns a strdup value. This value is kept
89 * in argv to be freed later.
90 */
91const char *getenv_safe(struct strvec *argv, const char *name);
92
93/*
94 * Should we print an ellipsis after an abbreviated SHA-1 value
95 * when doing diff-raw output or indicating a detached HEAD?
96 */
97int print_sha1_ellipsis(void);
98
99/*
100 * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
101 */
102int use_optional_locks(void);
103
104const char *get_git_namespace(void);
105const char *strip_namespace(const char *namespaced_ref);
106
107int git_default_config(const char *, const char *,
108 const struct config_context *, void *);
109
110/*
111 * TODO: All the below state either explicitly or implicitly relies on
112 * `the_repository`. We should eventually get rid of these and make the
113 * dependency on a repository explicit:
114 *
115 * - `setup_git_env()` ideally shouldn't exist as it modifies global state,
116 * namely the environment. The current process shouldn't ever access that
117 * state via envvars though, but should instead consult a `struct
118 * repository`. When spawning new processes, we would ideally also pass a
119 * `struct repository` and then set up the environment variables for the
120 * child process, only.
121 *
122 * - `have_git_dir()` should not have to exist at all. Instead, we should
123 * decide on whether or not we have a `struct repository`.
124 *
125 * - All the global config variables should become tied to a repository. Like
126 * this, we'd correctly honor repository-local configuration and be able to
127 * distinguish configuration values from different repositories.
128 *
129 * Please do not add new global config variables here.
130 */
131# ifdef USE_THE_REPOSITORY_VARIABLE
132void setup_git_env(const char *git_dir);
133
134/*
135 * Returns true iff we have a configured git repository (either via
136 * setup_git_directory, or in the environment via $GIT_DIR).
137 */
138int have_git_dir(void);
139
140extern int is_bare_repository_cfg;
141int is_bare_repository(void);
142extern char *git_work_tree_cfg;
143
144/* Environment bits from configuration mechanism */
145extern int trust_executable_bit;
146extern int trust_ctime;
147extern int check_stat;
148extern int has_symlinks;
149extern int minimum_abbrev, default_abbrev;
150extern int ignore_case;
151extern int assume_unchanged;
152extern int warn_on_object_refname_ambiguity;
153extern char *apply_default_whitespace;
154extern char *apply_default_ignorewhitespace;
155extern char *git_attributes_file;
156extern int zlib_compression_level;
157extern int pack_compression_level;
158extern unsigned long pack_size_limit_cfg;
159extern int max_allowed_tree_depth;
160
161extern int precomposed_unicode;
162extern int protect_hfs;
163extern int protect_ntfs;
164
165extern int core_apply_sparse_checkout;
166extern int core_sparse_checkout_cone;
167extern int sparse_expect_files_outside_of_patterns;
168
169enum rebase_setup_type {
170 AUTOREBASE_NEVER = 0,
171 AUTOREBASE_LOCAL,
172 AUTOREBASE_REMOTE,
173 AUTOREBASE_ALWAYS
174};
175extern enum rebase_setup_type autorebase;
176
177enum push_default_type {
178 PUSH_DEFAULT_NOTHING = 0,
179 PUSH_DEFAULT_MATCHING,
180 PUSH_DEFAULT_SIMPLE,
181 PUSH_DEFAULT_UPSTREAM,
182 PUSH_DEFAULT_CURRENT,
183 PUSH_DEFAULT_UNSPECIFIED
184};
185extern enum push_default_type push_default;
186
187enum object_creation_mode {
188 OBJECT_CREATION_USES_HARDLINKS = 0,
189 OBJECT_CREATION_USES_RENAMES = 1
190};
191extern enum object_creation_mode object_creation_mode;
192
193extern int grafts_keep_true_parents;
194
195const char *get_log_output_encoding(void);
196const char *get_commit_output_encoding(void);
197
198extern char *git_commit_encoding;
199extern char *git_log_output_encoding;
200
201extern char *editor_program;
202extern char *askpass_program;
203extern char *excludes_file;
204
205/*
206 * The character that begins a commented line in user-editable file
207 * that is subject to stripspace.
208 */
209extern const char *comment_line_str;
210extern char *comment_line_str_to_free;
211#ifndef WITH_BREAKING_CHANGES
212extern int auto_comment_line_char;
213extern bool warn_on_auto_comment_char;
214#endif /* !WITH_BREAKING_CHANGES */
215
216# endif /* USE_THE_REPOSITORY_VARIABLE */
217#endif /* ENVIRONMENT_H */