Skip to content

Commit cc41d37

Browse files
committed
git-gui: use -profile tcl8 on encoding conversions
git-gui in the prior commit learned to apply -profile tcl8 when reading files, avoiding errors on non-binary data streams whose encoding is not utf-8. But, git-gui also consumes binary data streams (generally blobs from commits) as the output of commands, and internally decodes this to support various displays. With Tcl9, errors occur in this decoding for the same reasons described in the previous commit: basically, the underlying data may contain extended ascii characters violating the assumption of utf-8 encoding. This problem has a similar fix to the prior issue: we must use the tlc8 profile when converting this data to the internal unicode format. Do so, again only on Tcl9 as Tcl8.6 does not recognize -profile, and only Tcl 9.0 makes strict the default. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 24b1078 commit cc41d37

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

git-gui.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ if {[package vcompare $::tcl_version 9.0] >= 0} {
8484
chan configure $f -profile tcl8
8585
return $f
8686
}
87+
proc convertfrom args {
88+
return [encoding convertfrom -profile tcl8 {*}$args]
89+
}
90+
} else {
91+
proc convertfrom args {
92+
return [encoding convertfrom {*}$args]
93+
}
8794
}
8895

8996
######################################################################
@@ -1543,7 +1550,7 @@ proc read_diff_index {fd after} {
15431550
set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
15441551
set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
15451552
merge_state \
1546-
[encoding convertfrom utf-8 $p] \
1553+
[convertfrom utf-8 $p] \
15471554
[lindex $i 4]? \
15481555
[list [lindex $i 0] [lindex $i 2]] \
15491556
[list]
@@ -1576,7 +1583,7 @@ proc read_diff_files {fd after} {
15761583
set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
15771584
set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
15781585
merge_state \
1579-
[encoding convertfrom utf-8 $p] \
1586+
[convertfrom utf-8 $p] \
15801587
?[lindex $i 4] \
15811588
[list] \
15821589
[list [lindex $i 0] [lindex $i 2]]
@@ -1599,7 +1606,7 @@ proc read_ls_others {fd after} {
15991606
set pck [split $buf_rlo "\0"]
16001607
set buf_rlo [lindex $pck end]
16011608
foreach p [lrange $pck 0 end-1] {
1602-
set p [encoding convertfrom utf-8 $p]
1609+
set p [convertfrom utf-8 $p]
16031610
if {[string index $p end] eq {/}} {
16041611
set p [string range $p 0 end-1]
16051612
}

lib/blame.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ method _showcommit {cur_w lno} {
997997

998998
set enc [tcl_encoding $enc]
999999
if {$enc ne {}} {
1000-
set msg [encoding convertfrom $enc $msg]
1000+
set msg [convertfrom $enc $msg]
10011001
}
10021002
set msg [string trim $msg]
10031003
}

lib/commit.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ You are currently in the middle of a merge that has not been fully completed. Y
4343

4444
set enc [tcl_encoding $enc]
4545
if {$enc ne {}} {
46-
set msg [encoding convertfrom $enc $msg]
47-
set name [encoding convertfrom $enc $name]
48-
set email [encoding convertfrom $enc $email]
46+
set msg [convertfrom $enc $msg]
47+
set name [convertfrom $enc $name]
48+
set email [convertfrom $enc $email]
4949
}
5050
if {$name ne {} && $email ne {}} {
5151
set commit_author [list name $name email $email date $time]

0 commit comments

Comments
 (0)