]> git.ipfire.org Git - thirdparty/git.git/commitdiff
advice: omit trailing whitespace
authorJunio C Hamano <gitster@pobox.com>
Fri, 29 Mar 2024 22:57:06 +0000 (15:57 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 29 Mar 2024 23:18:48 +0000 (16:18 -0700)
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>
advice.c
t/t3200-branch.sh
t/t7004-tag.sh

index b0e05506871b9c402b75ad7ba52c47776797611d..a18bfe776f609d6340d9620c32ff5cdbef81d341 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -104,8 +104,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)
index d3bbd00b818a4f26e2c19ae0ec432138200afc62..ccfa6a720d090c2f7f2a085f60065bdcfaf8d1d9 100755 (executable)
@@ -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.
index b41a47eb943a03b1588bdc87802b0645944ce2ec..696866d7794e1fdd72760ed093b9ff9737d97969 100755 (executable)
@@ -1777,10 +1777,10 @@ test_expect_success '--points-at finds annotated tags of tags' '
 '
 
 test_expect_success 'recursive tagging should give advice' '
-       sed -e "s/|$//" <<-EOF >expect &&
+       cat >expect <<-EOF &&
        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