summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b45974a)
raw | patch | inline | side by side (parent: b45974a)
author | Junio C Hamano <junkio@cox.net> | |
Sun, 24 Dec 2006 07:53:02 +0000 (23:53 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 26 Dec 2006 08:22:39 +0000 (00:22 -0800) |
When i18n.commitencoding is set to a non UTF-8 encoding,
commit-tree records the encoding in an extra header after
author/committer headers in the commit object.
An earlier version used trailer but Johannes points out that
there is little risk breaking existing Porcelains with a new
header.
Signed-off-by: Junio C Hamano <junkio@cox.net>
commit-tree records the encoding in an extra header after
author/committer headers in the commit object.
An earlier version used trailer but Johannes points out that
there is little risk breaking existing Porcelains with a new
header.
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-commit-tree.c | patch | blob | history |
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index f641787988e197209f097cbc9d1b260a2cb6d9d8..33c29f7495afad0342545a7e6854c3e3032a69e2 100644 (file)
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
char comment[1000];
char *buffer;
unsigned int size;
+ int encoding_is_utf8;
setup_ident();
git_config(git_default_config);
parents++;
}
+ encoding_is_utf8 = !strcmp(git_commit_encoding, "utf-8");
+
init_buffer(&buffer, &size);
add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1));
/* Person/date information */
add_buffer(&buffer, &size, "author %s\n", git_author_info(1));
- add_buffer(&buffer, &size, "committer %s\n\n", git_committer_info(1));
+ add_buffer(&buffer, &size, "committer %s\n", git_committer_info(1));
+ if (!encoding_is_utf8)
+ add_buffer(&buffer, &size,
+ "encoding %s\n", git_commit_encoding);
+ add_buffer(&buffer, &size, "\n");
/* And add the comment */
while (fgets(comment, sizeof(comment), stdin) != NULL)
/* And check the encoding */
buffer[size] = '\0';
- if (!strcmp(git_commit_encoding, "utf-8") && !is_utf8(buffer))
+ if (encoding_is_utf8 && !is_utf8(buffer))
fprintf(stderr, commit_utf8_warn);
if (!write_sha1_file(buffer, size, commit_type, commit_sha1)) {