mirror of
https://github.com/git/git.git
synced 2024-09-28 07:40:44 +02:00
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>
This commit is contained in:
parent
65c425a2ec
commit
5b2f6d9cd5
@ -433,11 +433,9 @@ static int read_oneliner(struct strbuf *buf,
|
|||||||
{
|
{
|
||||||
int orig_len = buf->len;
|
int orig_len = buf->len;
|
||||||
|
|
||||||
if (!file_exists(path))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if (strbuf_read_file(buf, path, 0) < 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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user