Skip to content

Commit ab30c04

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 6ea3006 commit ab30c04

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
@@ -7783,7 +7783,7 @@ proc gettree {id} {
77837783
set treepending $id
77847784
set treefilelist($id) {}
77857785
set treeidlist($id) {}
7786-
fconfigure $gtf -blocking 0 -encoding binary
7786+
fconfigure $gtf -blocking 0 -translation binary
77877787
filerun $gtf [list gettreeline $gtf $id]
77887788
}
77897789
} else {
@@ -8044,7 +8044,7 @@ proc gettreediffs {ids} {
80448044
80458045
set treepending $ids
80468046
set treediff {}
8047-
fconfigure $gdtf -blocking 0 -encoding binary
8047+
fconfigure $gdtf -blocking 0 -translation binary
80488048
filerun $gdtf [list gettreediffline $gdtf $ids]
80498049
}
80508050
@@ -8155,7 +8155,7 @@ proc getblobdiffs {ids} {
81558155
error_popup [mc "Error getting diffs: %s" $err]
81568156
return
81578157
}
8158-
fconfigure $bdf -blocking 0 -encoding binary -eofchar {}
8158+
fconfigure $bdf -blocking 0 -translation binary
81598159
set blobdifffd($ids) $bdf
81608160
initblobdiffvars
81618161
filerun $bdf [list getblobdiffline $bdf $diffids]

0 commit comments

Comments
 (0)