Skip to contentSkip to conversation

shortlog: do not stall when there is no input

PATCH In review Michele Ballabio 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shortlog: do not stall when there is no input

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

---
 builtin-shortlog.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
builtin-shortlog.c +1 -2
index b3b055f..ff5dca6 100644
@@ -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);
 
Signature · 1 line
1.7.0
#1 lore raw
Quoted 3 lines · Michele Ballabio

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.

#2 lore raw

PATCH 1/1 shortlog: warn the user when there is no input

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.

---

Quoted 9 lines · Junio C Hamano
Quoted 3 lines · Michele Ballabio

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(-)
builtin-shortlog.c +2 -0
index b3b055f..22668b4 100644
@@ -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
Signature · 1 line
1.7.0