summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 267123b)
raw | patch | inline | side by side (parent: 267123b)
author | Jonas Fonseca <fonseca@diku.dk> | |
Fri, 14 Mar 2008 21:35:24 +0000 (22:35 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 15 Mar 2008 07:49:15 +0000 (00:49 -0700) |
Once upon a time shortlog could be run from a non-git directory
and still do its job. Fix this regression and add a small test
for it.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
and still do its job. Fix this regression and add a small test
for it.
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-shortlog.c | patch | blob | history | |
git.c | patch | blob | history | |
t/t4201-shortlog.sh | patch | blob | history |
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index b22b0edd65eefacabb648962b9c20c695609a3f5..bd795b1db7a4054a0218d1ec96794ad25d656896 100644 (file)
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
{
struct shortlog log;
struct rev_info rev;
+ int nongit;
+ prefix = setup_git_directory_gently(&nongit);
shortlog_init(&log);
/* since -n is a shadowed rev argument, parse our args first */
die ("unrecognized argument: %s", argv[1]);
/* assume HEAD if from a tty */
- if (!rev.pending.nr && isatty(0))
+ if (!nongit && !rev.pending.nr && isatty(0))
add_head_to_pending(&rev);
if (rev.pending.nr == 0) {
read_from_stdin(&log);
index 1e3eb1065fe3fe52361c2feaeadfab85780877ee..13de8018f0451c1e36d8fbc8f8c10233d2b45be9 100644 (file)
--- a/git.c
+++ b/git.c
{ "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
{ "rm", cmd_rm, RUN_SETUP },
{ "send-pack", cmd_send_pack, RUN_SETUP },
- { "shortlog", cmd_shortlog, RUN_SETUP | USE_PAGER },
+ { "shortlog", cmd_shortlog, USE_PAGER },
{ "show-branch", cmd_show_branch, RUN_SETUP },
{ "show", cmd_show, RUN_SETUP | USE_PAGER },
{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 6d12efb74d8bedede8e476429b2fccd648eb05a3..eef4cafda99729977af9bee2eca83493814faede 100755 (executable)
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
test_expect_success 'shortlog wrapping' 'diff -u expect out'
+git log HEAD > log
+GIT_DIR=non-existing git shortlog -w < log > out
+
+test_expect_success 'shortlog from non-git directory' 'diff -u expect out'
+
test_done