Skip to content

Commit 2d8cf94

Browse files
committed
advice: omit trailing whitespace
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 <[email protected]>
1 parent d6fd043 commit 2d8cf94

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

advice.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ static void vadvise(const char *advice, int display_instructions,
104104

105105
for (cp = buf.buf; *cp; cp = np) {
106106
np = strchrnul(cp, '\n');
107-
fprintf(stderr, _("%shint: %.*s%s\n"),
107+
fprintf(stderr, _("%shint:%s%.*s%s\n"),
108108
advise_get_color(ADVICE_COLOR_HINT),
109+
(np == cp) ? "" : " ",
109110
(int)(np - cp), cp,
110111
advise_get_color(ADVICE_COLOR_RESET));
111112
if (*np)

t/t3200-branch.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,9 @@ test_expect_success 'avoid ambiguous track and advise' '
11541154
hint: tracking ref '\''refs/heads/main'\'':
11551155
hint: ambi1
11561156
hint: ambi2
1157-
hint: ''
1157+
hint:
11581158
hint: This is typically a configuration error.
1159-
hint: ''
1159+
hint:
11601160
hint: To support setting up tracking branches, ensure that
11611161
hint: different remotes'\'' fetch refspecs map into different
11621162
hint: tracking namespaces.

t/t7004-tag.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,10 +1777,10 @@ test_expect_success '--points-at finds annotated tags of tags' '
17771777
'
17781778

17791779
test_expect_success 'recursive tagging should give advice' '
1780-
sed -e "s/|$//" <<-EOF >expect &&
1780+
cat >expect <<-EOF &&
17811781
hint: You have created a nested tag. The object referred to by your new tag is
17821782
hint: already a tag. If you meant to tag the object that it points to, use:
1783-
hint: |
1783+
hint:
17841784
hint: git tag -f nested annotated-v4.0^{}
17851785
hint: Disable this message with "git config advice.nestedTag false"
17861786
EOF

0 commit comments

Comments
 (0)