Let's not needlessly add this trailing whitespace to empty "hint:" lines, this makes copy/pasting them better, and also makes the tests more straightforward. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> --- advice.c | 9 +++++++-- t/t7004-tag.sh | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/advice.c b/advice.c index 2f5499a5e18..9691c7e7899 100644 --- a/advice.c +++ b/advice.c @@ -90,10 +90,15 @@ static void vadvise(const char *advice, int display_instructions, strbuf_addf(&buf, turn_off_instructions, key); for (cp = buf.buf; *cp; cp = np) { + int len; + np = strchrnul(cp, '\n'); - fprintf(stderr, _("%shint: %.*s%s\n"), + len = np - cp; + + fprintf(stderr, _("%shint:%s%.*s%s\n"), advise_get_color(ADVICE_COLOR_HINT), - (int)(np - cp), cp, + len ? " " : "", + len, cp, advise_get_color(ADVICE_COLOR_RESET)); if (*np) np++; diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 082be85dffc..a7041e64ccf 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -1749,10 +1749,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 <<-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 -- 2.33.0.1404.g7bcfc82b295