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