summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2007-04-24 06:11:40 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2007-04-24 06:11:40 (GMT)
commitf20db5ff30af2169a0fe8a0afe015c30cdbe0256 (patch)
treed0a086489905620467f677af897ee6065f5f9668
parent845d377b2880a0c5d74f785244469ab1ac815bde (diff)
downloadgit-f20db5ff30af2169a0fe8a0afe015c30cdbe0256.zip
git-f20db5ff30af2169a0fe8a0afe015c30cdbe0256.tar.gz
git-f20db5ff30af2169a0fe8a0afe015c30cdbe0256.tar.bz2
git-gui: Correctly handle UTF-8 encoded commit messages
Uwe Kleine-K├Ânig discovered git-gui mangled his surname and did not send the proper UTF-8 byte sequence to git-commit-tree when his name appeared in the commit message (e.g. Signed-Off-By line). Turns out this was related to other trouble that I had in the past with trying to use "fconfigure $fd -encoding $enc" to select the stream encoding and let Tcl's IO engine do all of the encoding work for us. Other parts of git-gui were just always setting the file channels to "-encoding binary" and then performing the encoding work themselves using "encoding convertfrom" and "convertto", as that was the only way I could make UTF-8 filenames work properly. I found this same bug in the amend code path, and in the blame display. So its fixed in all three locations (commit creation, reloading message for amend, viewing message in blame). Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rwxr-xr-xgit-gui.sh46
1 files changed, 26 insertions, 20 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 94067cc..3f41bd7 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1067,8 +1067,8 @@ You are currently in the middle of a merge that has not been fully completed. Y
set enc [string tolower [string range $line 9 end]]
}
}
- fconfigure $fd -encoding $enc
- set msg [string trim [read $fd]]
+ set msg [encoding convertfrom $enc [read $fd]]
+ set msg [string trim $msg]
close $fd
} err]} {
error_popup "Error loading commit data for amend:\n\n$err"
@@ -1291,8 +1291,8 @@ A rescan will be automatically started now.
if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
set enc utf-8
}
- fconfigure $msg_wt -encoding $enc -translation binary
- puts -nonewline $msg_wt $msg
+ fconfigure $msg_wt -encoding binary -translation binary
+ puts -nonewline $msg_wt [encoding convertto $enc $msg]
close $msg_wt
# -- Create the commit.
@@ -3663,6 +3663,20 @@ proc blame_showcommit {w w_cmit w_line w_file lno} {
incr i
}
+ set author_name {}
+ set author_email {}
+ set author_time {}
+ catch {set author_name $blame_data($w,$cmit,author)}
+ catch {set author_email $blame_data($w,$cmit,author-mail)}
+ catch {set author_time [clock format $blame_data($w,$cmit,author-time)]}
+
+ set committer_name {}
+ set committer_email {}
+ set committer_time {}
+ catch {set committer_name $blame_data($w,$cmit,committer)}
+ catch {set committer_email $blame_data($w,$cmit,committer-mail)}
+ catch {set committer_time [clock format $blame_data($w,$cmit,committer-time)]}
+
if {[catch {set msg $blame_data($w,$cmit,message)}]} {
set msg {}
catch {
@@ -3676,27 +3690,19 @@ proc blame_showcommit {w w_cmit w_line w_file lno} {
set enc [string tolower [string range $line 9 end]]
}
}
- fconfigure $fd -encoding $enc
- set msg [string trim [read $fd]]
+ set msg [encoding convertfrom $enc [read $fd]]
+ set msg [string trim $msg]
close $fd
+
+ set author_name [encoding convertfrom $enc $author_name]
+ set committer_name [encoding convertfrom $enc $committer_name]
+
+ set blame_data($w,$cmit,author) $author_name
+ set blame_data($w,$cmit,committer) $committer_name
}
set blame_data($w,$cmit,message) $msg
}
- set author_name {}
- set author_email {}
- set author_time {}
- catch {set author_name $blame_data($w,$cmit,author)}
- catch {set author_email $blame_data($w,$cmit,author-mail)}
- catch {set author_time [clock format $blame_data($w,$cmit,author-time)]}
-
- set committer_name {}
- set committer_email {}
- set committer_time {}
- catch {set committer_name $blame_data($w,$cmit,committer)}
- catch {set committer_email $blame_data($w,$cmit,committer-mail)}
- catch {set committer_time [clock format $blame_data($w,$cmit,committer-time)]}
-
$w_cmit insert end "commit $cmit\n"
$w_cmit insert end "Author: $author_name $author_email $author_time\n"
$w_cmit insert end "Committer: $committer_name $committer_email $committer_time\n"