From: Denton Liu Date: Tue, 7 Apr 2020 14:27:51 +0000 (-0400) Subject: sequencer: make file exists check more efficient X-Git-Tag: v2.27.0-rc0~72^2~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5b2f6d9cd50b1c8909326c7175aef288a9915f33;p=thirdparty%2Fgit.git sequencer: make file exists check more efficient We currently check whether a file exists and return early before reading the file. Instead of accessing the file twice, always read the file and check `errno` to see if the file doesn't exist. Signed-off-by: Denton Liu Signed-off-by: Junio C Hamano --- diff --git a/sequencer.c b/sequencer.c index faab0b13e8..a961cf5a9b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -433,11 +433,9 @@ static int read_oneliner(struct strbuf *buf, { int orig_len = buf->len; - if (!file_exists(path)) - return 0; - if (strbuf_read_file(buf, path, 0) < 0) { - warning_errno(_("could not read '%s'"), path); + if (errno != ENOENT && errno != ENOTDIR) + warning_errno(_("could not read '%s'"), path); return 0; }