Skip to content

Commit d6b16ce

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9b21a34 commit d6b16ce

File tree

2 files changed

+0
-24
lines changed

2 files changed

+0
-24
lines changed

builtin/shortlog.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
149149
ctx.output_encoding = get_log_output_encoding();
150150

151151
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-
159152
if (!log->summary) {
160153
if (log->user_format)
161154
pretty_print_commit(&ctx, commit, &oneline);
@@ -165,7 +158,6 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
165158

166159
insert_one_record(log, author.buf, oneline.len ? oneline.buf : "<none>");
167160

168-
out:
169161
strbuf_release(&author);
170162
strbuf_release(&oneline);
171163
}

t/t4201-shortlog.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,22 +178,6 @@ test_expect_success !MINGW 'shortlog encoding' '
178178
git shortlog HEAD~2.. > out &&
179179
test_cmp expect out'
180180

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-
197181
test_expect_success 'shortlog with revision pseudo options' '
198182
git shortlog --all &&
199183
git shortlog --branches &&

0 commit comments

Comments
 (0)