From: Jeff King <peff@peff.net>
To: "René Scharfe" <l.s.r@web.de>
Cc: Thomas Bock <bockthom@cs.uni-saarland.de>,
Derrick Stolee <derrickstolee@github.com>,
Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org
Subject: Re: [PATCH 3/3] parse_commit(): handle broken whitespace-only timestamp
Date: Sat, 22 Apr 2023 20:37:15 -0400 [thread overview]
Message-ID: <20230423003715.GB3953216@coredump.intra.peff.net> (raw)
In-Reply-To: <7f48188b-2e06-9f01-de8d-a24812fb20fe@web.de>
On Sat, Apr 22, 2023 at 05:53:10PM +0200, René Scharfe wrote:
> Am 22.04.23 um 15:50 schrieb Jeff King:
> > diff --git a/commit.c b/commit.c
> > index ede810ac1c..56877322d3 100644
> > --- a/commit.c
> > +++ b/commit.c
> > @@ -120,6 +120,16 @@ static timestamp_t parse_commit_date(const char *buf, const char *tail)
> > if (dateptr == buf || dateptr == eol)
> > return 0;
> >
> > + /*
> > + * trim leading whitespace; parse_timestamp() will do this itself, but
> > + * it will walk past the newline at eol while doing so. So we insist
> > + * that there is at least one digit here.
> > + */
> > + while (dateptr < eol && isspace(*dateptr))
> > + dateptr++;
> > + if (!strchr("0123456789", *dateptr))
>
> You could use (our own) isdigit() here instead. It's more concise and
> efficient.
Heh, yes, that is much better. I had strspn() on the mind since that is
what split_ident_line() uses.
I think it could even just be:
if (dateptr != eol)
which implies that we found some non-whitespace character, and then we
rely on parse_timestamp() to return 0 (which is what the current code is
effectively doing).
-Peff
next prev parent reply other threads:[~2023-04-23 0:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-22 13:50 [PATCH 3/3] parse_commit(): handle broken whitespace-only timestamp Jeff King
2023-04-22 15:53 ` René Scharfe
2023-04-23 0:37 ` Jeff King [this message]
2023-04-25 5:56 ` Jeff King
2023-04-24 18:01 ` Junio C Hamano
2023-04-25 5:27 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230423003715.GB3953216@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=bockthom@cs.uni-saarland.de \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=l.s.r@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).