Skip to content

Commit 0f4b70c

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 futhermore 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. - -translation lf : this avoids any translation of line endings, which by default are translated \n. - -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, 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 dd22277 commit 0f4b70c

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
@@ -7811,7 +7811,7 @@ proc gettree {id} {
78117811
set treepending $id
78127812
set treefilelist($id) {}
78137813
set treeidlist($id) {}
7814-
fconfigure $gtf -blocking 0 -encoding binary
7814+
fconfigure $gtf -blocking 0 -translation binary
78157815
filerun $gtf [list gettreeline $gtf $id]
78167816
}
78177817
} else {
@@ -8074,7 +8074,7 @@ proc gettreediffs {ids} {
80748074
80758075
set treepending $ids
80768076
set treediff {}
8077-
fconfigure $gdtf -blocking 0 -encoding binary
8077+
fconfigure $gdtf -blocking 0 -translation binary
80788078
filerun $gdtf [list gettreediffline $gdtf $ids]
80798079
}
80808080
@@ -8194,7 +8194,7 @@ proc getblobdiffs {ids} {
81948194
error_popup [mc "Error getting diffs: %s" $err]
81958195
return
81968196
}
8197-
fconfigure $bdf -blocking 0 -encoding binary -eofchar {}
8197+
fconfigure $bdf -blocking 0 -translation binary
81988198
set blobdifffd($ids) $bdf
81998199
initblobdiffvars
82008200
filerun $bdf [list getblobdiffline $bdf $diffids]

0 commit comments

Comments
 (0)