git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Ben Boeckel" <mathstuf@gmail.com>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Heba Waly" <heba.waly@gmail.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH 2/5] advice output: emit empty lines as "hint:", not "hint: "
Date: Mon,  4 Oct 2021 03:58:21 +0200	[thread overview]
Message-ID: <patch-2.5-5b5754ebfd2-20211004T015432Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.5-00000000000-20211004T015432Z-avarab@gmail.com>

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(-)

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


  parent reply	other threads:[~2021-10-04  1:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-04  1:58 [PATCH 0/5] advice API: simplification, small fixes, readability Ævar Arnfjörð Bjarmason
2021-10-04  1:58 ` [PATCH 1/5] advice.h: don't indent top-level enum Ævar Arnfjörð Bjarmason
2021-10-04  1:58 ` Ævar Arnfjörð Bjarmason [this message]
2021-10-04  1:58 ` [PATCH 3/5] advice.[ch]: remove advice.pushNonFastForward alias Ævar Arnfjörð Bjarmason
2021-10-04  1:58 ` [PATCH 4/5] advice API: revamp the API, again Ævar Arnfjörð Bjarmason
2021-10-04  1:58 ` [PATCH 5/5] advice.[ch]: sort enum fields in alphabetical order Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=patch-2.5-5b5754ebfd2-20211004T015432Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=heba.waly@gmail.com \
    --cc=mathstuf@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).