Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2013-09-19 01:14:00 +0400
committerJunio C Hamano <gitster@pobox.com>2013-09-19 01:41:19 +0400
commitcd4f09e38341bdd17cf008ea57863e4b10ac176b (patch)
tree9c1162de2f91778e9792f1831b05292ef6defc62 /t/t4201-shortlog.sh
parentedca4152560522a431a51fc0a06147fc680b5b18 (diff)
shortlog: ignore commits with missing authors
Most of git's traversals are robust against minor breakages in commit data. For example, "git log" will still output an entry for a commit that has a broken encoding or missing author, and will not abort the whole operation. Shortlog, on the other hand, will die as soon as it sees a commit without an author, meaning that a repository with a broken commit cannot get any shortlog output at all. Let's downgrade this fatal error to a warning, and continue the operation. We simply ignore the commit and do not count it in the total (since we do not have any author under which to file it). Alternatively, we could output some kind of "<empty>" record to collect these bogus commits. It is probably not worth it, though; we have already warned to stderr, so the user is aware that such bogosities exist, and any placeholder we came up with would either be syntactically invalid, or would potentially conflict with real data. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4201-shortlog.sh')
-rwxr-xr-xt/t4201-shortlog.sh16
1 files changed, 16 insertions, 0 deletions
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