summaryrefslogtreecommitdiff
path: root/builtin-blame.c
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2008-10-21 20:55:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-10-21 21:09:34 (GMT)
commit69cd8f63427c65c65d9cd66bb8c05ca93dc3edef (patch)
tree6520e907a99f50404bf9ba8e151ceb6f06e72e5e /builtin-blame.c
parent208f689610e524ce9858f9d28635f7fea51b8d96 (diff)
downloadgit-69cd8f63427c65c65d9cd66bb8c05ca93dc3edef.zip
git-69cd8f63427c65c65d9cd66bb8c05ca93dc3edef.tar.gz
git-69cd8f63427c65c65d9cd66bb8c05ca93dc3edef.tar.bz2
builtin-blame: Reencode commit messages according to git-log rules.
Currently git-blame outputs text from the commit messages (e.g. the author name and the summary string) as-is, without even providing any information about the encoding used for the data. It makes interpreting the data in multilingual environment very difficult. This commit changes the blame implementation to recode the messages using the rules used by other commands like git-log. Namely, the target encoding can be specified through the i18n.commitEncoding or i18n.logOutputEncoding options, or directly on the command line using the --encoding parameter. Converting the encoding before output seems to be more friendly to the porcelain tools than simply providing the value of the encoding header, and does not require changing the output format. If anybody needs the old behavior, it is possible to achieve it by specifying --encoding=none. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-blame.c')
-rw-r--r--builtin-blame.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/builtin-blame.c b/builtin-blame.c
index 48cc0c1..2457e71 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -1431,7 +1431,7 @@ static void get_commit_info(struct commit *commit,
int detailed)
{
int len;
- char *tmp, *endp;
+ char *tmp, *endp, *reencoded, *message;
static char author_buf[1024];
static char committer_buf[1024];
static char summary_buf[1024];
@@ -1449,24 +1449,29 @@ static void get_commit_info(struct commit *commit,
die("Cannot read commit %s",
sha1_to_hex(commit->object.sha1));
}
+ reencoded = reencode_commit_message(commit, NULL);
+ message = reencoded ? reencoded : commit->buffer;
ret->author = author_buf;
- get_ac_line(commit->buffer, "\nauthor ",
+ get_ac_line(message, "\nauthor ",
sizeof(author_buf), author_buf, &ret->author_mail,
&ret->author_time, &ret->author_tz);
- if (!detailed)
+ if (!detailed) {
+ free(reencoded);
return;
+ }
ret->committer = committer_buf;
- get_ac_line(commit->buffer, "\ncommitter ",
+ get_ac_line(message, "\ncommitter ",
sizeof(committer_buf), committer_buf, &ret->committer_mail,
&ret->committer_time, &ret->committer_tz);
ret->summary = summary_buf;
- tmp = strstr(commit->buffer, "\n\n");
+ tmp = strstr(message, "\n\n");
if (!tmp) {
error_out:
sprintf(summary_buf, "(%s)", sha1_to_hex(commit->object.sha1));
+ free(reencoded);
return;
}
tmp += 2;
@@ -1478,6 +1483,7 @@ static void get_commit_info(struct commit *commit,
goto error_out;
memcpy(summary_buf, tmp, len);
summary_buf[len] = 0;
+ free(reencoded);
}
/*