{"thread":{"id":"17329","subject":"[PATCH (GIT-GUI BUG)] git-gui: Fix post-commit status with subject in non-locale encoding.","startedAt":"2009-01-23T21:18:13Z","lastAt":"2009-01-24T06:37:30Z","messageCount":2,"participants":["Alexander Gavrilov","Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"101692","messageId":"200901240018.13457.angavrilov@gmail.com","threadId":"17329","inReplyTo":null,"subject":"[PATCH (GIT-GUI BUG)] git-gui: Fix post-commit status with subject in non-locale encoding.","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2009-01-23T21:18:13Z","receivedAt":"2009-01-23T21:18:13Z","isPatch":true,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"As pointed out in msysgit bug #181, when a non-locale encoding\nis used for commits, post-commit status messages display the\nsubject incorrectly. It happens because the file handle is\nnot properly configured before the subject is read back.\n\nThis patch fixes it by factoring out the code that is\nused to setup the output handle into a separate function,\nand calling it from the reading code.\n\nSigned-off-by: Alexander Gavrilov <angavrilov@gmail.com>\n---\n\n\tThe original bug report:\n\n\thttp://code.google.com/p/msysgit/issues/detail?id=181\n\n\n lib/commit.tcl |   29 +++++++++++++++++++----------\n 1 files changed, 19 insertions(+), 10 deletions(-)\n\ndiff --git a/lib/commit.tcl b/lib/commit.tcl\nindex 9cc8410..17aba91 100644\n--- a/lib/commit.tcl\n+++ b/lib/commit.tcl\n@@ -115,6 +115,23 @@ proc create_new_commit {} {\n \trescan ui_ready\n }\n \n+proc setup_commit_encoding {msg_wt {quiet 0}} {\n+\tglobal repo_config\n+\n+\tif {[catch {set enc $repo_config(i18n.commitencoding)}]} {\n+\t\tset enc utf-8\n+\t}\n+\tset use_enc [tcl_encoding $enc]\n+\tif {$use_enc ne {}} {\n+\t\tfconfigure $msg_wt -encoding $use_enc\n+\t} else {\n+\t\tif {!$quiet} {\n+\t\t\terror_popup [mc \"warning: Tcl does not support encoding '%s'.\" $enc]\n+\t\t}\n+\t\tfconfigure $msg_wt -encoding utf-8\n+\t}\n+}\n+\n proc commit_tree {} {\n \tglobal HEAD commit_type file_states ui_comm repo_config\n \tglobal pch_error\n@@ -200,16 +217,7 @@ A good commit message has the following format:\n \tset msg_p [gitdir GITGUI_EDITMSG]\n \tset msg_wt [open $msg_p w]\n \tfconfigure $msg_wt -translation lf\n-\tif {[catch {set enc $repo_config(i18n.commitencoding)}]} {\n-\t\tset enc utf-8\n-\t}\n-\tset use_enc [tcl_encoding $enc]\n-\tif {$use_enc ne {}} {\n-\t\tfconfigure $msg_wt -encoding $use_enc\n-\t} else {\n-\t\terror_popup [mc \"warning: Tcl does not support encoding '%s'.\" $enc]\n-\t\tfconfigure $msg_wt -encoding utf-8\n-\t}\n+\tsetup_commit_encoding $msg_wt\n \tputs $msg_wt $msg\n \tclose $msg_wt\n \n@@ -362,6 +370,7 @@ A rescan will be automatically started now.\n \t\tappend reflogm \" ($commit_type)\"\n \t}\n \tset msg_fd [open $msg_p r]\n+\tsetup_commit_encoding $msg_fd 1\n \tgets $msg_fd subject\n \tclose $msg_fd\n \tappend reflogm {: } $subject\n-- \n1.6.1.63.g950db\n"},{"id":"101732","messageId":"200901240737.31092.robin.rosenberg@gmail.com","threadId":"17329","inReplyTo":"200901240018.13457.angavrilov@gmail.com","subject":"Re: [PATCH (GIT-GUI BUG)] git-gui: Fix post-commit status with subject in non-locale encoding.","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg@gmail.com","sentAt":"2009-01-24T06:37:30Z","receivedAt":"2009-01-24T06:37:30Z","isPatch":true,"sender":{"key":"robin.rosenberg@gmail.com","avatar":null},"body":"fredag 23 januari 2009 22:18:13 skrev Alexander Gavrilov:\n> As pointed out in msysgit bug #181, when a non-locale encoding\n> is used for commits, post-commit status messages display the\n> subject incorrectly. It happens because the file handle is\n> not properly configured before the subject is read back.\n> \n> This patch fixes it by factoring out the code that is\n> used to setup the output handle into a separate function,\n> and calling it from the reading code.\n\nAck. Works fine now.\n\nThanks.\n\n-- robin\n"}]}