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

Re: [PATCH] advice: omit trailing whitespace

From
Rubén Justo <rjusto@gmail.com>
Date
Mar 29, 2024, 23:23 UTC
Message-ID
<fc002d62-6efe-42d4-b562-c10d3419fff6@gmail.com>
In-Reply-To
<xmqq4jcooddp.fsf@gitster.g>
On Fri, Mar 29, 2024 at 03:57:06PM -0700, Junio C Hamano wrote:
Show 13 quoted lines
> Git tools all consistently encourage users to avoid whitespaces at
> the end of line by giving them features like "git diff --check" and
> "git am --whitespace=fix".  Make sure that the advice messages we
> give users avoid trailing whitespaces.  We shouldn't be wasting
> vertical screen real estate by adding blank lines in advice messages
> that are supposed to be concise hints, but as long as we write such
> blank line in our "hints", we should do it right.
> 
> A test that expects the current behaviour of leaving trailing
> whitespaces has been adjusted.
> 
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---

Yeah, ACK. This is obviously a good thing. I'll base my other series in this. Thanks.

Show 35 quoted lines
>  advice.c          | 3 ++-
>  t/t3200-branch.sh | 4 ++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git c/advice.c w/advice.c
> index d19648b7f8..75111191ad 100644
> --- c/advice.c
> +++ w/advice.c
> @@ -105,8 +105,9 @@ static void vadvise(const char *advice, int display_instructions,
>  
>  	for (cp = buf.buf; *cp; cp = np) {
>  		np = strchrnul(cp, '\n');
> -		fprintf(stderr,	_("%shint: %.*s%s\n"),
> +		fprintf(stderr,	_("%shint:%s%.*s%s\n"),
>  			advise_get_color(ADVICE_COLOR_HINT),
> +			(np == cp) ? "" : " ",
>  			(int)(np - cp), cp,
>  			advise_get_color(ADVICE_COLOR_RESET));
>  		if (*np)
> diff --git c/t/t3200-branch.sh w/t/t3200-branch.sh
> index d3bbd00b81..ccfa6a720d 100755
> --- c/t/t3200-branch.sh
> +++ w/t/t3200-branch.sh
> @@ -1154,9 +1154,9 @@ test_expect_success 'avoid ambiguous track and advise' '
>  	hint: tracking ref '\''refs/heads/main'\'':
>  	hint:   ambi1
>  	hint:   ambi2
> -	hint: ''
> +	hint:
>  	hint: This is typically a configuration error.
> -	hint: ''
> +	hint:
>  	hint: To support setting up tracking branches, ensure that
>  	hint: different remotes'\'' fetch refspecs map into different
>  	hint: tracking namespaces.
A quick run tells me that this step also needs, I think:
--- >8 ---
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index b41a47eb94..03bb4af7d6 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -1780,7 +1780,7 @@ test_expect_success 'recursive tagging should give advice' '
        sed -e "s/|$//" <<-EOF >expect &&
        hint: You have created a nested tag. The object referred to by your new tag is
        hint: already a tag. If you meant to tag the object that it points to, use:
-       hint: |
+       hint:
        hint:   git tag -f nested annotated-v4.0^{}
        hint: Disable this message with "git config advice.nestedTag false"
        EOF
Previous: Junio C HamanoNext: Rubén Justo
Message 2 of 9 in “advice: omit trailing whitespace”
  1. advice: omit trailing whitespaceJunio C Hamano, Mar 29, 2024
  2. Rubén JustoMar 29, 2024
  3. Rubén JustoMar 31, 2024
  4. Junio C HamanoMar 31, 2024
  5. Rubén JustoMar 31, 2024
  6. Rubén JustoMar 31, 2024
  7. Junio C HamanoMar 31, 2024
  8. Rubén JustoApr 1, 2024
  9. Dragan SimicMar 29, 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.