summaryrefslogtreecommitdiff
path: root/builtin-shortlog.c
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2009-11-25 20:33:28 +0100
committerJunio C Hamano <gitster@pobox.com>2009-11-25 15:36:54 -0800
commit79f7ca063d6b74e9d7f3db90c85dfa4a162128e4 (patch)
treea06c29b673fe4ebe9c7e6677e26ff55051549491 /builtin-shortlog.c
parent78d553b7d7b269bb22ebd8b1198657c37484a3a0 (diff)
downloadgit-79f7ca063d6b74e9d7f3db90c85dfa4a162128e4.tar.gz
shortlog: respect commit encoding
Don't take the author name information without re-encoding from the raw commit object buffer. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-shortlog.c')
-rw-r--r--builtin-shortlog.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 4d4a3c82d6..b98edc3ba6 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -139,8 +139,12 @@ static void read_from_stdin(struct shortlog *log)
void shortlog_add_commit(struct shortlog *log, struct commit *commit)
{
const char *author = NULL, *buffer;
+ struct strbuf buf = STRBUF_INIT;
+ struct strbuf ufbuf = STRBUF_INIT;
- buffer = commit->buffer;
+ pretty_print_commit(CMIT_FMT_RAW, commit, &buf,
+ 0, NULL, NULL, DATE_NORMAL, 0);
+ buffer = buf.buf;
while (*buffer && *buffer != '\n') {
const char *eol = strchr(buffer, '\n');
@@ -157,17 +161,15 @@ void shortlog_add_commit(struct shortlog *log, struct commit *commit)
die("Missing author: %s",
sha1_to_hex(commit->object.sha1));
if (log->user_format) {
- struct strbuf buf = STRBUF_INIT;
-
- pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &buf,
+ pretty_print_commit(CMIT_FMT_USERFORMAT, commit, &ufbuf,
DEFAULT_ABBREV, "", "", DATE_NORMAL, 0);
- insert_one_record(log, author, buf.buf);
- strbuf_release(&buf);
- return;
- }
- if (*buffer)
+ buffer = ufbuf.buf;
+ } else if (*buffer) {
buffer++;
+ }
insert_one_record(log, author, !*buffer ? "<none>" : buffer);
+ strbuf_release(&ufbuf);
+ strbuf_release(&buf);
}
static void get_from_rev(struct rev_info *rev, struct shortlog *log)