]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/setup-drop-global-state' into jch
authorJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2026 20:21:08 +0000 (13:21 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Jun 2026 20:21:08 +0000 (13:21 -0700)
Continuation of "setup.c" refactoring to drop remaining global state
(`git_work_tree_cfg`, `is_bare_repository_cfg`). The most notable
outcome is that `is_bare_repository()` has been updated to no longer
implicitly rely on `the_repository`.

* ps/setup-drop-global-state:
  treewide: drop USE_THE_REPOSITORY_VARIABLE
  environment: stop using `the_repository` in `is_bare_repository()`
  environment: split up concerns of `is_bare_repository_cfg`
  builtin/init: stop modifying `is_bare_repository_cfg`
  setup: remove global `git_work_tree_cfg` variable
  builtin/init: simplify logic to configure worktree
  builtin/init: stop modifying global `git_work_tree_cfg` variable

1  2 
attr.c
builtin/gc.c
builtin/repo.c
environment.c
environment.h
mailmap.c

diff --cc attr.c
Simple merge
diff --cc builtin/gc.c
Simple merge
diff --cc builtin/repo.c
Simple merge
diff --cc environment.c
index ff862dccf9e13f595a04dfa0fc08435a9f611739,bf209534153b2b7ba57aa0034ca8f2721e0b5d87..8f0c1c4f2501934830b9e4addd4a9880d584196c
@@@ -46,7 -48,7 +46,6 @@@ int has_symlinks = 1
  int minimum_abbrev = 4, default_abbrev = -1;
  int ignore_case;
  int assume_unchanged;
- int is_bare_repository_cfg = -1; /* unspecified */
 -int warn_on_object_refname_ambiguity = 1;
  char *git_commit_encoding;
  char *git_log_output_encoding;
  char *apply_default_whitespace;
@@@ -126,26 -132,12 +122,26 @@@ 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 have_git_dir(void)
  {
        return startup_info->have_repository
diff --cc environment.h
index 0ccf0a0e6e49669f0716cc8e22ba6c0e2a3b6b13,164a55df2ca225c50b1759d33d822a8cc20fe96f..8aaedcfea36c472926352f535df429d2a2ab022e
@@@ -135,16 -123,10 +135,18 @@@ 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);
 +
  void repo_config_values_init(struct repo_config_values *cfg);
  
+ int is_bare_repository(struct repository *repo);
  /*
   * 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 trust_ctime;
 -extern int check_stat;
  extern int has_symlinks;
  extern int minimum_abbrev, default_abbrev;
  extern int ignore_case;
diff --cc mailmap.c
Simple merge