clone: send diagnostic messages to stderr
authorJeff King <peff@peff.net>
Wed, 18 Sep 2013 20:05:13 +0000 (16:05 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 Sep 2013 20:34:12 +0000 (13:34 -0700)
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>
builtin/clone.c
t/t5601-clone.sh
t/t5702-clone-options.sh
index 430307b298b4f9ea03ff4caea283b133fde0077e..42c40f2bfdef5f8c322e550eac81c3ac4dcc0384 100644 (file)
@@ -380,7 +380,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;
@@ -552,12 +552,12 @@ static void update_remote_refs(const struct ref *refs,
 
        if (check_connectivity) {
                if (0 <= option_verbosity)
-                       printf(_("Checking connectivity... "));
+                       fprintf(stderr, _("Checking connectivity... "));
                if (check_everything_connected_with_transport(iterate_ref_map,
                                                              0, &rm, transport))
                        die(_("remote did not send all necessary objects"));
                if (0 <= option_verbosity)
-                       printf(_("done\n"));
+                       fprintf(stderr, _("done\n"));
        }
 
        if (refs) {
@@ -850,9 +850,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);
index 0629149eddcff4e6e724ab82479504deda141141..b3b11e61c03e5d6d3e49a6f2d4a2281f05a7a600 100755 (executable)
@@ -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
 '
 
index 85cadfad6d8aeee79e0f05530376ca7dc6f085f0..d3dbdfe0699c4ad590263d157ad22d7bfed6b8f5 100755 (executable)
@@ -19,17 +19,18 @@ test_expect_success 'clone -o' '
 
 '
 
-test_expect_success 'redirected clone' '
+test_expect_success 'redirected clone does not show progress' '
 
        git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
-       test_must_be_empty err
+       ! grep % err
 
 '
-test_expect_success 'redirected clone -v' '
+
+test_expect_success 'redirected clone -v does show progress' '
 
        git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
                >out 2>err &&
-       test -s err
+       grep % err
 
 '