git-gui: Fix commit encoding handling.
Commits without an encoding header are supposed to be encoded in utf8. While this apparently hasn't always been the case, currently it is the active convention, so it is better to follow it; otherwise people who have to use commitEncoding on their machines are unable to read utf-8 commits made by others. I also think that it is preferrable to display the warning about an unsupported value of commitEncoding more prominently, because this condition may lead to surprising behavior and, eventually, to loss of data. Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Alexander Gavrilov committed
Dec 6, 2008 at 20:24 UTC
3ac31e4451ff7c77c7ecbd639e685995e6a8dcc7
2 files changed
+5
-7
lib/blame.tcl
+2
-3
@@ -940,9 +940,8 @@ method _showcommit {cur_w lno} {
940
catch {
941
set fd [git_read cat-file commit $cmit]
942
fconfigure $fd -encoding binary -translation lf
943
- if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
944
- set enc utf-8
945
- }
943
+ # By default commits are assumed to be in utf-8
944
+ set enc utf-8
945
while {[gets $fd line] > 0} {
946
if {[string match {encoding *} $line]} {
947
set enc [string tolower [string range $line 9 end]]
lib/commit.tcl
+3
-4
@@ -27,9 +27,8 @@ You are currently in the middle of a merge that has not been fully completed. Y
27
if {[catch {
28
set fd [git_read cat-file commit $curHEAD]
29
fconfigure $fd -encoding binary -translation lf
30
- if {[catch {set enc $repo_config(i18n.commitencoding)}]} {
31
- set enc utf-8
32
- }
30
+ # By default commits are assumed to be in utf-8
31
+ set enc utf-8
32
while {[gets $fd line] > 0} {
33
if {[string match {parent *} $line]} {
34
lappend parents [string range $line 7 end]
@@ -208,7 +207,7 @@ A good commit message has the following format:
207
if {$use_enc ne {}} {
208
fconfigure $msg_wt -encoding $use_enc
209
} else {
211
- puts stderr [mc "warning: Tcl does not support encoding '%s'." $enc]
210
+ error_popup [mc "warning: Tcl does not support encoding '%s'." $enc]
211
fconfigure $msg_wt -encoding utf-8
212
}
213
puts $msg_wt $msg