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

[PATCH] shortlog: warn the user when there is no input

From
Michele Ballabio <barra_cuda@katamail.com>
Date
Feb 24, 2010, 20:49 UTC
Message-ID
<201002242149.03662.barra_cuda@katamail.com>
In-Reply-To
<7vvddmmnvo.fsf@alter.siamese.dyndns.org>

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:
Show 9 quoted lines
> 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
Previous: Junio C Hamano
Message 3 of 3 in “shortlog: do not stall when there is no input”
  1. shortlog: do not stall when there is no inputMichele Ballabio, Feb 24, 2010
  2. Junio C HamanoFeb 24, 2010
  3. shortlog: warn the user when there is no inputMichele Ballabio, Feb 24, 2010

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.