{"thread":{"id":"12699","subject":"[PATCH] shortlog: do not require to run from inside a git repository","startedAt":"2008-03-14T21:35:24Z","lastAt":"2008-03-16T03:55:56Z","messageCount":2,"participants":["Jonas Fonseca","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"72148","messageId":"20080314213524.GA10085@diku.dk","threadId":"12699","inReplyTo":null,"subject":"[PATCH] shortlog: do not require to run from inside a git repository","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2008-03-14T21:35:24Z","receivedAt":"2008-03-14T21:35:24Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Once upon a time shortlog could be run from a non-git directory\nand still do its job. Fix this regression and add a small test\nfor it.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n builtin-shortlog.c  |    4 +++-\n git.c               |    2 +-\n t/t4201-shortlog.sh |    5 +++++\n 3 files changed, 9 insertions(+), 2 deletions(-)\n\n On top of next.\n\ndiff --git a/builtin-shortlog.c b/builtin-shortlog.c\nindex b22b0ed..bd795b1 100644\n--- a/builtin-shortlog.c\n+++ b/builtin-shortlog.c\n@@ -229,7 +229,9 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n {\n \tstruct shortlog log;\n \tstruct rev_info rev;\n+\tint nongit;\n \n+\tprefix = setup_git_directory_gently(&nongit);\n \tshortlog_init(&log);\n \n \t/* since -n is a shadowed rev argument, parse our args first */\n@@ -259,7 +261,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n \t\tdie (\"unrecognized argument: %s\", argv[1]);\n \n \t/* assume HEAD if from a tty */\n-\tif (!rev.pending.nr && isatty(0))\n+\tif (!nongit && !rev.pending.nr && isatty(0))\n \t\tadd_head_to_pending(&rev);\n \tif (rev.pending.nr == 0) {\n \t\tread_from_stdin(&log);\ndiff --git a/git.c b/git.c\nindex 1e3eb10..13de801 100644\n--- a/git.c\n+++ b/git.c\n@@ -343,7 +343,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"revert\", cmd_revert, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"rm\", cmd_rm, RUN_SETUP },\n \t\t{ \"send-pack\", cmd_send_pack, RUN_SETUP },\n-\t\t{ \"shortlog\", cmd_shortlog, RUN_SETUP | USE_PAGER },\n+\t\t{ \"shortlog\", cmd_shortlog, USE_PAGER },\n \t\t{ \"show-branch\", cmd_show_branch, RUN_SETUP },\n \t\t{ \"show\", cmd_show, RUN_SETUP | USE_PAGER },\n \t\t{ \"status\", cmd_status, RUN_SETUP | NEED_WORK_TREE },\ndiff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh\nindex 91ea696..405b971 100755\n--- a/t/t4201-shortlog.sh\n+++ b/t/t4201-shortlog.sh\n@@ -47,4 +47,9 @@ EOF\n \n test_expect_success 'shortlog wrapping' 'test_cmp expect out'\n \n+git log HEAD > log\n+GIT_DIR=non-existing git shortlog -w < log > out\n+\n+test_expect_success 'shortlog from non-git directory' 'test_cmp expect out'\n+\n test_done\n-- \n1.5.4.4.684.g0e08.dirty\n\n-- \nJonas Fonseca\n"},{"id":"72203","messageId":"7vskyrl3ub.fsf@gitster.siamese.dyndns.org","threadId":"12699","inReplyTo":"20080314213524.GA10085@diku.dk","subject":"Re: [PATCH] shortlog: do not require to run from inside a git repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-16T03:55:56Z","receivedAt":"2008-03-16T03:55:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonas Fonseca <fonseca@diku.dk> writes:\n\n> Once upon a time shortlog could be run from a non-git directory\n> and still do its job. Fix this regression and add a small test\n> for it.\n\nNice regression fix.  Thanks.\n"}]}