Skip to content

Commit

Permalink
Merge branch 'jk/shortlog-tolerate-broken-commit'
Browse files Browse the repository at this point in the history
* jk/shortlog-tolerate-broken-commit:
  shortlog: ignore commits with missing authors
  • Loading branch information
Jonathan Nieder committed Sep 25, 2013
2 parents a301889 + cd4f09e commit 7f794aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions builtin/shortlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions t/t4201-shortlog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7f794aa

Please sign in to comment.