aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@frugalware.org>2008-10-09 01:40:32 +0200
committerShawn O. Pearce <spearce@spearce.org>2008-10-09 11:26:17 -0700
commit21188b1eafd3741fda0f7905dc997279a17b50ba (patch)
tree68bbf5f02d00fd354efd097fff73ec09f4d9c4b6
parent23abd3f48cb217d1558fa1984bfa8c502717c08f (diff)
downloadgit-21188b1eafd3741fda0f7905dc997279a17b50ba.tar.gz
git-21188b1eafd3741fda0f7905dc997279a17b50ba.tar.xz
Implement git clone -v
The new -v option forces the progressbar, even in case the output is not a terminal. This can be useful if the caller is an IDE or wrapper which wants to scrape the progressbar from stderr and show its information in a different format. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r--Documentation/git-clone.txt5
-rw-r--r--builtin-clone.c4
-rwxr-xr-xt/t5702-clone-options.sh13
-rw-r--r--transport.c2
-rw-r--r--transport.h2
5 files changed, 25 insertions, 1 deletions
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 0e14e732f..95f08b911 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -90,6 +90,11 @@ then the cloned repository will become corrupt.
Operate quietly. This flag is also passed to the `rsync'
command when given.
+--verbose::
+-v::
+ Display the progressbar, even in case the standard output is not
+ a terminal.
+
--no-checkout::
-n::
No checkout of HEAD is performed after the clone is complete.
diff --git a/builtin-clone.c b/builtin-clone.c
index 49d2eb9c2..df71b2381 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -38,9 +38,11 @@ static int option_local, option_no_hardlinks, option_shared;
static char *option_template, *option_reference, *option_depth;
static char *option_origin = NULL;
static char *option_upload_pack = "git-upload-pack";
+static int option_verbose;
static struct option builtin_clone_options[] = {
OPT__QUIET(&option_quiet),
+ OPT__VERBOSE(&option_verbose),
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
"don't create a checkout"),
OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),
@@ -506,6 +508,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (option_quiet)
transport->verbose = -1;
+ else if (option_verbose)
+ transport->progress = 1;
if (option_upload_pack)
transport_set_option(transport, TRANS_OPT_UPLOADPACK,
diff --git a/t/t5702-clone-options.sh b/t/t5702-clone-options.sh
index 328e4d9a3..27825f5f3 100755
--- a/t/t5702-clone-options.sh
+++ b/t/t5702-clone-options.sh
@@ -19,4 +19,17 @@ test_expect_success 'clone -o' '
'
+test_expect_success 'redirected clone' '
+
+ git clone "file://$(pwd)/parent" clone-redirected >out 2>err &&
+ test ! -s err
+
+'
+test_expect_success 'redirected clone -v' '
+
+ git clone -v "file://$(pwd)/parent" clone-redirected-v >out 2>err &&
+ test -s err
+
+'
+
test_done
diff --git a/transport.c b/transport.c
index 5110c56c4..1c510a336 100644
--- a/transport.c
+++ b/transport.c
@@ -644,7 +644,7 @@ static int fetch_refs_via_pack(struct transport *transport,
args.include_tag = data->followtags;
args.verbose = (transport->verbose > 0);
args.quiet = (transport->verbose < 0);
- args.no_progress = args.quiet || !isatty(1);
+ args.no_progress = args.quiet || (!transport->progress && !isatty(1));
args.depth = data->depth;
for (i = 0; i < nr_heads; i++)
diff --git a/transport.h b/transport.h
index d0b52053f..6bbc1a826 100644
--- a/transport.h
+++ b/transport.h
@@ -25,6 +25,8 @@ struct transport {
int (*disconnect)(struct transport *connection);
char *pack_lockfile;
signed verbose : 2;
+ /* Force progress even if the output is not a tty */
+ unsigned progress : 1;
};
#define TRANSPORT_PUSH_ALL 1