summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPat Thoyts <patthoyts@users.sourceforge.net>2012-04-19 11:19:58 +0100
committerPat Thoyts <patthoyts@users.sourceforge.net>2012-04-19 14:07:39 +0100
commitfda1ba02f3015310c3ac505292640c90bc97b172 (patch)
treedbea42c09270730f5d782ea24a49b661624e496a
parentc42939d24e5f48f7bce44771dbe22a879664faa1 (diff)
downloadgit-fda1ba02f3015310c3ac505292640c90bc97b172.tar.gz
git-gui: preserve commit messages in utf-8
The commit message buffer is automatically preserved to a local file but this uses the system encoding which may fail to properly encode unicode text. Forcing this file to use utf-8 preserves the message correctly. Reported-by: Ángel José Riesgo <ajriesgo@gmail.com> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
-rwxr-xr-xgit-gui.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 7dddc7dd24..936b367baf 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1464,7 +1464,7 @@ proc rescan {after {honor_trustmtime 1}} {
(![$ui_comm edit modified]
|| [string trim [$ui_comm get 0.0 end]] eq {})} {
if {[string match amend* $commit_type]} {
- } elseif {[load_message GITGUI_MSG]} {
+ } elseif {[load_message GITGUI_MSG utf-8]} {
} elseif {[run_prepare_commit_msg_hook]} {
} elseif {[load_message MERGE_MSG]} {
} elseif {[load_message SQUASH_MSG]} {
@@ -1550,7 +1550,7 @@ proc rescan_stage2 {fd after} {
fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
}
-proc load_message {file} {
+proc load_message {file {encoding {}}} {
global ui_comm
set f [gitdir $file]
@@ -1559,6 +1559,9 @@ proc load_message {file} {
return 0
}
fconfigure $fd -eofchar {}
+ if {$encoding ne {}} {
+ fconfigure $fd -encoding $encoding
+ }
set content [string trim [read $fd]]
close $fd
regsub -all -line {[ \r\t]+$} $content {} content
@@ -2267,6 +2270,7 @@ proc do_quit {{rc {1}}} {
&& $msg ne {}} {
catch {
set fd [open $save w]
+ fconfigure $fd -encoding utf-8
puts -nonewline $fd $msg
close $fd
}
@@ -3836,7 +3840,7 @@ if {[is_enabled transport]} {
}
if {[winfo exists $ui_comm]} {
- set GITGUI_BCK_exists [load_message GITGUI_BCK]
+ set GITGUI_BCK_exists [load_message GITGUI_BCK utf-8]
# -- If both our backup and message files exist use the
# newer of the two files to initialize the buffer.
@@ -3873,6 +3877,7 @@ if {[winfo exists $ui_comm]} {
} elseif {$m} {
catch {
set fd [open [gitdir GITGUI_BCK] w]
+ fconfigure $fd -encoding utf-8
puts -nonewline $fd $msg
close $fd
set GITGUI_BCK_exists 1