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 <gitster@pobox.com>
Junio C Hamano committed
Mar 29, 2024 at 15:57 UTC
2d8cf94b28de9da683ddd40961a3a572f2741cf3
3 files changed
+6
-5
advice.c
+2
-1
@@ -104,8 +104,9 @@ static void vadvise(const char *advice, int display_instructions,
104
105
for (cp = buf.buf; *cp; cp = np) {
106
np = strchrnul(cp, '\n');
107
- fprintf(stderr, _("%shint: %.*s%s\n"),
107
+ fprintf(stderr, _("%shint:%s%.*s%s\n"),
108
advise_get_color(ADVICE_COLOR_HINT),
109
+ (np == cp) ? "" : " ",
110
(int)(np - cp), cp,
111
advise_get_color(ADVICE_COLOR_RESET));
112
if (*np)
t/t3200-branch.sh
+2
-2
@@ -1154,9 +1154,9 @@ test_expect_success 'avoid ambiguous track and advise' '
1154
hint: tracking ref '\''refs/heads/main'\'':
1155
hint: ambi1
1156
hint: ambi2
1157
- hint: ''
1157
+ hint:
1158
hint: This is typically a configuration error.
1159
- hint: ''
1159
+ hint:
1160
hint: To support setting up tracking branches, ensure that
1161
hint: different remotes'\'' fetch refspecs map into different
1162
hint: tracking namespaces.
t/t7004-tag.sh
+2
-2
@@ -1777,10 +1777,10 @@ test_expect_success '--points-at finds annotated tags of tags' '
1777
'
1778
1779
test_expect_success 'recursive tagging should give advice' '
1780
- sed -e "s/|$//" <<-EOF >expect &&
1780
+ cat >expect <<-EOF &&
1781
hint: You have created a nested tag. The object referred to by your new tag is
1782
hint: already a tag. If you meant to tag the object that it points to, use:
1783
- hint: |
1783
+ hint:
1784
hint: git tag -f nested annotated-v4.0^{}
1785
hint: Disable this message with "git config advice.nestedTag false"
1786
EOF