summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2013-09-24 23:29:00 -0700
committerJonathan Nieder <jrnieder@gmail.com>2013-09-24 23:29:00 -0700
commit7f794aab3eb84fedf1240c845976cab1c566c716 (patch)
tree9790ca68355e0981ea201a912bb68dfe40ebb368
parenta301889980237b4d1cba9d07e48bdaf67064af83 (diff)
parentcd4f09e38341bdd17cf008ea57863e4b10ac176b (diff)
downloadgit-7f794aab3eb84fedf1240c845976cab1c566c716.tar.gz
Merge branch 'jk/shortlog-tolerate-broken-commit'
* jk/shortlog-tolerate-broken-commit: shortlog: ignore commits with missing authors
-rw-r--r--builtin/shortlog.c6
-rwxr-xr-xt/t4201-shortlog.sh16
2 files changed, 20 insertions, 2 deletions
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index ae73d17b6c..c226f767aa 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -127,9 +127,11 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
author = buffer + 7;
buffer = eol;
}
- if (!author)
- die(_("Missing author: %s"),
+ if (!author) {
+ warning(_("Missing author: %s"),
sha1_to_hex(commit->object.sha1));
+ return;
+ }
if (log->user_format) {
struct pretty_print_context ctx = {0};
ctx.fmt = CMIT_FMT_USERFORMAT;
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 5493500ef1..42866992cf 100755
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
@@ -172,4 +172,20 @@ test_expect_success 'shortlog encoding' '
git shortlog HEAD~2.. > out &&
test_cmp expect out'
+test_expect_success 'shortlog ignores commits with missing authors' '
+ git commit --allow-empty -m normal &&
+ git commit --allow-empty -m soon-to-be-broken &&
+ git cat-file commit HEAD >commit.tmp &&
+ sed "/^author/d" commit.tmp >broken.tmp &&
+ commit=$(git hash-object -w -t commit --stdin <broken.tmp) &&
+ git update-ref HEAD $commit &&
+ cat >expect <<-\EOF &&
+ A U Thor (1):
+ normal
+
+ EOF
+ git shortlog HEAD~2.. >actual &&
+ test_cmp expect actual
+'
+
test_done