Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/environment.h # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / environment.h` 270 lines ยท 9279 bytes Raw Blame History 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 #define GIT_REF_STORAGE_FORMAT_ENVIRONMENT "GIT_REF_STORAGE_FORMAT" 48 #define GIT_OBJECT_STORAGE_FORMAT_ENVIRONMENT "GIT_OBJECT_STORAGE_FORMAT" 49 50 /* 51 * Environment variable used to propagate the --no-advice global option to the 52 * advice_enabled() helper, even when run in a subprocess. 53 * This is an internal variable that should not be set by the user. 54 */ 55 #define GIT_ADVICE_ENVIRONMENT "GIT_ADVICE" 56 57 /* 58 * Environment variable used to detect that a lazy fetch is already in 59 * progress in a parent process, to prevent infinite recursion when a 60 * promisor remote resolves back to the repository being served. 61 * This is an internal variable that should not be set by the user. 62 */ 63 #define LAZY_FETCH_DEPTH_ENVIRONMENT "GIT_INTERNAL_LAZY_FETCH_DEPTH" 64 65 /* 66 * Environment variable used in handshaking the wire protocol. 67 * Contains a colon ':' separated list of keys with optional values 68 * 'key[=value]'. Presence of unknown keys and values must be 69 * ignored. 70 */ 71 #define GIT_PROTOCOL_ENVIRONMENT "GIT_PROTOCOL" 72 /* HTTP header used to handshake the wire protocol */ 73 #define GIT_PROTOCOL_HEADER "Git-Protocol" 74 75 /* 76 * This environment variable is expected to contain a boolean indicating 77 * whether we should or should not treat: 78 * 79 * GIT_DIR=foo.git git ... 80 * 81 * as if GIT_WORK_TREE=. was given. It's not expected that users will make use 82 * of this, but we use it internally to communicate to sub-processes that we 83 * are in a bare repo. If not set, defaults to true. 84 */ 85 #define GIT_IMPLICIT_WORK_TREE_ENVIRONMENT "GIT_IMPLICIT_WORK_TREE" 86 87 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES" 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 struct strvec; 98 99 struct repository; 100 101 /* 102 * NEEDSWORK: It would be better if these definitions could be moved to 103 * other more specific files, but care is needed to avoid circular 104 * inclusion issues. 105 */ 106 enum push_default_type { 107 PUSH_DEFAULT_NOTHING = 0, 108 PUSH_DEFAULT_MATCHING, 109 PUSH_DEFAULT_SIMPLE, 110 PUSH_DEFAULT_UPSTREAM, 111 PUSH_DEFAULT_CURRENT, 112 PUSH_DEFAULT_UNSPECIFIED 113 }; 114 115 enum rebase_setup_type { 116 AUTOREBASE_NEVER = 0, 117 AUTOREBASE_LOCAL, 118 AUTOREBASE_REMOTE, 119 AUTOREBASE_ALWAYS 120 }; 121 122 enum object_creation_mode { 123 OBJECT_CREATION_USES_HARDLINKS = 0, 124 OBJECT_CREATION_USES_RENAMES = 1 125 }; 126 127 struct repo_config_values { 128 /* section "core" config values */ 129 char *attributes_file; 130 char *excludes_file; 131 char *editor_program; 132 char *pager_program; 133 char *askpass_program; 134 char *apply_default_whitespace; 135 char *apply_default_ignorewhitespace; 136 enum push_default_type push_default; 137 enum rebase_setup_type autorebase; 138 enum object_creation_mode object_creation_mode; 139 int apply_sparse_checkout; 140 int trust_ctime; 141 int check_stat; 142 int zlib_compression_level; 143 int pack_compression_level; 144 int precomposed_unicode; 145 int core_sparse_checkout_cone; 146 int warn_on_object_refname_ambiguity; 147 int protect_hfs; 148 int protect_ntfs; 149 int ignore_case; 150 int trust_executable_bit; 151 int has_symlinks; 152 int use_nanosec; 153 unsigned int max_ce_namelen; 154 155 /* section "sparse" config values */ 156 int sparse_expect_files_outside_of_patterns; 157 158 /* section "branch" config values */ 159 enum branch_track branch_track; 160 }; 161 162 struct repo_config_values *repo_config_values(struct repository *repo); 163 164 /* 165 * Wrapper of getenv() that returns a strdup value. This value is kept 166 * in argv to be freed later. 167 */ 168 const char *getenv_safe(struct strvec *argv, const char *name); 169 170 /* 171 * Should we print an ellipsis after an abbreviated SHA-1 value 172 * when doing diff-raw output or indicating a detached HEAD? 173 */ 174 int print_sha1_ellipsis(void); 175 176 /* 177 * Returns the boolean value of $GIT_OPTIONAL_LOCKS (or the default value). 178 */ 179 int use_optional_locks(void); 180 181 const char *get_git_namespace(void); 182 const char *strip_namespace(const char *namespaced_ref); 183 184 int git_default_config(const char *, const char *, 185 const struct config_context *, void *); 186 int git_default_core_config(const char *var, const char *value, 187 const struct config_context *ctx, void *cb); 188 189 /* 190 * Getters for the `protect_hfs` and `protect_ntfs` fields of `struct repo_config_values`. 191 * They check `repo->initialized` to prevent calling `repo_config_values()` 192 * before the repository setup is fully complete or in non-git environments. 193 */ 194 int repo_protect_hfs(struct repository *repo); 195 int repo_protect_ntfs(struct repository *repo); 196 197 /* 198 * Getter for the `ignore_case` field of `struct repo_config_values`. 199 * It checks `repo->initialized` to prevent calling repo_config_values()` 200 * before the repository setup is fully complete or in non-git environments. 201 */ 202 int repo_ignore_case(struct repository *repo); 203 204 int repo_trust_executable_bit(struct repository *repo); 205 206 int repo_has_symlinks(struct repository *repo); 207 208 const char *repo_excludes_file(struct repository *repo); 209 210 void repo_config_values_init(struct repo_config_values *cfg); 211 212 int is_bare_repository(struct repository *repo); 213 214 /* 215 * Frees memory allocated for dynamically loaded configuration values 216 * inside `repo_config_values`. 217 * 218 * As dynamically allocated variables are migrated into this struct, 219 * their FREE_AND_NULL() calls should be appended here. 220 */ 221 void repo_config_values_clear(struct repo_config_values *cfg); 222 223 /* 224 * TODO: All the below state either explicitly or implicitly relies on 225 * `the_repository`. We should eventually get rid of these and make the 226 * dependency on a repository explicit: 227 * 228 * - `have_git_dir()` should not have to exist at all. Instead, we should 229 * decide on whether or not we have a `struct repository`. 230 * 231 * - All the global config variables should become tied to a repository. Like 232 * this, we'd correctly honor repository-local configuration and be able to 233 * distinguish configuration values from different repositories. 234 * 235 * Please do not add new global config variables here. 236 */ 237 # ifdef USE_THE_REPOSITORY_VARIABLE 238 239 /* 240 * Returns true iff we have a configured git repository (either via 241 * setup_git_directory, or in the environment via $GIT_DIR). 242 */ 243 int have_git_dir(void); 244 245 /* Environment bits from configuration mechanism */ 246 extern int minimum_abbrev, default_abbrev; 247 extern int assume_unchanged; 248 extern unsigned long pack_size_limit_cfg; 249 250 extern int grafts_keep_true_parents; 251 252 const char *get_log_output_encoding(void); 253 const char *get_commit_output_encoding(void); 254 255 extern char *git_commit_encoding; 256 extern char *git_log_output_encoding; 257 258 /* 259 * The character that begins a commented line in user-editable file 260 * that is subject to stripspace. 261 */ 262 extern const char *comment_line_str; 263 extern char *comment_line_str_to_free; 264 #ifndef WITH_BREAKING_CHANGES 265 extern int auto_comment_line_char; 266 extern bool warn_on_auto_comment_char; 267 #endif /* !WITH_BREAKING_CHANGES */ 268 269 # endif /* USE_THE_REPOSITORY_VARIABLE */ 270 #endif /* ENVIRONMENT_H */