clone: send diagnostic messages to stderr

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). This should not regress any scripts that try to parse the current output, as the output is already internationalized and therefore unstable. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 18, 2013 at 16:05 UTC 68b939b2f097b6675c4aaa178655559aa81b25cb
3 files changed +11 -10
builtin/clone.c
+5 -5
@@ -380,7 +380,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)
380 }
381
382 if (0 <= option_verbosity)
383 - printf(_("done.\n"));
383 + fprintf(stderr, _("done.\n"));
384 }
385
386 static const char *junk_work_tree;
@@ -552,12 +552,12 @@ static void update_remote_refs(const struct ref *refs,
552
553 if (check_connectivity) {
554 if (0 <= option_verbosity)
555 - printf(_("Checking connectivity... "));
555 + fprintf(stderr, _("Checking connectivity... "));
556 if (check_everything_connected_with_transport(iterate_ref_map,
557 0, &rm, transport))
558 die(_("remote did not send all necessary objects"));
559 if (0 <= option_verbosity)
560 - printf(_("done\n"));
560 + fprintf(stderr, _("done\n"));
561 }
562
563 if (refs) {
@@ -850,9 +850,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
850
851 if (0 <= option_verbosity) {
852 if (option_bare)
853 - printf(_("Cloning into bare repository '%s'...\n"), dir);
853 + fprintf(stderr, _("Cloning into bare repository '%s'...\n"), dir);
854 else
855 - printf(_("Cloning into '%s'...\n"), dir);
855 + fprintf(stderr, _("Cloning into '%s'...\n"), dir);
856 }
857 init_db(option_template, INIT_DB_QUIET);
858 write_config(&option_config);
t/t5601-clone.sh
+1 -1
@@ -36,7 +36,7 @@ test_expect_success 'clone with excess parameters (2)' '
36
37 test_expect_success C_LOCALE_OUTPUT 'output from clone' '
38 rm -fr dst &&
39 - git clone -n "file://$(pwd)/src" dst >output &&
39 + git clone -n "file://$(pwd)/src" dst >output 2>&1 &&
40 test $(grep Clon output | wc -l) = 1
41 '
42
t/t5702-clone-options.sh
+5 -4
@@ -19,17 +19,18 @@ test_expect_success 'clone -o' '
19
20 '
21
22 -test_expect_success 'redirected clone' '
22 +test_expect_success 'redirected clone does not show progress' '
23
24 git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
25 - test_must_be_empty err
25 + ! grep % err
26
27 '
28 -test_expect_success 'redirected clone -v' '
28 +
29 +test_expect_success 'redirected clone -v does show progress' '
30
31 git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
32 >out 2>err &&
32 - test -s err
33 + grep % err
34
35 '
36