diff options
author | Denton Liu <liu.denton@gmail.com> | 2020-04-07 17:27:51 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-04-08 02:57:30 +0300 |
commit | 5b2f6d9cd50b1c8909326c7175aef288a9915f33 (patch) | |
tree | 17f549a69d3c7744793219a12b7622cf1e1d6fa7 /sequencer.c | |
parent | 65c425a2ec815989994716c81a2307ae5b5645bc (diff) |
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 <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 6 |
1 files changed, 2 insertions, 4 deletions
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; } |