Skip to content

Commit 5b2f6d9

Browse files
Denton-Lgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 65c425a commit 5b2f6d9

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

sequencer.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,9 @@ static int read_oneliner(struct strbuf *buf,
433433
{
434434
int orig_len = buf->len;
435435

436-
if (!file_exists(path))
437-
return 0;
438-
439436
if (strbuf_read_file(buf, path, 0) < 0) {
440-
warning_errno(_("could not read '%s'"), path);
437+
if (errno != ENOENT && errno != ENOTDIR)
438+
warning_errno(_("could not read '%s'"), path);
441439
return 0;
442440
}
443441

0 commit comments

Comments
 (0)