]> granicus.if.org Git - git/commitdiff
Merge branch 'jk/setup-sequence-update'
authorJunio C Hamano <gitster@pobox.com>
Wed, 21 Sep 2016 22:15:23 +0000 (15:15 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Sep 2016 22:15:24 +0000 (15:15 -0700)
There were numerous corner cases in which the configuration files
are read and used or not read at all depending on the directory a
Git command was run, leading to inconsistent behaviour.  The code
to set-up repository access at the beginning of a Git process has
been updated to fix them.

* jk/setup-sequence-update:
  t1007: factor out repeated setup
  init: reset cached config when entering new repo
  init: expand comments explaining config trickery
  config: only read .git/config from configured repos
  test-config: setup git directory
  t1302: use "git -C"
  pager: handle early config
  pager: use callbacks instead of configset
  pager: make pager_program a file-local static
  pager: stop loading git_default_config()
  pager: remove obsolete comment
  diff: always try to set up the repository
  diff: handle --no-index prefixes consistently
  diff: skip implicit no-index check when given --no-index
  patch-id: use RUN_SETUP_GENTLY
  hash-object: always try to set up the git repository

1  2 
builtin/diff.c
builtin/init-db.c
cache.h
config.c
diff-no-index.c
environment.c
git.c
pager.c
t/helper/test-config.c
t/t4204-patch-id.sh

diff --cc builtin/diff.c
Simple merge
Simple merge
diff --cc cache.h
Simple merge
diff --cc config.c
index 0dfed682b86829fc06667d303c676e8abe6b3150,5e50fb1a31a5b4e0bb3c4cf517023c447c2f925f..1e4b6178f79587c9519ecbc9dd90c1e0b72af952
+++ b/config.c
@@@ -1286,32 -1191,43 +1283,32 @@@ int git_config_system(void
  
  static int do_git_config_sequence(config_fn_t fn, void *data)
  {
 -      int ret = 0, found = 0;
 +      int ret = 0;
        char *xdg_config = xdg_config_home("config");
        char *user_config = expand_user_path("~/.gitconfig");
-       char *repo_config = git_pathdup("config");
+       char *repo_config = have_git_dir() ? git_pathdup("config") : NULL;
  
 -      if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0)) {
 +      current_parsing_scope = CONFIG_SCOPE_SYSTEM;
 +      if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0))
                ret += git_config_from_file(fn, git_etc_gitconfig(),
                                            data);
 -              found += 1;
 -      }
  
 -      if (xdg_config && !access_or_die(xdg_config, R_OK, ACCESS_EACCES_OK)) {
 +      current_parsing_scope = CONFIG_SCOPE_GLOBAL;
 +      if (xdg_config && !access_or_die(xdg_config, R_OK, ACCESS_EACCES_OK))
                ret += git_config_from_file(fn, xdg_config, data);
 -              found += 1;
 -      }
  
 -      if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK)) {
 +      if (user_config && !access_or_die(user_config, R_OK, ACCESS_EACCES_OK))
                ret += git_config_from_file(fn, user_config, data);
 -              found += 1;
 -      }
  
 -      if (repo_config && !access_or_die(repo_config, R_OK, 0)) {
 +      current_parsing_scope = CONFIG_SCOPE_REPO;
 +      if (repo_config && !access_or_die(repo_config, R_OK, 0))
                ret += git_config_from_file(fn, repo_config, data);
 -              found += 1;
 -      }
  
 -      switch (git_config_from_parameters(fn, data)) {
 -      case -1: /* error */
 +      current_parsing_scope = CONFIG_SCOPE_CMDLINE;
 +      if (git_config_from_parameters(fn, data) < 0)
                die(_("unable to parse command-line config"));
 -              break;
 -      case 0: /* found nothing */
 -              break;
 -      default: /* found at least one item */
 -              found++;
 -              break;
 -      }
  
 +      current_parsing_scope = CONFIG_SCOPE_UNKNOWN;
        free(xdg_config);
        free(user_config);
        free(repo_config);
diff --cc diff-no-index.c
Simple merge
diff --cc environment.c
Simple merge
diff --cc git.c
Simple merge
diff --cc pager.c
Simple merge
Simple merge
Simple merge