wrapper.c: add and use warn_on_fopen_errors()
In many places, Git warns about an inaccessible file after a fopen() failed. To discern these cases from other cases where we want to warn about inaccessible files, introduce a new helper specifically to test whether fopen() failed because the current user lacks the permission to open file in question. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8e178ec4d0
commit
11dc1fcb3f
3
config.c
3
config.c
@ -2640,6 +2640,9 @@ int git_config_rename_section_in_file(const char *config_filename,
|
||||
}
|
||||
|
||||
if (!(config_file = fopen(config_filename, "rb"))) {
|
||||
ret = warn_on_fopen_errors(config_filename);
|
||||
if (ret)
|
||||
goto out;
|
||||
/* no config file means nothing to rename, no error */
|
||||
goto commit_and_out;
|
||||
}
|
||||
|
Reference in New Issue
Block a user