git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] parse_commit(): handle broken whitespace-only timestamp

From
René Scharfe <l.s.r@web.de>
Date
Apr 22, 2023, 15:53 UTC
Message-ID
<7f48188b-2e06-9f01-de8d-a24812fb20fe@web.de>
In-Reply-To
<20230422135001.GA3942563@coredump.intra.peff.net>
Am 22.04.23 um 15:50 schrieb Jeff King:
Show 16 quoted lines
> 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.

René
Previous: Jeff KingNext: Jeff King
Message 2 of 6 in “parse_commit(): handle broken whitespace-only timestamp”
  1. 3/3 parse_commit(): handle broken whitespace-only timestampJeff King, Apr 22, 2023
  2. René ScharfeApr 22, 2023
  3. Jeff KingApr 23, 2023
  4. Jeff KingApr 25, 2023
  5. Junio C HamanoApr 24, 2023
  6. Jeff KingApr 25, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.