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

Re: [PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines

From
Nanako Shiraishi <nanako3@lavabit.com>
Date
Sep 27, 2008, 22:08 UTC
Message-ID
<20080928070858.6117@nanako3.lavabit.com>
Johan Herland <johan@herland.net> writes:
Show 17 quoted lines
>  builtin-for-each-ref.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/builtin-for-each-ref.c b/builtin-for-each-ref.c
> index 9b44092..e59bd80 100644
> --- a/builtin-for-each-ref.c
> +++ b/builtin-for-each-ref.c
> @@ -321,8 +321,8 @@ static const char *find_wholine(const char *who, int wholen, const char *buf, un
>  static const char *copy_line(const char *buf)
>  {
>  	const char *eol = strchr(buf, '\n');
> -	if (!eol)
> -		return "";
> +	if (!eol) // simulate strchrnul()
> +		eol = buf + strlen(buf);
>  	return xmemdupz(buf, eol - buf);
>  }
Why does this C++ style comment talk about "simulate"?
Don't other parts of git already use strchrnul()?
-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/
Next: Johan Herland
Message 1 of 2 in “Re: [PATCH] for-each-ref: Fix --format=%(subject) for log message without newlines”
  1. Nanako ShiraishiSep 27, 2008
  2. Use strchrnul() instead of strchr() plus manual workaroundJohan Herland, Sep 27, 2008

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.