Skip to content

Commit adcb2e0

Browse files
committed
Merge branch 'mv/clonev'
* mv/clonev: Implement git clone -v
2 parents 449acfa + 21188b1 commit adcb2e0

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

Documentation/git-clone.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ then the cloned repository will become corrupt.
9090
Operate quietly. This flag is also passed to the `rsync'
9191
command when given.
9292

93+
--verbose::
94+
-v::
95+
Display the progressbar, even in case the standard output is not
96+
a terminal.
97+
9398
--no-checkout::
9499
-n::
95100
No checkout of HEAD is performed after the clone is complete.

builtin-clone.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ static int option_local, option_no_hardlinks, option_shared;
3838
static char *option_template, *option_reference, *option_depth;
3939
static char *option_origin = NULL;
4040
static char *option_upload_pack = "git-upload-pack";
41+
static int option_verbose;
4142

4243
static struct option builtin_clone_options[] = {
4344
OPT__QUIET(&option_quiet),
45+
OPT__VERBOSE(&option_verbose),
4446
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
4547
"don't create a checkout"),
4648
OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),
@@ -504,6 +506,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
504506

505507
if (option_quiet)
506508
transport->verbose = -1;
509+
else if (option_verbose)
510+
transport->progress = 1;
507511

508512
if (option_upload_pack)
509513
transport_set_option(transport, TRANS_OPT_UPLOADPACK,

t/t5702-clone-options.sh

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

22+
test_expect_success 'redirected clone' '
23+
24+
git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
25+
test ! -s err
26+
27+
'
28+
test_expect_success 'redirected clone -v' '
29+
30+
git clone -v "file://$(pwd)/parent" clone-redirected-v >out 2>err &&
31+
test -s err
32+
33+
'
34+
2235
test_done

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ static int fetch_refs_via_pack(struct transport *transport,
644644
args.include_tag = data->followtags;
645645
args.verbose = (transport->verbose > 0);
646646
args.quiet = (transport->verbose < 0);
647-
args.no_progress = args.quiet || !isatty(1);
647+
args.no_progress = args.quiet || (!transport->progress && !isatty(1));
648648
args.depth = data->depth;
649649

650650
for (i = 0; i < nr_heads; i++)

transport.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct transport {
2525
int (*disconnect)(struct transport *connection);
2626
char *pack_lockfile;
2727
signed verbose : 2;
28+
/* Force progress even if the output is not a tty */
29+
unsigned progress : 1;
2830
};
2931

3032
#define TRANSPORT_PUSH_ALL 1

0 commit comments

Comments
 (0)