Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 68b939b

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e230c56 commit 68b939b

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

builtin/clone.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void clone_local(const char *src_repo, const char *dest_repo)
380380
}
381381

382382
if (0 <= option_verbosity)
383-
printf(_("done.\n"));
383+
fprintf(stderr, _("done.\n"));
384384
}
385385

386386
static const char *junk_work_tree;
@@ -552,12 +552,12 @@ static void update_remote_refs(const struct ref *refs,
552552

553553
if (check_connectivity) {
554554
if (0 <= option_verbosity)
555-
printf(_("Checking connectivity... "));
555+
fprintf(stderr, _("Checking connectivity... "));
556556
if (check_everything_connected_with_transport(iterate_ref_map,
557557
0, &rm, transport))
558558
die(_("remote did not send all necessary objects"));
559559
if (0 <= option_verbosity)
560-
printf(_("done\n"));
560+
fprintf(stderr, _("done\n"));
561561
}
562562

563563
if (refs) {
@@ -850,9 +850,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
850850

851851
if (0 <= option_verbosity) {
852852
if (option_bare)
853-
printf(_("Cloning into bare repository '%s'...\n"), dir);
853+
fprintf(stderr, _("Cloning into bare repository '%s'...\n"), dir);
854854
else
855-
printf(_("Cloning into '%s'...\n"), dir);
855+
fprintf(stderr, _("Cloning into '%s'...\n"), dir);
856856
}
857857
init_db(option_template, INIT_DB_QUIET);
858858
write_config(&option_config);

t/t5601-clone.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test_expect_success 'clone with excess parameters (2)' '
3636

3737
test_expect_success C_LOCALE_OUTPUT 'output from clone' '
3838
rm -fr dst &&
39-
git clone -n "file://$(pwd)/src" dst >output &&
39+
git clone -n "file://$(pwd)/src" dst >output 2>&1 &&
4040
test $(grep Clon output | wc -l) = 1
4141
'
4242

t/t5702-clone-options.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ test_expect_success 'clone -o' '
1919
2020
'
2121

22-
test_expect_success 'redirected clone' '
22+
test_expect_success 'redirected clone does not show progress' '
2323
2424
git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
25-
test_must_be_empty err
25+
! grep % err
2626
2727
'
28-
test_expect_success 'redirected clone -v' '
28+
29+
test_expect_success 'redirected clone -v does show progress' '
2930
3031
git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
3132
>out 2>err &&
32-
test -s err
33+
grep % err
3334
3435
'
3536

0 commit comments

Comments
 (0)