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

Re: [PATCH] gpg-interface: fix strip_cr_before_lf to only remove CR before LF

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 24, 2026, 16:58 UTC
Message-ID
<xmqqfr2bkh8u.fsf@gitster.g>
In-Reply-To
<20260624093618.17456-1-antonio.destefani08@gmail.com>
Antonio De Stefani <antonio.destefani08@gmail.com> writes:
Show 23 quoted lines
> c4adea82 (Convert CR/LF to LF in tag signatures, 2008-07-11)
> introduced CR stripping for GPG output on Windows, but intentionally
> stripped all CR characters unconditionally to "keep the code simpler",
> even though only \r\n sequences (Windows line endings) needed to be
> normalized. 2f47eae2 (Split GPG interface into its own helper library,
> 2011-09-07) moved the code into gpg-interface.c, and 29b31577 (ssh
> signing: add ssh key format and signing code, 2021-09-10) extracted
> it into the remove_cr_after() helper when adding SSH signing support.
>
> The original laziness was safe at the time because lone CR characters
> are not expected in GPG signature output. However, the NEEDSWORK
> comment left by a previous reader correctly identified that only
> \r\n pairs should be stripped, not lone \r characters.
>
> Fix the loop to skip \r only when immediately followed by \n, keeping
> lone trailing CR characters intact. Rename the function to
> strip_cr_before_lf to reflect its corrected behavior, and update
> both call sites and their comments accordingly.
>
> Signed-off-by: Antonio De Stefani <antonio.destefani08@gmail.com>
> ---
>  gpg-interface.c | 25 +++++++++++--------------
>  1 file changed, 11 insertions(+), 14 deletions(-)
Looking good.  Will queue. Thanks.
Previous: Antonio De Stefani
Message 2 of 2 in “gpg-interface: fix strip_cr_before_lf to only remove CR before LF”
  1. gpg-interface: fix strip_cr_before_lf to only remove CR before LFAntonio De Stefani, Jun 24, 2026
  2. Junio C HamanoJun 24, 2026

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.