Merge branch 'cp/unit-test-reftable-stack' into ps/reftable-exclude
[git/gitster.git] / environment.h
blob0148738ed63f987d81747afe9483097ecbf3fc8e
1 #ifndef ENVIRONMENT_H
2 #define ENVIRONMENT_H
4 struct repository;
5 struct strvec;
7 /*
8 * The character that begins a commented line in user-editable file
9 * that is subject to stripspace.
11 extern const char *comment_line_str;
12 extern char *comment_line_str_to_free;
13 extern int auto_comment_line_char;
16 * Wrapper of getenv() that returns a strdup value. This value is kept
17 * in argv to be freed later.
19 const char *getenv_safe(struct strvec *argv, const char *name);
21 /* Double-check local_repo_env below if you add to this list. */
22 #define GIT_DIR_ENVIRONMENT "GIT_DIR"
23 #define GIT_COMMON_DIR_ENVIRONMENT "GIT_COMMON_DIR"
24 #define GIT_NAMESPACE_ENVIRONMENT "GIT_NAMESPACE"
25 #define GIT_WORK_TREE_ENVIRONMENT "GIT_WORK_TREE"
26 #define GIT_PREFIX_ENVIRONMENT "GIT_PREFIX"
27 #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
28 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
29 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
30 #define GRAFT_ENVIRONMENT "GIT_GRAFT_FILE"
31 #define GIT_SHALLOW_FILE_ENVIRONMENT "GIT_SHALLOW_FILE"
32 #define TEMPLATE_DIR_ENVIRONMENT "GIT_TEMPLATE_DIR"
33 #define CONFIG_ENVIRONMENT "GIT_CONFIG"
34 #define CONFIG_DATA_ENVIRONMENT "GIT_CONFIG_PARAMETERS"
35 #define CONFIG_COUNT_ENVIRONMENT "GIT_CONFIG_COUNT"
36 #define EXEC_PATH_ENVIRONMENT "GIT_EXEC_PATH"
37 #define CEILING_DIRECTORIES_ENVIRONMENT "GIT_CEILING_DIRECTORIES"
38 #define NO_REPLACE_OBJECTS_ENVIRONMENT "GIT_NO_REPLACE_OBJECTS"
39 #define GIT_REPLACE_REF_BASE_ENVIRONMENT "GIT_REPLACE_REF_BASE"
40 #define NO_LAZY_FETCH_ENVIRONMENT "GIT_NO_LAZY_FETCH"
41 #define GITATTRIBUTES_FILE ".gitattributes"
42 #define INFOATTRIBUTES_FILE "info/attributes"
43 #define ATTRIBUTE_MACRO_PREFIX "[attr]"
44 #define GITMODULES_FILE ".gitmodules"
45 #define GITMODULES_INDEX ":.gitmodules"
46 #define GITMODULES_HEAD "HEAD:.gitmodules"
47 #define GIT_NOTES_REF_ENVIRONMENT "GIT_NOTES_REF"
48 #define GIT_NOTES_DEFAULT_REF "refs/notes/commits"
49 #define GIT_NOTES_DISPLAY_REF_ENVIRONMENT "GIT_NOTES_DISPLAY_REF"
50 #define GIT_NOTES_REWRITE_REF_ENVIRONMENT "GIT_NOTES_REWRITE_REF"
51 #define GIT_NOTES_REWRITE_MODE_ENVIRONMENT "GIT_NOTES_REWRITE_MODE"
52 #define GIT_LITERAL_PATHSPECS_ENVIRONMENT "GIT_LITERAL_PATHSPECS"
53 #define GIT_GLOB_PATHSPECS_ENVIRONMENT "GIT_GLOB_PATHSPECS"
54 #define GIT_NOGLOB_PATHSPECS_ENVIRONMENT "GIT_NOGLOB_PATHSPECS"
55 #define GIT_ICASE_PATHSPECS_ENVIRONMENT "GIT_ICASE_PATHSPECS"
56 #define GIT_QUARANTINE_ENVIRONMENT "GIT_QUARANTINE_PATH"
57 #define GIT_OPTIONAL_LOCKS_ENVIRONMENT "GIT_OPTIONAL_LOCKS"
58 #define GIT_TEXT_DOMAIN_DIR_ENVIRONMENT "GIT_TEXTDOMAINDIR"
59 #define GIT_ATTR_SOURCE_ENVIRONMENT "GIT_ATTR_SOURCE"
62 * Environment variable used to propagate the --no-advice global option to the
63 * advice_enabled() helper, even when run in a subprocess.
64 * This is an internal variable that should not be set by the user.
66 #define GIT_ADVICE_ENVIRONMENT "GIT_ADVICE"
69 * Environment variable used in handshaking the wire protocol.
70 * Contains a colon ':' separated list of keys with optional values
71 * 'key[=value]'. Presence of unknown keys and values must be
72 * ignored.
74 #define GIT_PROTOCOL_ENVIRONMENT "GIT_PROTOCOL"
75 /* HTTP header used to handshake the wire protocol */
76 #define GIT_PROTOCOL_HEADER "Git-Protocol"
79 * This environment variable is expected to contain a boolean indicating
80 * whether we should or should not treat:
82 * GIT_DIR=foo.git git ...
84 * as if GIT_WORK_TREE=. was given. It's not expected that users will make use
85 * of this, but we use it internally to communicate to sub-processes that we
86 * are in a bare repo. If not set, defaults to true.
88 #define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE"
91 * Repository-local GIT_* environment variables; these will be cleared
92 * when git spawns a sub-process that runs inside another repository.
93 * The array is NULL-terminated, which makes it easy to pass in the "env"
94 * parameter of a run-command invocation, or to do a simple walk.
96 extern const char * const local_repo_env[];
98 void setup_git_env(const char *git_dir);
101 * Returns true iff we have a configured git repository (either via
102 * setup_git_directory, or in the environment via $GIT_DIR).
104 int have_git_dir(void);
106 extern int is_bare_repository_cfg;
107 int is_bare_repository(void);
108 extern char *git_work_tree_cfg;
109 const char *get_git_dir(void);
110 const char *get_git_common_dir(void);
111 const char *get_object_directory(void);
112 char *get_index_file(void);
113 char *get_graft_file(struct repository *r);
114 void set_git_dir(const char *path, int make_realpath);
115 const char *get_git_namespace(void);
116 const char *strip_namespace(const char *namespaced_ref);
117 const char *get_git_work_tree(void);
118 void set_git_work_tree(const char *tree);
120 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
122 /* Environment bits from configuration mechanism */
123 extern int trust_executable_bit;
124 extern int trust_ctime;
125 extern int check_stat;
126 extern int has_symlinks;
127 extern int minimum_abbrev, default_abbrev;
128 extern int ignore_case;
129 extern int assume_unchanged;
130 extern int prefer_symlink_refs;
131 extern int warn_ambiguous_refs;
132 extern int warn_on_object_refname_ambiguity;
133 extern char *apply_default_whitespace;
134 extern char *apply_default_ignorewhitespace;
135 extern char *git_attributes_file;
136 extern char *git_hooks_path;
137 extern int zlib_compression_level;
138 extern int pack_compression_level;
139 extern size_t packed_git_window_size;
140 extern size_t packed_git_limit;
141 extern size_t delta_base_cache_limit;
142 extern unsigned long big_file_threshold;
143 extern unsigned long pack_size_limit_cfg;
144 extern int max_allowed_tree_depth;
147 * Accessors for the core.sharedrepository config which lazy-load the value
148 * from the config (if not already set). The "reset" function can be
149 * used to unset "set" or cached value, meaning that the value will be loaded
150 * fresh from the config file on the next call to get_shared_repository().
152 void set_shared_repository(int value);
153 int get_shared_repository(void);
154 void reset_shared_repository(void);
156 extern int core_preload_index;
157 extern int precomposed_unicode;
158 extern int protect_hfs;
159 extern int protect_ntfs;
161 extern int core_apply_sparse_checkout;
162 extern int core_sparse_checkout_cone;
163 extern int sparse_expect_files_outside_of_patterns;
166 * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value).
168 int use_optional_locks(void);
170 enum log_refs_config {
171 LOG_REFS_UNSET = -1,
172 LOG_REFS_NONE = 0,
173 LOG_REFS_NORMAL,
174 LOG_REFS_ALWAYS
176 extern enum log_refs_config log_all_ref_updates;
178 enum rebase_setup_type {
179 AUTOREBASE_NEVER = 0,
180 AUTOREBASE_LOCAL,
181 AUTOREBASE_REMOTE,
182 AUTOREBASE_ALWAYS
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
194 extern enum rebase_setup_type autorebase;
195 extern enum push_default_type push_default;
197 enum object_creation_mode {
198 OBJECT_CREATION_USES_HARDLINKS = 0,
199 OBJECT_CREATION_USES_RENAMES = 1
202 extern enum object_creation_mode object_creation_mode;
204 extern char *notes_ref_name;
206 extern int grafts_keep_true_parents;
208 extern int repository_format_precious_objects;
211 * Create a temporary file rooted in the object database directory, or
212 * die on failure. The filename is taken from "pattern", which should have the
213 * usual "XXXXXX" trailer, and the resulting filename is written into the
214 * "template" buffer. Returns the open descriptor.
216 int odb_mkstemp(struct strbuf *temp_filename, const char *pattern);
219 * Create a pack .keep file named "name" (which should generally be the output
220 * of odb_pack_name). Returns a file descriptor opened for writing, or -1 on
221 * error.
223 int odb_pack_keep(const char *name);
225 const char *get_log_output_encoding(void);
226 const char *get_commit_output_encoding(void);
228 extern char *git_commit_encoding;
229 extern char *git_log_output_encoding;
231 extern char *editor_program;
232 extern char *askpass_program;
233 extern char *excludes_file;
236 * Should we print an ellipsis after an abbreviated SHA-1 value
237 * when doing diff-raw output or indicating a detached HEAD?
239 int print_sha1_ellipsis(void);
241 #endif