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