Skip to content

Commit bfa50c2

Browse files
Denton-Lgitster
authored andcommitted
sequencer: configurably warn on non-existent files
In the future, we plan on externing read_oneliner(). Future users of read_oneliner() will want the ability to output warnings in the event that the `path` doesn't exist. Introduce the `READ_ONELINER_WARN_MISSING` flag which, if active, would issue a warning when a file doesn't exist by always executing warning_errno() in the case where strbuf_read_file() fails. Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3442c3d commit bfa50c2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sequencer.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ static int write_message(const void *buf, size_t len, const char *filename,
420420
}
421421

422422
#define READ_ONELINER_SKIP_IF_EMPTY (1 << 0)
423+
#define READ_ONELINER_WARN_MISSING (1 << 1)
423424

424425
/*
425426
* Reads a file that was presumably written by a shell script, i.e. with an
@@ -436,7 +437,8 @@ static int read_oneliner(struct strbuf *buf,
436437
int orig_len = buf->len;
437438

438439
if (strbuf_read_file(buf, path, 0) < 0) {
439-
if (errno != ENOENT && errno != ENOTDIR)
440+
if ((flags & READ_ONELINER_WARN_MISSING) ||
441+
(errno != ENOENT && errno != ENOTDIR))
440442
warning_errno(_("could not read '%s'"), path);
441443
return 0;
442444
}

0 commit comments

Comments
 (0)