shortlog: don't warn on empty author

Git tries to avoid creating a commit with an empty author name or email. However, commits created by older, less strict versions of git may still be in the history. There's not much point in issuing a warning to stderr for an empty author. The user can't do anything about it now, and we are better off to simply include it in the shortlog output as an empty name/email, and let the caller process it however they see fit. Older versions of shortlog differentiated between "author header not present" (which complained) and "author name/email are blank" (which included the empty ident in the output). But since switching to format_commit_message, we complain to stderr about either case (linux.git has a blank author deep in its history which triggers this). We could try to restore the older behavior (complaining only about the missing header), but in retrospect, there's not much point in differentiating these cases. A missing author header is bogus, but as for the "blank" case, the only useful behavior is to add it to the "empty name" collection. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jan 18, 2016 at 18:04 UTC d6b16ce9147e787cce3551fc79d52b3e30c3ad3a
2 files changed -24
builtin/shortlog.c
-8
@@ -149,13 +149,6 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
149 ctx.output_encoding = get_log_output_encoding();
150
151 format_commit_message(commit, "%an <%ae>", &author, &ctx);
152 - /* we can detect a total failure only by seeing " <>" in the output */
153 - if (author.len <= 3) {
154 - warning(_("Missing author: %s"),
155 - oid_to_hex(&commit->object.oid));
156 - goto out;
157 - }
158 -
152 if (!log->summary) {
153 if (log->user_format)
154 pretty_print_commit(&ctx, commit, &oneline);
@@ -165,7 +158,6 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
158
159 insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");
160
168 -out:
161 strbuf_release(&author);
162 strbuf_release(&oneline);
163 }
t/t4201-shortlog.sh
-16
@@ -178,22 +178,6 @@ test_expect_success !MINGW 'shortlog encoding' '
178 git shortlog HEAD~2.. > out &&
179 test_cmp expect out'
180
181 -test_expect_success 'shortlog ignores commits with missing authors' '
182 - git commit --allow-empty -m normal &&
183 - git commit --allow-empty -m soon-to-be-broken &&
184 - git cat-file commit HEAD >commit.tmp &&
185 - sed "/^author/d" commit.tmp >broken.tmp &&
186 - commit=$(git hash-object -w -t commit --stdin <broken.tmp) &&
187 - git update-ref HEAD $commit &&
188 - cat >expect <<-\EOF &&
189 - A U Thor (1):
190 - normal
191 -
192 - EOF
193 - git shortlog HEAD~2.. >actual &&
194 - test_cmp expect actual
195 -'
196 -
181 test_expect_success 'shortlog with revision pseudo options' '
182 git shortlog --all &&
183 git shortlog --branches &&