Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Keep a commit's encoding local to its parser
Diffstat (limited to '')
| -rw-r--r-- | source/parsing.c | 20 |
1 file changed, 11 insertions, 9 deletions
diff --git a/source/parsing.c b/source/parsing.c index 4c13c05..5b6ea57 100644 --- a/source/parsing.c +++ b/source/parsing.c @@ -165,6 +165,7 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) struct commitinfo *info; const char *p = repo_get_commit_buffer(the_repository, commit, NULL); const char *eol; + char *encoding = NULL; info = xcalloc(1, sizeof(struct commitinfo)); info->commit = commit; @@ -193,15 +194,15 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) if (p && skip_prefix(p, "encoding ", &p)) { eol = strchr(p, '\n'); if (eol) { - info->msg_encoding = xmemdupz(p, eol - p); + encoding = xmemdupz(p, eol - p); p = eol + 1; } } // Git only writes the header when the message is in something other // than UTF-8, so its absence means UTF-8. - if (!info->msg_encoding) - info->msg_encoding = xstrdup("UTF-8"); + if (!encoding) + encoding = xstrdup("UTF-8"); while (!end_of_header(p)) p = next_header_line(p); @@ -221,12 +222,13 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) info->msg = xstrdup(""); } - reencode(&info->author, info->msg_encoding); - reencode(&info->author_email, info->msg_encoding); - reencode(&info->committer, info->msg_encoding); - reencode(&info->committer_email, info->msg_encoding); - reencode(&info->subject, info->msg_encoding); - reencode(&info->msg, info->msg_encoding); + reencode(&info->author, encoding); + reencode(&info->author_email, encoding); + reencode(&info->committer, encoding); + reencode(&info->committer_email, encoding); + reencode(&info->subject, encoding); + reencode(&info->msg, encoding); + free(encoding); return info; } |
