@@ -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++;
@@ -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
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@gmail.com> --- advice.c | 9 +++++++-- t/t7004-tag.sh | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-)