Skip to content

Commit

Permalink
Merge branch 'jk/clone-progress-to-stderr' into maint
Browse files Browse the repository at this point in the history
"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
  • Loading branch information
Junio C Hamano committed Oct 28, 2013
2 parents da212ea + 643f918 commit df1ef91
Showing 4 changed files with 32 additions and 28 deletions.
44 changes: 21 additions & 23 deletions builtin/clone.c
Original file line number Diff line number Diff line change
@@ -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;
@@ -551,13 +551,13 @@ static void update_remote_refs(const struct ref *refs,
const struct ref *rm = mapped_refs;

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

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

transport_set_option(transport, TRANS_OPT_KEEP, "yes");
transport_set_option(transport, TRANS_OPT_KEEP, "yes");

if (option_depth)
transport_set_option(transport, TRANS_OPT_DEPTH,
option_depth);
if (option_single_branch)
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");
if (option_depth)
transport_set_option(transport, TRANS_OPT_DEPTH,
option_depth);
if (option_single_branch)
transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, "1");

transport_set_verbosity(transport, option_verbosity, option_progress);
transport_set_verbosity(transport, option_verbosity, option_progress);

if (option_upload_pack)
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
option_upload_pack);
if (option_upload_pack)
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
option_upload_pack);

if (transport->smart_options && !option_depth)
transport->smart_options->check_self_contained_and_connected = 1;
}
if (transport->smart_options && !option_depth)
transport->smart_options->check_self_contained_and_connected = 1;

refs = transport_get_remote_refs(transport);

2 changes: 1 addition & 1 deletion t/t5601-clone.sh
Original file line number Diff line number Diff line change
@@ -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
'

4 changes: 4 additions & 0 deletions t/t5701-clone-local.sh
Original file line number Diff line number Diff line change
@@ -134,4 +134,8 @@ test_expect_success 'cloning a local path with --no-local does not hardlink' '
! repo_is_hardlinked force-nonlocal
'

test_expect_success 'cloning locally respects "-u" for fetching refs' '
test_must_fail git clone --bare -u false a should_not_work.git
'

test_done
10 changes: 6 additions & 4 deletions t/t5702-clone-options.sh
Original file line number Diff line number Diff line change
@@ -19,17 +19,19 @@ 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_i18ngrep ! "Checking connectivity" 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
'

0 comments on commit df1ef91

Please sign in to comment.