Merge branch 'jk/fsmonitor-event-listener-race-fix' into maint-2.47
[git/gitster.git] / environment.h
blob923e12661e19e45af18801af91bc4f8032a7ec14
1 #ifndef ENVIRONMENT_H
2 #define ENVIRONMENT_H
4 #include "repo-settings.h"
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"
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.
51 #define GIT_ADVICE_ENVIRONMENT "GIT_ADVICE"
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.
59 #define GIT_PROTOCOL_ENVIRONMENT "GIT_PROTOCOL"
60 /* HTTP header used to handshake the wire protocol */
61 #define GIT_PROTOCOL_HEADER "Git-Protocol"
64 * This environment variable is expected to contain a boolean indicating
65 * whether we should or should not treat:
67 * GIT_DIR=foo.git git ...
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.
73 #define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE"
75 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
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.
83 extern const char * const local_repo_env[];
85 struct strvec;
88 * Wrapper of getenv() that returns a strdup value. This value is kept
89 * in argv to be freed later.
91 const char *getenv_safe(struct strvec *argv, const char *name);
94 * Should we print an ellipsis after an abbreviated SHA-1 value
95 * when doing diff-raw output or indicating a detached HEAD?
97 int print_sha1_ellipsis(void);
100 * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
102 int use_optional_locks(void);
104 const char *get_git_namespace(void);
105 const char *strip_namespace(const char *namespaced_ref);
108 * TODO: All the below state either explicitly or implicitly relies on
109 * `the_repository`. We should eventually get rid of these and make the
110 * dependency on a repository explicit:
112 * - `setup_git_env()` ideally shouldn't exist as it modifies global state,
113 * namely the environment. The current process shouldn't ever access that
114 * state via envvars though, but should instead consult a `struct
115 * repository`. When spawning new processes, we would ideally also pass a
116 * `struct repository` and then set up the environment variables for the
117 * child process, only.
119 * - `have_git_dir()` should not have to exist at all. Instead, we should
120 * decide on whether or not we have a `struct repository`.
122 * - All the global config variables should become tied to a repository. Like
123 * this, we'd correctly honor repository-local configuration and be able to
124 * distinguish configuration values from different repositories.
126 * Please do not add new global config variables here.
128 # ifdef USE_THE_REPOSITORY_VARIABLE
129 void setup_git_env(const char *git_dir);
132 * Returns true iff we have a configured git repository (either via
133 * setup_git_directory, or in the environment via $GIT_DIR).
135 int have_git_dir(void);
138 * Accessors for the core.sharedrepository config which lazy-load the value
139 * from the config (if not already set). The "reset" function can be
140 * used to unset "set" or cached value, meaning that the value will be loaded
141 * fresh from the config file on the next call to get_shared_repository().
143 void set_shared_repository(int value);
144 int get_shared_repository(void);
145 void reset_shared_repository(void);
147 extern int is_bare_repository_cfg;
148 int is_bare_repository(void);
149 extern char *git_work_tree_cfg;
151 /* Environment bits from configuration mechanism */
152 extern int trust_executable_bit;
153 extern int trust_ctime;
154 extern int check_stat;
155 extern int has_symlinks;
156 extern int minimum_abbrev, default_abbrev;
157 extern int ignore_case;
158 extern int assume_unchanged;
159 extern int warn_on_object_refname_ambiguity;
160 extern char *apply_default_whitespace;
161 extern char *apply_default_ignorewhitespace;
162 extern char *git_attributes_file;
163 extern char *git_hooks_path;
164 extern int zlib_compression_level;
165 extern int pack_compression_level;
166 extern size_t packed_git_window_size;
167 extern size_t packed_git_limit;
168 extern size_t delta_base_cache_limit;
169 extern unsigned long big_file_threshold;
170 extern unsigned long pack_size_limit_cfg;
171 extern int max_allowed_tree_depth;
173 extern int core_preload_index;
174 extern int precomposed_unicode;
175 extern int protect_hfs;
176 extern int protect_ntfs;
178 extern int core_apply_sparse_checkout;
179 extern int core_sparse_checkout_cone;
180 extern int sparse_expect_files_outside_of_patterns;
182 enum rebase_setup_type {
183 AUTOREBASE_NEVER = 0,
184 AUTOREBASE_LOCAL,
185 AUTOREBASE_REMOTE,
186 AUTOREBASE_ALWAYS
188 extern enum rebase_setup_type autorebase;
190 enum push_default_type {
191 PUSH_DEFAULT_NOTHING = 0,
192 PUSH_DEFAULT_MATCHING,
193 PUSH_DEFAULT_SIMPLE,
194 PUSH_DEFAULT_UPSTREAM,
195 PUSH_DEFAULT_CURRENT,
196 PUSH_DEFAULT_UNSPECIFIED
198 extern enum push_default_type push_default;
200 enum object_creation_mode {
201 OBJECT_CREATION_USES_HARDLINKS = 0,
202 OBJECT_CREATION_USES_RENAMES = 1
204 extern enum object_creation_mode object_creation_mode;
206 extern int grafts_keep_true_parents;
208 extern int repository_format_precious_objects;
210 const char *get_log_output_encoding(void);
211 const char *get_commit_output_encoding(void);
213 extern char *git_commit_encoding;
214 extern char *git_log_output_encoding;
216 extern char *editor_program;
217 extern char *askpass_program;
218 extern char *excludes_file;
221 * The character that begins a commented line in user-editable file
222 * that is subject to stripspace.
224 extern const char *comment_line_str;
225 extern char *comment_line_str_to_free;
226 extern int auto_comment_line_char;
228 # endif /* USE_THE_REPOSITORY_VARIABLE */
229 #endif /* ENVIRONMENT_H */