git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Phil Haack <phil@github.com>, Emeric Fermas <emeric.fermas@gmail.com>
Subject: [PATCH 4/3] clone: send diagnostic messages to stderr
Date: Sat, 26 May 2012 00:11:35 -0400	[thread overview]
Message-ID: <20120526041135.GA28957@sigill.intra.peff.net> (raw)
In-Reply-To: <20120526034226.GA14287@sigill.intra.peff.net>

Putting messages like "Cloning into.." and "done" on stdout
is un-Unix and uselessly clutters the stdout channel. Send
them to stderr.

We have to tweak two tests to accommodate this:

  1. t5601 checks for doubled output due to forking, and
     doesn't actually care where the output goes; adjust it
     to check stderr.

  2. t5702 is trying to test whether progress output was
     sent to stderr, but naively does so by checking
     whether stderr produced any output. Instead, have it
     look for "%", a token found in progress output but not
     elsewhere (and which lets us avoid hard-coding the
     progress text in the test).

Signed-off-by: Jeff King <peff@peff.net>
---
This one isn't really related to the other patches in the series, but
while we're on the subject of extremely minor git-clone annoyances, I
thought I'd throw it in as a bonus round.

Arguably the test in t5601 should just go away entirely. stderr tends to
be line-buffered anyway, so the thing it is testing for wouldn't happen.
Not to mention that according to 2c3766f, which introduced it, the
problem was due to start_async() not flushing output before forking.
But we long ago switched start_async to use pthreads, so the bug it is
testing for wouldn't even be detectable on any modern platform.

 builtin/clone.c          | 6 +++---
 t/t5601-clone.sh         | 2 +-
 t/t5702-clone-options.sh | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index d004abb..08470ed 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -371,7 +371,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)
 	}
 
 	if (0 <= option_verbosity)
-		printf(_("done.\n"));
+		fprintf(stderr, _("done.\n"));
 }
 
 static const char *junk_work_tree;
@@ -751,9 +751,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
 
 	if (0 <= option_verbosity) {
 		if (option_bare)
-			printf(_("Cloning into bare repository '%s'...\n"), dir);
+			fprintf(stderr, _("Cloning into bare repository '%s'...\n"), dir);
 		else
-			printf(_("Cloning into '%s'...\n"), dir);
+			fprintf(stderr, _("Cloning into '%s'...\n"), dir);
 	}
 	init_db(option_template, INIT_DB_QUIET);
 	write_config(&option_config);
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 67869b4..aa9f991 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -36,7 +36,7 @@ test_expect_success 'clone with excess parameters (2)' '
 
 test_expect_success C_LOCALE_OUTPUT 'output from clone' '
 	rm -fr dst &&
-	git clone -n "file://$(pwd)/src" dst >output &&
+	git clone -n "file://$(pwd)/src" dst >output 2>&1 &&
 	test $(grep Clon output | wc -l) = 1
 '
 
diff --git a/t/t5702-clone-options.sh b/t/t5702-clone-options.sh
index 02cb024..67e170e 100755
--- a/t/t5702-clone-options.sh
+++ b/t/t5702-clone-options.sh
@@ -22,14 +22,14 @@ test_expect_success 'clone -o' '
 test_expect_success 'redirected clone' '
 
 	git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
-	test ! -s err
+	! grep % err
 
 '
 test_expect_success 'redirected clone -v' '
 
 	git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
 		>out 2>err &&
-	test -s err
+	grep % err
 
 '
 
-- 
1.7.10.1.21.g62fda49.dirty

  parent reply	other threads:[~2012-05-26  4:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-26  3:42 [PATCH 0/3] clone --local fixes Jeff King
2012-05-26  3:42 ` [PATCH 1/3] t5701: modernize style Jeff King
2012-05-26  3:45 ` [PATCH 2/3] clone: make --local handle URLs Jeff King
2012-05-28 18:31   ` Johannes Sixt
2012-05-28 19:10     ` Jeff King
2012-05-26  3:45 ` [PATCH 3/3] clone: allow --no-local to turn off local optimizations Jeff King
2012-05-26  4:11 ` Jeff King [this message]
2012-05-27  6:32 ` [PATCH 0/3] clone --local fixes Junio C Hamano
2012-05-28  5:36   ` Jeff King
2012-05-29 17:43     ` Junio C Hamano
2012-05-30 11:03       ` Jeff King
2012-05-30 11:08         ` Jeff King
2012-05-30 11:09         ` [PATCH 1/2] docs/clone: mention that --local may be ignored Jeff King
2012-05-30 11:10         ` [PATCH 2/2] clone: allow --no-local to turn off local optimizations Jeff King
2012-05-30 17:20           ` Junio C Hamano
2012-05-30 21:59             ` Jeff King
2012-05-30 22:10               ` Junio C Hamano
2012-05-30 23:21                 ` Jeff King
2012-05-30 23:33                   ` Junio C Hamano

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=20120526041135.GA28957@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=emeric.fermas@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phil@github.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).