Diff options
-rw-r--r--source/cgit.h1
-rw-r--r--source/parsing.c20
-rw-r--r--source/shared.c1
3 files changed, 11 insertions, 11 deletions
diff --git a/source/cgit.h b/source/cgit.h
index a089633..00258fd 100644
--- a/source/cgit.h
+++ b/source/cgit.h
@@ -135,7 +135,6 @@ struct commitinfo {
int committer_tz;
char *subject;
char *msg;
- char *msg_encoding;
};
struct taginfo {
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;
}
diff --git a/source/shared.c b/source/shared.c
index 30e2e12..e075b8a 100644
--- a/source/shared.c
+++ b/source/shared.c
@@ -245,7 +245,6 @@ void cgit_free_commitinfo(struct commitinfo *info)
free(info->committer_email);
free(info->subject);
free(info->msg);
- free(info->msg_encoding);
free(info);
}