Skip to content

Commit c99e238

Browse files
committed
gitk: switch to -translation binary
gitk uses '-encoding binary' in several places to handle non-text data. Per TIP 699, this is not recommended as there has been too much confusion and misconfiguration of binary channels, and this option is removed in Tcl 9. Tcl defines a binary channel as one that reproduces the input data exactly. As Tcl stores all data internally in unicode format, a binary channel requires 3 things: - -encoding iso8859-1 : this causes each byte of input to be translated to its unicode equivalent (may be multi-byte). - -translation lf : this avoids any translation of line endings, which by default are translated to \n on input. - -eofchar {} : this avoids any use of an end of file character, which is ctrl-z by default on Windows. The recommended '-translation binary' makes all three settings, but this is not done in gitk now. Rather, gitk uses '-encoding binary', which is an alias to '-encoding iso8859-1' removed by TIP 699, in multiple places, and -eofchar {} in one place but not all. All other files, configured in non-binary fashion, have -eofchar {}. Unix and Windows differ on line ending conventions, Tcl by default converts line endings to \n on input, and to those common on the platform on output. git emits only \n on Unix or Windows. Also, Tcl's proc gets recognizes and removes \n, \r, or \r\n as line endings, and this is used by gitk except in procs selectline and parsecommit. But, those two procs recognize any combination of \n and \r as terminating a line. So, there is no need to translate line endings on input, and using -translation binary avoids any such translation. Tcl sets eofchar to ctrl-z (ascii \0x1a) only on Windows, otherwise eofchar is {}. This provides compatibility to old DOS based codes and files originating when file systems recorded only sectors allocated, and not bytes used. git does not use ctrl-z to terminate data anywhere. Only two channels in gitk leave eofchar at the default value, both use -encoding binary now. A third one was converted in commit 681c329 ("gitk: Handle blobs containing a DOS end-of-file marker", 2009-03-16), fixing such a problem of early data termination. Using eofchar {} is correct, even if not always necessary. Tcl 9 forces change, using -translation binary per TIP 699 does what gitk needs and is backwards compatible to Tcl 8.x. Do it. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 1957249 commit c99e238

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

gitk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7819,7 +7819,7 @@ proc gettree {id} {
78197819
set treepending $id
78207820
set treefilelist($id) {}
78217821
set treeidlist($id) {}
7822-
fconfigure $gtf -blocking 0 -encoding binary
7822+
fconfigure $gtf -blocking 0 -translation binary
78237823
filerun $gtf [list gettreeline $gtf $id]
78247824
}
78257825
} else {
@@ -8082,7 +8082,7 @@ proc gettreediffs {ids} {
80828082
80838083
set treepending $ids
80848084
set treediff {}
8085-
fconfigure $gdtf -blocking 0 -encoding binary
8085+
fconfigure $gdtf -blocking 0 -translation binary
80868086
filerun $gdtf [list gettreediffline $gdtf $ids]
80878087
}
80888088
@@ -8202,7 +8202,7 @@ proc getblobdiffs {ids} {
82028202
error_popup [mc "Error getting diffs: %s" $err]
82038203
return
82048204
}
8205-
fconfigure $bdf -blocking 0 -encoding binary -eofchar {}
8205+
fconfigure $bdf -blocking 0 -translation binary
82068206
set blobdifffd($ids) $bdf
82078207
initblobdiffvars
82088208
filerun $bdf [list getblobdiffline $bdf $diffids]

0 commit comments

Comments
 (0)