Skip to content

Commit df1ef91

Browse files
committed
Merge branch 'jk/clone-progress-to-stderr' into maint
"git clone" gave some progress messages to the standard output, not to the standard error, and did not allow suppressing them with the "--no-progress" option. * jk/clone-progress-to-stderr: clone: always set transport options clone: treat "checking connectivity" like other progress clone: send diagnostic messages to stderr
2 parents da212ea + 643f918 commit df1ef91

File tree

4 files changed

+32
-28
lines changed

4 files changed

+32
-28
lines changed

builtin/clone.c

Lines changed: 21 additions & 23 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;
@@ -551,13 +551,13 @@ static void update_remote_refs(const struct ref *refs,
551551
const struct ref *rm = mapped_refs;
552552

553553
if (check_connectivity) {
554-
if (0 <= option_verbosity)
555-
printf(_("Checking connectivity... "));
554+
if (transport->progress)
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"));
559-
if (0 <= option_verbosity)
560-
printf(_("done\n"));
559+
if (transport->progress)
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);
@@ -885,27 +885,25 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
885885
remote = remote_get(option_origin);
886886
transport = transport_get(remote, remote->url[0]);
887887

888-
if (!is_local) {
889-
if (!transport->get_refs_list || !transport->fetch)
890-
die(_("Don't know how to clone %s"), transport->url);
888+
if (!transport->get_refs_list || (!is_local && !transport->fetch))
889+
die(_("Don't know how to clone %s"), transport->url);
891890

892-
transport_set_option(transport, TRANS_OPT_KEEP, "yes");
891+
transport_set_option(transport, TRANS_OPT_KEEP, "yes");
893892

894-
if (option_depth)
895-
transport_set_option(transport, TRANS_OPT_DEPTH,
896-
option_depth);
897-
if (option_single_branch)
898-
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
893+
if (option_depth)
894+
transport_set_option(transport, TRANS_OPT_DEPTH,
895+
option_depth);
896+
if (option_single_branch)
897+
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
899898

900-
transport_set_verbosity(transport, option_verbosity, option_progress);
899+
transport_set_verbosity(transport, option_verbosity, option_progress);
901900

902-
if (option_upload_pack)
903-
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
904-
option_upload_pack);
901+
if (option_upload_pack)
902+
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
903+
option_upload_pack);
905904

906-
if (transport->smart_options && !option_depth)
907-
transport->smart_options->check_self_contained_and_connected = 1;
908-
}
905+
if (transport->smart_options && !option_depth)
906+
transport->smart_options->check_self_contained_and_connected = 1;
909907

910908
refs = transport_get_remote_refs(transport);
911909

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/t5701-clone-local.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,8 @@ test_expect_success 'cloning a local path with --no-local does not hardlink' '
134134
! repo_is_hardlinked force-nonlocal
135135
'
136136

137+
test_expect_success 'cloning locally respects "-u" for fetching refs' '
138+
test_must_fail git clone --bare -u false a should_not_work.git
139+
'
140+
137141
test_done

t/t5702-clone-options.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,19 @@ 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 &&
26+
test_i18ngrep ! "Checking connectivity" err
2627
2728
'
28-
test_expect_success 'redirected clone -v' '
29+
30+
test_expect_success 'redirected clone -v does show progress' '
2931
3032
git clone --progress "file://$(pwd)/parent" clone-redirected-progress \
3133
>out 2>err &&
32-
test -s err
34+
grep % err
3335
3436
'
3537

0 commit comments

Comments
 (0)