Skip to content

Commit

Permalink
trace2: fixup access problem on /etc/gitconfig in read_very_early_config
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jeffhostetler authored and gitster committed May 7, 2019
1 parent 81567ca commit f672dee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,9 @@ static int do_git_config_sequence(const struct config_options *opts,
repo_config = NULL;

current_parsing_scope = CONFIG_SCOPE_SYSTEM;
if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK, 0))
if (git_config_system() && !access_or_die(git_etc_gitconfig(), R_OK,
opts->system_gently ?
ACCESS_EACCES_OK : 0))
ret += git_config_from_file(fn, git_etc_gitconfig(),
data);

Expand Down Expand Up @@ -1807,6 +1809,7 @@ void read_very_early_config(config_fn_t cb, void *data)
opts.ignore_repo = 1;
opts.ignore_worktree = 1;
opts.ignore_cmdline = 1;
opts.system_gently = 1;

config_with_options(cb, data, NULL, &opts);
}
Expand Down
1 change: 1 addition & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct config_options {
unsigned int ignore_repo : 1;
unsigned int ignore_worktree : 1;
unsigned int ignore_cmdline : 1;
unsigned int system_gently : 1;
const char *commondir;
const char *git_dir;
config_parser_event_fn_t event_fn;
Expand Down

0 comments on commit f672dee

Please sign in to comment.