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

Re: [PATCH] drop trailing newline from warning/error/die messages

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 5, 2024, 15:18 UTC
Message-ID
<xmqqfrqe5dtf.fsf@gitster.g>
In-Reply-To
<20240905085149.GA2340826@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 19 quoted lines
> Our error reporting routines append a trailing newline, and the strings
> we pass to them should not include them (otherwise we get an extra blank
> line after the message).
>
> These cases were all found by looking at the results of:
>
>   git grep -P '[^_](error|error_errno|warning|die|die_errno)\(.*\\n"[,)]' '*.c'
>
> Note that we _do_ sometimes include a newline in the middle of such
> messages, to create multiline output (hence our grep matching "," or ")"
> after we see the newline, so we know we're at the end of the string).
>
> It's possible that one or more of these cases could intentionally be
> including a blank line at the end, but having looked at them all
> manually, I think these are all just mistakes.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> I just happened to notice one of these, so I grepped for more.
Just like what a good developer would do ;-)  Thanks.

I am a bit surprised (and feel somewhat relieved) that no tests try to match the messages exactly (with test_cmp, not with test_grep).

Previous: Jeff King
Message 4 of 4 in “drop trailing newline from warning/error/die messages”
  1. drop trailing newline from warning/error/die messagesJeff King, Sep 5, 2024
  2. Patrick SteinhardtSep 5, 2024
  3. Jeff KingSep 6, 2024
  4. Junio C HamanoSep 5, 2024

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.