use xopen() to handle fatal open(2) failures
Add and apply a semantic patch for using xopen() instead of calling open(2) and die() or die_errno() explicitly. This makes the error messages more consistent and shortens the code. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
a7439d0f9d
commit
66e905b7dd
@ -1136,9 +1136,7 @@ static void handle_fetch_head(struct commit_list **remotes, struct strbuf *merge
|
||||
merge_names = &fetch_head_file;
|
||||
|
||||
filename = git_path_fetch_head(the_repository);
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd < 0)
|
||||
die_errno(_("could not open '%s' for reading"), filename);
|
||||
fd = xopen(filename, O_RDONLY);
|
||||
|
||||
if (strbuf_read(merge_names, fd, 0) < 0)
|
||||
die_errno(_("could not read '%s'"), filename);
|
||||
|
||||
Reference in New Issue
Block a user