trace2: fixup access problem on /etc/gitconfig in read_very_early_config

Teach do_git_config_sequence() to optionally gently check for access to the system config. Use this option in read_very_early_config() when initializing trace2. In [1] SZEDER Gábor reported that my changes in [2] introduced a regression when the user does not have permission to read the system config. This commit addresses that problem by optionally ignoring that error. [1] https://public-inbox.org/git/285beb2b2d740ce20fdd8af1becf371ab39703db.1554995916.git.gitgitgadget@gmail.com/T/#m342e839289aec515523a98b5e34d7f42d3f1fd79 [2] https://public-inbox.org/git/285beb2b2d740ce20fdd8af1becf371ab39703db.1554995916.git.gitgitgadget@gmail.com/T/#m11b59c9228c698442f750ee8f9b10c629399ae48 Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff Hostetler committed Apr 29, 2019 at 13:14 UTC f672deec2d56b0d7ae64ce3efd918e02efc58b9c
2 files changed +5 -1
config.c
+4 -1
@@ -1676,7 +1676,9 @@ static int do_git_config_sequence(const struct config_options *opts,
1676 repo_config = NULL;
1677
1678 current_parsing_scope = CONFIG_SCOPE_SYSTEM;
1679 - if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0))
1679 + if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK,
1680 + opts->system_gently ?
1681 + ACCESS_EACCES_OK : 0))
1682 ret += git_config_from_file(fn, git_etc_gitconfig(),
1683 data);
1684
@@ -1807,6 +1809,7 @@ void read_very_early_config(config_fn_t cb, void *data)
1809 opts.ignore_repo = 1;
1810 opts.ignore_worktree = 1;
1811 opts.ignore_cmdline = 1;
1812 + opts.system_gently = 1;
1813
1814 config_with_options(cb, data, NULL, &opts);
1815 }
config.h
+1
@@ -58,6 +58,7 @@ struct config_options {
58 unsigned int ignore_repo : 1;
59 unsigned int ignore_worktree : 1;
60 unsigned int ignore_cmdline : 1;
61 + unsigned int system_gently : 1;
62 const char *commondir;
63 const char *git_dir;
64 config_parser_event_fn_t event_fn;