]> git.ipfire.org Git - thirdparty/git.git/commit - wrapper.c
wrapper: implement xfopen()
authorPaul Tan <pyokagan@gmail.com>
Tue, 4 Aug 2015 13:51:23 +0000 (21:51 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Aug 2015 05:02:11 +0000 (22:02 -0700)
commit260eec292736388831958637eccdcf1a8f00e14d
tree8492c821dac8943a3b03ef25c5a3cecb1887b8c0
parent3ff53df7b4cbc331d302181d2d6644f4cb860a52
wrapper: implement xfopen()

A common usage pattern of fopen() is to check if it succeeded, and die()
if it failed:

FILE *fp = fopen(path, "w");
if (!fp)
die_errno(_("could not open '%s' for writing"), path);

Implement a wrapper function xfopen() for the above, so that we can save
a few lines of code and make the die() messages consistent.

Helped-by: Jeff King <peff@peff.net>
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-compat-util.h
wrapper.c