git/list[1] front-page[2] threads[3] people[4] search[5] about
 

warn non utf-8 commit log messages.

From
Junio C Hamano <junkio@cox.net>
Date
Dec 23, 2006, 19:53 UTC
Message-ID
<7vfyb6qth6.fsf_-_@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0612230048350.19693@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> But I had enough of UTF-8 for a day.
>
> Okay, so I lied (this are both patches revised and combined):

I am thinking of putting this in 'next', with the following changes on top of your combined patch.

git-commit-tree warns if the commit message does not minimally conform to the UTF-8 encoding when i18n.commitencoding is either unset, or set to "utf-8". It does not die as in your version.

 builtin-commit-tree.c |   13 +++++++------
 utf8.c                |    2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c
index f274721..f641787 100644
--- a/builtin-commit-tree.c
+++ b/builtin-commit-tree.c
@@ -78,6 +78,11 @@ static int new_parent(int idx)
 	return 1;
 }
 
+static const char commit_utf8_warn[] =
+"Warning: commit message does not conform to UTF-8.\n"
+"You may want to amend it after fixing the message, or set the config\n"
+"variable i18n.commitencoding to the encoding your project uses.\n";
+
 int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 {
 	int i;
@@ -133,12 +138,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
 
 	/* And check the encoding */
 	buffer[size] = '\0';
-	if (!strcmp(git_commit_encoding, "utf-8") && !is_utf8(buffer)) {
-		fprintf(stderr, "Commit message does not conform to UTF-8.\n"
-			"Please fix the message,"
-			" or set the config variable i18n.commitencoding.\n");
-		return 1;
-	}
+	if (!strcmp(git_commit_encoding, "utf-8") && !is_utf8(buffer))
+		fprintf(stderr, commit_utf8_warn);
 
 	if (!write_sha1_file(buffer, size, commit_type, commit_sha1)) {
 		printf("%s\n", sha1_to_hex(commit_sha1));
diff --git a/utf8.c b/utf8.c
index aed60ad..8fa6257 100644
--- a/utf8.c
+++ b/utf8.c
@@ -244,7 +244,7 @@ void print_wrapped_text(const char *text, int indent, int indent2, int width)
 	for (;;) {
 		char c = *text;
 		if (!c || isspace(c)) {
-			if (w < width || space < 0) {
+			if (w < width || !space) {
 				const char *start = bol;
 				if (space)
 					start = space;
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 34 of 39 in “Fix documentation copy&paste typo”
  1. Fix documentation copy&paste typoUwe Kleine-Koenig, Dec 8, 2006
  2. Uwe Kleine-KönigDec 19, 2006
  3. Junio C HamanoDec 19, 2006
  4. specify charset for commits (Was: [PATCH] Fix documentation copy&paste typo)Uwe Kleine-König, Dec 21, 2006
  5. Johannes SchindelinDec 21, 2006
  6. Santi BéjarDec 21, 2006
  7. Alexander LitvinovDec 21, 2006
  8. Jakub NarebskiDec 21, 2006
  9. Alexander LitvinovDec 21, 2006
  10. Jakub NarebskiDec 21, 2006
  11. Uwe Kleine-KönigDec 21, 2006
  12. Junio C HamanoDec 21, 2006
  13. Nicolas PitreDec 21, 2006
  14. Uwe Kleine-KönigDec 21, 2006
  15. Alexander LitvinovDec 21, 2006
  16. Johannes SchindelinDec 22, 2006
  17. Uwe Kleine-KönigDec 22, 2006
  18. Uwe Kleine-KönigDec 22, 2006
  19. Nicolas PitreDec 22, 2006
  20. Junio C HamanoDec 22, 2006
  21. 1/2 libgit.a: add some UTF-8 handling functionsJohannes Schindelin, Dec 22, 2006
  22. Junio C HamanoDec 22, 2006
  23. Johannes SchindelinDec 22, 2006
  24. Junio C HamanoDec 22, 2006
  25. Johannes SchindelinDec 22, 2006
  26. Junio C HamanoDec 22, 2006
  27. Alexander LitvinovDec 25, 2006
  28. Uwe Kleine-KönigDec 22, 2006
  29. Uwe Kleine-KönigDec 22, 2006
  30. Johannes SchindelinDec 22, 2006
  31. Johannes SchindelinDec 22, 2006
  32. Uwe Kleine-KönigDec 23, 2006
  33. Johannes SchindelinDec 23, 2006
  34. warn non utf-8 commit log messages.Junio C Hamano, Dec 23, 2006
  35. Johannes SchindelinDec 23, 2006
  36. 2/2 git-commit-tree: if i18n.commitencoding is utf-8 (default), check itJohannes Schindelin, Dec 22, 2006
  37. Junio C HamanoDec 22, 2006
  38. Johannes SchindelinDec 22, 2006
  39. 3/2 Wrap lines in shortlogJohannes Schindelin, Dec 22, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.