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
@ -88,9 +88,7 @@ static int parse_file_arg_callback(const struct option *opt,
|
||||
if (!strcmp(arg, "-"))
|
||||
fd = 0;
|
||||
else {
|
||||
fd = open(arg, O_RDONLY);
|
||||
if (fd < 0)
|
||||
die_errno(_("git commit-tree: failed to open '%s'"), arg);
|
||||
fd = xopen(arg, O_RDONLY);
|
||||
}
|
||||
if (strbuf_read(buf, fd, 0) < 0)
|
||||
die_errno(_("git commit-tree: failed to read '%s'"), arg);
|
||||
|
Reference in New Issue
Block a user