From 66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Wed, 25 Aug 2021 22:16:46 +0200 Subject: use xopen() to handle fatal open(2) failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- builtin/merge.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'builtin/merge.c') diff --git a/builtin/merge.c b/builtin/merge.c index 22f23990b3..47614d8070 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -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); -- cgit 1.2.3-korg