]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ty/migrate-excludes-file' into next
authorJunio C Hamano <gitster@pobox.com>
Thu, 23 Jul 2026 17:33:51 +0000 (10:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 23 Jul 2026 17:33:51 +0000 (10:33 -0700)
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()

1  2 
apply.c
branch.c
builtin/push.c
dir.c
environment.c
environment.h
object-file.c
remote.c
repository.c
repository.h

diff --cc apply.c
Simple merge
diff --cc branch.c
Simple merge
diff --cc builtin/push.c
Simple merge
diff --cc dir.c
Simple merge
diff --cc environment.c
index 1734220d5926b8aca7aedd2a6079a2183abb31a9,ef3c032e0c0329af7dcc4fd71b40a1849fb3c5f7..76ee65e62b482372f99039ede226647a1f5f4436
  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 d7b830f7e1dfbac578ad7f00be5ff1eb2f3dd1a3,a47a5c83dbd469625bb8f7d527ffba1a8b7ed53b..e7ec5b0437342de4548f64d7e25e770d1be0976b
@@@ -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
   */
  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);
diff --cc object-file.c
Simple merge
diff --cc remote.c
Simple merge
diff --cc repository.c
Simple merge
diff --cc repository.h
Simple merge