{"thread":{"id":"22799","subject":"[PATCH] shortlog: do not stall when there is no input","startedAt":"2010-02-24T19:20:27Z","lastAt":"2010-02-24T20:49:03Z","messageCount":3,"participants":["Michele Ballabio","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"135598","messageId":"201002242020.27801.barra_cuda@katamail.com","threadId":"22799","inReplyTo":null,"subject":"[PATCH] shortlog: do not stall when there is no input","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2010-02-24T19:20:27Z","receivedAt":"2010-02-24T19:20:27Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"A simple \"git shortlog\" outside of a git repository used to stall\nwaiting for an input. Fix this by testing with isatty() before\ncalling read_from_stdin().\n\nSigned-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\n builtin-shortlog.c |    3 +--\n 1 files changed, 1 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex b3b055f..ff5dca6 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -294,9 +294,8 @@ parse_done:\n \t/* assume HEAD if from a tty */\n \tif (!nongit && !rev.pending.nr && isatty(0))\n \t\tadd_head_to_pending(&rev);\n-\tif (rev.pending.nr == 0) {\n+\tif (rev.pending.nr == 0 && !isatty(0))\n \t\tread_from_stdin(&log);\n-\t}\n \telse\n \t\tget_from_rev(&rev, &log);\n \n-- \n1.7.0\n"},{"id":"135605","messageId":"7vvddmmnvo.fsf@alter.siamese.dyndns.org","threadId":"22799","inReplyTo":"201002242020.27801.barra_cuda@katamail.com","subject":"Re: [PATCH] shortlog: do not stall when there is no input","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-24T19:31:39Z","receivedAt":"2010-02-24T19:31:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michele Ballabio <barra_cuda@katamail.com> writes:\n\n> A simple \"git shortlog\" outside of a git repository used to stall\n> waiting for an input. Fix this by testing with isatty() before\n> calling read_from_stdin().\n\nI'd actually prefer doing what \"git commit\" does.  Give a helpful hint\nthat it is waiting for input from the standard input, but do read from\nstandard input as the program is instructed to do.\n\nThat way people who drive the program with expect will not be broken ;-)\nbut that is a minor point.\n"},{"id":"135612","messageId":"201002242149.03662.barra_cuda@katamail.com","threadId":"22799","inReplyTo":"7vvddmmnvo.fsf@alter.siamese.dyndns.org","subject":"[PATCH] shortlog: warn the user when there is no input","fromName":"Michele Ballabio","fromEmail":"barra_cuda@katamail.com","sentAt":"2010-02-24T20:49:03Z","receivedAt":"2010-02-24T20:49:03Z","isPatch":true,"sender":{"key":"barra_cuda@katamail.com","avatar":"https://avatars.githubusercontent.com/u/16371673?v=4"},"body":"A simple \"git shortlog\" outside of a git repository stalls\nwaiting for an input. Check if that's the case by testing with\nisatty() before read_from_stdin(), and warn the user like\n\"git commit\" does in a similar case.\n\nSigned-off-by: Michele Ballabio <barra_cuda@katamail.com>\n---\nOn Wednesday 24 February 2010, Junio C Hamano wrote:\n> Michele Ballabio <barra_cuda@katamail.com> writes:\n> \n> > A simple \"git shortlog\" outside of a git repository used to stall\n> > waiting for an input. Fix this by testing with isatty() before\n> > calling read_from_stdin().\n> \n> I'd actually prefer doing what \"git commit\" does.  Give a helpful hint\n> that it is waiting for input from the standard input, but do read from\n> standard input as the program is instructed to do.\n\nOk.\n\n builtin-shortlog.c |    2 ++\n 1 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex b3b055f..22668b4 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -295,6 +295,8 @@ parse_done:\n \tif (!nongit && !rev.pending.nr && isatty(0))\n \t\tadd_head_to_pending(&rev);\n \tif (rev.pending.nr == 0) {\n+\t\tif (isatty(0))\n+\t\t\tfprintf(stderr, \"(reading log message from standard input)\\n\");\n \t\tread_from_stdin(&log);\n \t}\n \telse\n-- \n1.7.0\n"}]}