From: Junio C Hamano Date: Thu, 30 Jul 2026 17:32:03 +0000 (-0700) Subject: Merge branch 'ty/migrate-excludes-file' X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fc1e7582e6a2e3666d5dbc50ad7c22b716cfd6ec;p=thirdparty%2Fgit.git Merge branch 'ty/migrate-excludes-file' The 'excludes_file' and various other global configuration variables (including 'editor_program', 'pager_program', 'askpass_program', and 'push_default') have been migrated into the per-repository structure. * ty/migrate-excludes-file: repository: adjust the comment of config_values_private_ environment: move object_creation_mode into repo_config_values environment: move autorebase into repo_config_values environment: move push_default into repo_config_values environment: migrate apply_default_whitespace and apply_default_ignorewhitespace environment: move askpass_program into repo_config_values environment: move pager_program into repo_config_values environment: move editor_program into repo_config_values environment: move excludes_file into repo_config_values repository: introduce repo_config_values_clear() --- fc1e7582e6a2e3666d5dbc50ad7c22b716cfd6ec diff --cc environment.c index 1734220d59,ef3c032e0c..76ee65e62b --- a/environment.c +++ b/environment.c @@@ -41,12 -41,14 +41,10 @@@ static int pack_compression_seen; static int zlib_compression_seen; -int trust_executable_bit = 1; -int has_symlinks = 1; int minimum_abbrev = 4, default_abbrev = -1; -int ignore_case; int assume_unchanged; -int is_bare_repository_cfg = -1; /* unspecified */ char *git_commit_encoding; char *git_log_output_encoding; - char *apply_default_whitespace; - char *apply_default_ignorewhitespace; int fsync_object_files = -1; int use_fsync = -1; enum fsync_method fsync_method = FSYNC_METHOD_DEFAULT; @@@ -119,47 -120,22 +111,57 @@@ const char *getenv_safe(struct strvec * return argv->v[argv->nr - 1]; } -int is_bare_repository(void) +int is_bare_repository(struct repository *repo) { /* if core.bare is not 'false', let's see if there is a work tree */ - return is_bare_repository_cfg && !repo_get_work_tree(the_repository); + return repo->bare_cfg && !repo_get_work_tree(repo); +} + +int repo_protect_ntfs(struct repository *repo) +{ + return (repo && repo->initialized) ? + repo_config_values(repo)->protect_ntfs : + PROTECT_NTFS_DEFAULT; +} + +int repo_protect_hfs(struct repository *repo) +{ + return (repo && repo->initialized) ? + repo_config_values(repo)->protect_hfs : + PROTECT_HFS_DEFAULT; +} + +int repo_ignore_case(struct repository *repo) +{ + return (repo && repo->initialized) ? + repo_config_values(repo)->ignore_case : + 0; +} + +int repo_trust_executable_bit(struct repository *repo) +{ + return repo->initialized + ? repo_config_values(repo)->trust_executable_bit + : 1; +} + +int repo_has_symlinks(struct repository *repo) +{ + return repo->initialized + ? repo_config_values(repo)->has_symlinks + : platform_has_symlinks(); } + const char *repo_excludes_file(struct repository *repo) + { + struct repo_config_values *cfg = repo_config_values(repo); + + if (!cfg->excludes_file) + cfg->excludes_file = xdg_config_home("ignore"); + + return cfg->excludes_file; + } + int have_git_dir(void) { return startup_info->have_repository @@@ -742,12 -719,16 +746,21 @@@ int git_default_config(const char *var void repo_config_values_init(struct repo_config_values *cfg) { cfg->attributes_file = NULL; + cfg->excludes_file = NULL; + cfg->editor_program = NULL; + cfg->pager_program = NULL; + cfg->askpass_program = NULL; + cfg->apply_default_whitespace = NULL; + cfg->apply_default_ignorewhitespace = NULL; + cfg->push_default = PUSH_DEFAULT_UNSPECIFIED; + cfg->autorebase = AUTOREBASE_NEVER; + cfg->object_creation_mode = OBJECT_CREATION_MODE; cfg->apply_sparse_checkout = 0; + cfg->protect_hfs = PROTECT_HFS_DEFAULT; + cfg->protect_ntfs = PROTECT_NTFS_DEFAULT; + cfg->ignore_case = 0; + cfg->trust_executable_bit = 1; + cfg->has_symlinks = platform_has_symlinks(); cfg->branch_track = BRANCH_TRACK_REMOTE; cfg->trust_ctime = 1; cfg->check_stat = 1; diff --cc environment.h index d7b830f7e1,a47a5c83db..e7ec5b0437 --- a/environment.h +++ b/environment.h @@@ -138,29 -169,19 +174,40 @@@ int git_default_config(const char *, co int git_default_core_config(const char *var, const char *value, const struct config_context *ctx, void *cb); +/* + * Getters for the `protect_hfs` and `protect_ntfs` fields of `struct repo_config_values`. + * They check `repo->initialized` to prevent calling `repo_config_values()` + * before the repository setup is fully complete or in non-git environments. + */ +int repo_protect_hfs(struct repository *repo); +int repo_protect_ntfs(struct repository *repo); + +/* + * Getter for the `ignore_case` field of `struct repo_config_values`. + * It checks `repo->initialized` to prevent calling repo_config_values()` + * before the repository setup is fully complete or in non-git environments. + */ +int repo_ignore_case(struct repository *repo); + +int repo_trust_executable_bit(struct repository *repo); + +int repo_has_symlinks(struct repository *repo); + + const char *repo_excludes_file(struct repository *repo); + void repo_config_values_init(struct repo_config_values *cfg); +int is_bare_repository(struct repository *repo); + + /* + * Frees memory allocated for dynamically loaded configuration values + * inside `repo_config_values`. + * + * As dynamically allocated variables are migrated into this struct, + * their FREE_AND_NULL() calls should be appended here. + */ + void repo_config_values_clear(struct repo_config_values *cfg); + /* * TODO: All the below state either explicitly or implicitly relies on * `the_repository`. We should eventually get rid of these and make the @@@ -183,37 -204,21 +230,11 @@@ */ int have_git_dir(void); -extern int is_bare_repository_cfg; -int is_bare_repository(void); -extern char *git_work_tree_cfg; - /* Environment bits from configuration mechanism */ -extern int trust_executable_bit; -extern int has_symlinks; extern int minimum_abbrev, default_abbrev; -extern int ignore_case; extern int assume_unchanged; - extern char *apply_default_whitespace; - extern char *apply_default_ignorewhitespace; extern unsigned long pack_size_limit_cfg; - enum rebase_setup_type { - AUTOREBASE_NEVER = 0, - AUTOREBASE_LOCAL, - AUTOREBASE_REMOTE, - AUTOREBASE_ALWAYS - }; - extern enum rebase_setup_type autorebase; - - enum push_default_type { - PUSH_DEFAULT_NOTHING = 0, - PUSH_DEFAULT_MATCHING, - PUSH_DEFAULT_SIMPLE, - PUSH_DEFAULT_UPSTREAM, - PUSH_DEFAULT_CURRENT, - PUSH_DEFAULT_UNSPECIFIED - }; - extern enum push_default_type push_default; - - enum object_creation_mode { - OBJECT_CREATION_USES_HARDLINKS = 0, - OBJECT_CREATION_USES_RENAMES = 1 - }; - extern enum object_creation_mode object_creation_mode; -extern int protect_hfs; -extern int protect_ntfs; -- extern int grafts_keep_true_parents; const char *get_log_output_encoding(void);