diff options
author | Jeff King <peff@peff.net> | 2023-04-27 08:17:24 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-04-27 16:31:46 (GMT) |
commit | 90ef0f14eb1410747885806d8e55725053572654 (patch) | |
tree | f9399e3398e8e12b5389980d3dd1c0c54a94a21f /commit.c | |
parent | 089d9adff6408b8f3406e2f46179501337715ae8 (diff) | |
download | git-90ef0f14eb1410747885806d8e55725053572654.zip git-90ef0f14eb1410747885806d8e55725053572654.tar.gz git-90ef0f14eb1410747885806d8e55725053572654.tar.bz2 |
parse_commit(): describe more date-parsing failure modes
The previous few commits improved the parsing of dates in malformed
commit objects. But there's one big case left implicit: we may still
feed garbage to parse_timestamp(). This is preferable to trying to be
more strict, but let's document the thinking in a comment.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
-rw-r--r-- | commit.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -143,6 +143,15 @@ static timestamp_t parse_commit_date(const char *buf, const char *tail) /* * We know there is at least one digit (or dash), so we'll begin * parsing there and stop at worst case at eol. + * + * Note that we may feed parse_timestamp() extra characters here if the + * commit is malformed, and it will parse as far as it can. For + * example, "123foo456" would return "123". That might be questionable + * (versus returning "0"), but it would help in a hypothetical case + * like "123456+0100", where the whitespace from the timezone is + * missing. Since such syntactic errors may be baked into history and + * hard to correct now, let's err on trying to make our best guess + * here, rather than insist on perfect syntax. */ return parse_timestamp(dateptr, NULL, 10); } |