git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Implement git clone -v

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Oct 6, 2008, 22:19 UTC
Message-ID
<1223331590-22138-1-git-send-email-vmiklos@frugalware.org>
In-Reply-To
<81b0412b0810041442i3aa29628lf66ef9b188fe8ce7@mail.gmail.com>

The new -v option forces the progressbar, even in case the output is not a terminal.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
On Sat, Oct 04, 2008 at 11:42:15PM +0200, Alex Riesen <raa.lkml@gmail.com> wrote:
Show 6 quoted lines
> 2008/10/3 Constantine Plotnikov <constantine.plotnikov@gmail.com>:
> > Is there a way to force a progress output on stderr for git clone
> > preferably using options or environment variables?
>
> No, but "-v" option is not used for anything yet, so you are free to
> implement it.
Something like this?
 Documentation/git-clone.txt |    5 +++++
 builtin-clone.c             |    4 ++++
 transport.c                 |    2 +-
 transport.h                 |    2 ++
 4 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 0e14e73..95f08b9 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 49d2eb9..df71b23 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/transport.c b/transport.c
index 5110c56..1c510a3 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 d0b5205..6bbc1a8 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
-- 
1.6.0.2
Previous: Alex RiesenNext: Alex Riesen
Message 3 of 11 in “Forcing progerss output for clone”
  1. Constantine PlotnikovOct 3, 2008
  2. Alex RiesenOct 4, 2008
  3. Implement git clone -vMiklos Vajna, Oct 6, 2008
  4. Alex RiesenOct 7, 2008
  5. Miklos VajnaOct 7, 2008
  6. Shawn O. PearceOct 8, 2008
  7. Alex RiesenOct 8, 2008
  8. Implement git clone -vMiklos Vajna, Oct 8, 2008
  9. Junio C HamanoOct 9, 2008
  10. Shawn O. PearceOct 9, 2008
  11. Miklos VajnaOct 9, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.