git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Forcing progerss output for clone
@ 2008-10-03 20:01 Constantine Plotnikov
  2008-10-04 21:42 ` Alex Riesen
  0 siblings, 1 reply; 11+ messages in thread
From: Constantine Plotnikov @ 2008-10-03 20:01 UTC (permalink / raw)
  To: git

Hello!

Is there a way to force a progress output on stderr for git clone
preferably using options or environment variables?

The clone command in the git 1.6.0.2 does not print a progress
information to stderr if stdout and stderr are redirected (even if no
"-q" option is specified).

Such information would have been useful for displaying progress
information when cloning from IDE. IDE run git with streams
redirected, and this progress information could have been displayed to
user to indicate current status of operation.

Best Regards,
Constantine

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Forcing progerss output for clone
  2008-10-03 20:01 Forcing progerss output for clone Constantine Plotnikov
@ 2008-10-04 21:42 ` Alex Riesen
  2008-10-06 22:19   ` [PATCH] Implement git clone -v Miklos Vajna
  0 siblings, 1 reply; 11+ messages in thread
From: Alex Riesen @ 2008-10-04 21:42 UTC (permalink / raw)
  To: Constantine Plotnikov; +Cc: git

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.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] Implement git clone -v
  2008-10-04 21:42 ` Alex Riesen
@ 2008-10-06 22:19   ` Miklos Vajna
  2008-10-07  6:21     ` Alex Riesen
  0 siblings, 1 reply; 11+ messages in thread
From: Miklos Vajna @ 2008-10-06 22:19 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Constantine Plotnikov, git

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:
> 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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] Implement git clone -v
  2008-10-06 22:19   ` [PATCH] Implement git clone -v Miklos Vajna
@ 2008-10-07  6:21     ` Alex Riesen
  2008-10-07 19:39       ` Miklos Vajna
  0 siblings, 1 reply; 11+ messages in thread
From: Alex Riesen @ 2008-10-07  6:21 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Constantine Plotnikov, git

2008/10/7 Miklos Vajna <vmiklos@frugalware.org>:
> 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:
>> 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?
>

Yes. Does it work? :)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Implement git clone -v
  2008-10-07  6:21     ` Alex Riesen
@ 2008-10-07 19:39       ` Miklos Vajna
  2008-10-08  6:02         ` Shawn O. Pearce
  0 siblings, 1 reply; 11+ messages in thread
From: Miklos Vajna @ 2008-10-07 19:39 UTC (permalink / raw)
  To: Alex Riesen; +Cc: Constantine Plotnikov, git

[-- Attachment #1: Type: text/plain, Size: 355 bytes --]

On Tue, Oct 07, 2008 at 08:21:28AM +0200, Alex Riesen <raa.lkml@gmail.com> wrote:
> Yes. Does it work? :)

Yes, it does. I'm not sure how to test it from the testsuite, maybe
redirect the output to a file and grep in it? It's ugly, that's why I
did not do so, but if you think a testcase is a musthave for this
feature then that's the way to go, I guess.

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Implement git clone -v
  2008-10-07 19:39       ` Miklos Vajna
@ 2008-10-08  6:02         ` Shawn O. Pearce
  2008-10-08  6:25           ` Alex Riesen
  2008-10-08 23:40           ` Miklos Vajna
  0 siblings, 2 replies; 11+ messages in thread
From: Shawn O. Pearce @ 2008-10-08  6:02 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Alex Riesen, Constantine Plotnikov, git

Miklos Vajna <vmiklos@frugalware.org> wrote:
> On Tue, Oct 07, 2008 at 08:21:28AM +0200, Alex Riesen <raa.lkml@gmail.com> wrote:
> > Yes. Does it work? :)
> 
> Yes, it does. I'm not sure how to test it from the testsuite, maybe
> redirect the output to a file and grep in it? It's ugly, that's why I
> did not do so, but if you think a testcase is a musthave for this
> feature then that's the way to go, I guess.

Actually its not a bad way to test the feature.  Normally we disable
progress if stdout is not a tty.  If you redirect to a file then
-v should be needed to get anything at all on stderr.

You may be able to just test the size of the file:

	git fetch -v ... >out 2>err &&
	test -s err

