Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2020-04-07 17:27:53 +0300
committerJunio C Hamano <gitster@pobox.com>2020-04-08 02:57:30 +0300
commitbfa50c2c7f0cb806af6d272a84c16f114e15ceee (patch)
treee6f08cc9039ed1ce9e08a1d0f9d3dad6891da3d9 /sequencer.c
parent3442c3d11df16d7cd3867b133a8ec6ddd21a8839 (diff)
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 <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sequencer.c b/sequencer.c
index 6c4e8743ef..32cc289da3 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -420,6 +420,7 @@ static int write_message(const void *buf, size_t len, const char *filename,
}
#define READ_ONELINER_SKIP_IF_EMPTY (1 << 0)
+#define READ_ONELINER_WARN_MISSING (1 << 1)
/*
* 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,
int orig_len = buf->len;
if (strbuf_read_file(buf, path, 0) < 0) {
- if (errno != ENOENT && errno != ENOTDIR)
+ if ((flags & READ_ONELINER_WARN_MISSING) ||
+ (errno != ENOENT && errno != ENOTDIR))
warning_errno(_("could not read '%s'"), path);
return 0;
}