git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] shortlog: do not stall when there is no input
@ 2010-02-24 19:20 Michele Ballabio
  2010-02-24 19:31 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Michele Ballabio @ 2010-02-24 19:20 UTC (permalink / raw)
  To: git

A simple "git shortlog" outside of a git repository used to stall
waiting for an input. Fix this by testing with isatty() before
calling read_from_stdin().

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
---
 builtin-shortlog.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index b3b055f..ff5dca6 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -294,9 +294,8 @@ parse_done:
 	/* assume HEAD if from a tty */
 	if (!nongit && !rev.pending.nr && isatty(0))
 		add_head_to_pending(&rev);
-	if (rev.pending.nr == 0) {
+	if (rev.pending.nr == 0 && !isatty(0))
 		read_from_stdin(&log);
-	}
 	else
 		get_from_rev(&rev, &log);
 
-- 
1.7.0

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

* Re: [PATCH] shortlog: do not stall when there is no input
  2010-02-24 19:20 [PATCH] shortlog: do not stall when there is no input Michele Ballabio
@ 2010-02-24 19:31 ` Junio C Hamano
  2010-02-24 20:49   ` [PATCH] shortlog: warn the user " Michele Ballabio
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2010-02-24 19:31 UTC (permalink / raw)
  To: Michele Ballabio; +Cc: git

Michele Ballabio <barra_cuda@katamail.com> writes:

> A simple "git shortlog" outside of a git repository used to stall
> waiting for an input. Fix this by testing with isatty() before
> calling read_from_stdin().

I'd actually prefer doing what "git commit" does.  Give a helpful hint
that it is waiting for input from the standard input, but do read from
standard input as the program is instructed to do.

That way people who drive the program with expect will not be broken ;-)
but that is a minor point.

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

* [PATCH] shortlog: warn the user when there is no input
  2010-02-24 19:31 ` Junio C Hamano
@ 2010-02-24 20:49   ` Michele Ballabio
  0 siblings, 0 replies; 3+ messages in thread
From: Michele Ballabio @ 2010-02-24 20:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

A simple "git shortlog" outside of a git repository stalls
waiting for an input. Check if that's the case by testing with
isatty() before read_from_stdin(), and warn the user like
"git commit" does in a similar case.

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
---
On Wednesday 24 February 2010, Junio C Hamano wrote:
> Michele Ballabio <barra_cuda@katamail.com> writes:
> 
> > A simple "git shortlog" outside of a git repository used to stall
> > waiting for an input. Fix this by testing with isatty() before
> > calling read_from_stdin().
> 
> I'd actually prefer doing what "git commit" does.  Give a helpful hint
> that it is waiting for input from the standard input, but do read from
> standard input as the program is instructed to do.

Ok.

 builtin-shortlog.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index b3b055f..22668b4 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -295,6 +295,8 @@ parse_done:
 	if (!nongit && !rev.pending.nr && isatty(0))
 		add_head_to_pending(&rev);
 	if (rev.pending.nr == 0) {
+		if (isatty(0))
+			fprintf(stderr, "(reading log message from standard input)\n");
 		read_from_stdin(&log);
 	}
 	else
-- 
1.7.0

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

end of thread, other threads:[~2010-02-24 20:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-24 19:20 [PATCH] shortlog: do not stall when there is no input Michele Ballabio
2010-02-24 19:31 ` Junio C Hamano
2010-02-24 20:49   ` [PATCH] shortlog: warn the user " Michele Ballabio

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).