-- 
Shawn.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Implement git clone -v
  2008-10-08  6:02         ` Shawn O. Pearce
@ 2008-10-08  6:25           ` Alex Riesen
  2008-10-08 23:40           ` Miklos Vajna
  1 sibling, 0 replies; 11+ messages in thread
From: Alex Riesen @ 2008-10-08  6:25 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Miklos Vajna, Constantine Plotnikov, git

Shawn O. Pearce, Wed, Oct 08, 2008 08:02:57 +0200:
> Miklos Vajna <vmiklos@frugalware.org> wrote:
> > On Tue, Oct 07, 2008 at 08:21:28AM +0200, Alex Riesen <raa.lkml@gmail.com> wrote:
> > > Yes. Does it work? :)
> > 
> > Yes, it does. I'm not sure how to test it from the testsuite, maybe
> > redirect the output to a file and grep in it? It's ugly, that's why I
> > did not do so, but if you think a testcase is a musthave for this
> > feature then that's the way to go, I guess.
> 
> Actually its not a bad way to test the feature.  Normally we disable
> progress if stdout is not a tty.  If you redirect to a file then
> -v should be needed to get anything at all on stderr.
> 
> You may be able to just test the size of the file:
> 
> 	git fetch -v ... >out 2>err &&

git clone

> 	test -s err

Right, but I don't think you need tests for progress bar. As a typical
eye candy, it tends to change often enough to be too annoying to test.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH] Implement git clone -v
  2008-10-08  6:02         ` Shawn O. Pearce
  2008-10-08  6:25           ` Alex Riesen
@ 2008-10-08 23:40           ` Miklos Vajna
  2008-10-09 11:06             ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Miklos Vajna @ 2008-10-08 23:40 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Alex Riesen, Constantine Plotnikov, git

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 Tue, Oct 07, 2008 at 11:02:57PM -0700, "Shawn O. Pearce" <spearce@spearce.org> wrote:
> You may be able to just test the size of the file:
>
>       git fetch -v ... >out 2>err &&
>       test -s err

Here is an updated patch, now with testcases.

 Documentation/git-clone.txt |    5 +++++
 builtin-clone.c             |    4 ++++
 t/t5702-clone-options.sh    |   13 +++++++++++++
 transport.c                 |    2 +-
 transport.h                 |    2 ++
 5 files changed, 25 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/t/t5702-clone-options.sh b/t/t5702-clone-options.sh
index 328e4d9..27825f5 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 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

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] Implement git clone -v
  2008-10-08 23:40           ` Miklos Vajna
@ 2008-10-09 11:06             ` Junio C Hamano
  2008-10-09 15:20               ` Shawn O. Pearce
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2008-10-09 11:06 UTC (permalink / raw)
  To: Miklos Vajna; +Cc: Shawn O. Pearce, Alex Riesen, Constantine Plotnikov, git

Miklos Vajna <vmiklos@frugalware.org> writes:

> The new -v option forces the progressbar, even in case the output is not
> a terminal.
>
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>

The patch made me wonder why this new feature had to be implemented in the
first place and had me look up the message the patch was an follow-up to.
For somebody who would not recall the original request-for-feature (that
includes you 6 months from now), it would have been easier to understand
the context if the commit message said what the intended purpose of this
(i.e. "have it read by an IDE").

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Implement git clone -v
  2008-10-09 11:06             ` Junio C Hamano
@ 2008-10-09 15:20               ` Shawn O. Pearce
  2008-10-09 21:26                 ` Miklos Vajna
  0 siblings, 1 reply; 11+ messages in thread
From: Shawn O. Pearce @ 2008-10-09 15:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Miklos Vajna, Alex Riesen, Constantine Plotnikov, git

Junio C Hamano <gitster@pobox.com> wrote:
> Miklos Vajna <vmiklos@frugalware.org> writes:
> 
> > The new -v option forces the progressbar, even in case the output is not
> > a terminal.
> >
> > Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> 
> The patch made me wonder why this new feature had to be implemented in the
> first place and had me look up the message the patch was an follow-up to.
> For somebody who would not recall the original request-for-feature (that
> includes you 6 months from now), it would have been easier to understand
> the context if the commit message said what the intended purpose of this
> (i.e. "have it read by an IDE").

I'm amending the message as the following:

--8<--
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>
--

-- 
Shawn.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Implement git clone -v
  2008-10-09 15:20               ` Shawn O. Pearce
@ 2008-10-09 21:26                 ` Miklos Vajna
  0 siblings, 0 replies; 11+ messages in thread
From: Miklos Vajna @ 2008-10-09 21:26 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Junio C Hamano, Alex Riesen, Constantine Plotnikov, git

[-- Attachment #1: Type: text/plain, Size: 441 bytes --]

On Thu, Oct 09, 2008 at 08:20:28AM -0700, "Shawn O. Pearce" <spearce@spearce.org> wrote:
> I'm amending the message as the following:
> 
> --8<--
> 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.

Thanks!

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2008-10-09 21:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-03 20:01 Forcing progerss output for clone Constantine Plotnikov
2008-10-04 21:42 ` Alex Riesen
2008-10-06 22:19   ` [PATCH] Implement git clone -v Miklos Vajna
2008-10-07  6:21     ` Alex Riesen
2008-10-07 19:39       ` Miklos Vajna
2008-10-08  6:02         ` Shawn O. Pearce
2008-10-08  6:25           ` Alex Riesen
2008-10-08 23:40           ` Miklos Vajna
2008-10-09 11:06             ` Junio C Hamano
2008-10-09 15:20               ` Shawn O. Pearce
2008-10-09 21:26                 ` Miklos Vajna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).