summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 78d553b)
raw | patch | inline | side by side (parent: 78d553b)
author | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | |
Wed, 25 Nov 2009 19:33:28 +0000 (20:33 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 25 Nov 2009 23:36:54 +0000 (15:36 -0800) |
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>
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>
builtin-shortlog.c | patch | blob | history | |
t/t4201-shortlog.sh | patch | blob | history |
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 4d4a3c82d6209ce3ec897dad0c69d58a329b4303..b98edc3ba6c155b632d5e140d0b5a3e8a2d4eb9b 100644 (file)
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
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');
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)
diff --git a/t/t4201-shortlog.sh b/t/t4201-shortlog.sh
index 405b97119175a1c0fa75a9db30c6b1ab076cc44e..dd818f6fd61e8ca593c36467377d15d023eced25 100755 (executable)
--- a/t/t4201-shortlog.sh
+++ b/t/t4201-shortlog.sh
test_expect_success 'shortlog from non-git directory' 'test_cmp expect out'
+iconvfromutf8toiso88591() {
+ printf "%s" "$*" | iconv -f UTF-8 -t ISO-8859-1
+}
+
+DSCHO="Jöhännës \"Dschö\" Schindëlin"
+DSCHOE="$DSCHO <Johannes.Schindelin@gmx.de>"
+MSG1="set a1 to 2 and some non-ASCII chars: Äßø"
+MSG2="set a1 to 3 and some non-ASCII chars: áæï"
+cat > expect << EOF
+$DSCHO (2):
+ $MSG1
+ $MSG2
+
+EOF
+
+test_expect_success 'shortlog encoding' '
+ git reset --hard "$commit" &&
+ git config --unset i18n.commitencoding &&
+ echo 2 > a1 &&
+ git commit --quiet -m "$MSG1" --author="$DSCHOE" a1 &&
+ git config i18n.commitencoding "ISO-8859-1" &&
+ echo 3 > a1 &&
+ git commit --quiet -m "$(iconvfromutf8toiso88591 "$MSG2")" \
+ --author="$(iconvfromutf8toiso88591 "$DSCHOE")" a1 &&
+ git config --unset i18n.commitencoding &&
+ git shortlog HEAD~2.. > out &&
+test_cmp expect out'
+
test_done