Skip to content

Commit f672dee

Browse files
jeffhostetlergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 81567ca commit f672dee

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

config.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,9 @@ static int do_git_config_sequence(const struct config_options *opts,
16761676
repo_config = NULL;
16771677

16781678
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))
16801682
ret += git_config_from_file(fn, git_etc_gitconfig(),
16811683
data);
16821684

@@ -1807,6 +1809,7 @@ void read_very_early_config(config_fn_t cb, void *data)
18071809
opts.ignore_repo = 1;
18081810
opts.ignore_worktree = 1;
18091811
opts.ignore_cmdline = 1;
1812+
opts.system_gently = 1;
18101813

18111814
config_with_options(cb, data, NULL, &opts);
18121815
}

config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ struct config_options {
5858
unsigned int ignore_repo : 1;
5959
unsigned int ignore_worktree : 1;
6060
unsigned int ignore_cmdline : 1;
61+
unsigned int system_gently : 1;
6162
const char *commondir;
6263
const char *git_dir;
6364
config_parser_event_fn_t event_fn;

0 commit comments

Comments
 (0)