git-gui: do not mix -translation binary and -encoding

git-gui has many instances of '-translation binary' and '-encoding $SOMETHING' on the same channel. As eofchar is always null given a prior commit, the net effect of having '-translation binary' in such configuration is only to change how text line endings are handled. For cases where the channel is opened to be consumed via gets, the eol translation is irrelevant because Tcl's gets is documented to recognize any of \n, \r, and \r\n as a line ending. So, keep only the '-encoding $SOMETHING' configuration in these cases, making the configuration more clear. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>

Mark Levedahl committed May 21, 2025 at 19:18 UTC 07714e220b7ee137f4645ec950383eaaeddf23d5
4 files changed +6 -6
git-gui.sh
+2 -2
@@ -592,7 +592,7 @@ proc git {args} {
592
593 proc git_redir {cmd redir} {
594 set fd [git_read $cmd $redir]
595 - fconfigure $fd -translation binary -encoding utf-8
595 + fconfigure $fd -encoding utf-8
596 set result [string trimright [read $fd] "\n"]
597 close $fd
598 if {$::_trace} {
@@ -1004,7 +1004,7 @@ proc _parse_config {arr_name args} {
1004 [concat config \
1005 $args \
1006 --null --list]]
1007 - fconfigure $fd_rc -translation binary -encoding utf-8
1007 + fconfigure $fd_rc -encoding utf-8
1008 set buf [read $fd_rc]
1009 close $fd_rc
1010 }
lib/branch.tcl
+2 -2
@@ -8,7 +8,7 @@ proc load_all_heads {} {
8 set rh_len [expr {[string length $rh] + 1}]
9 set all_heads [list]
10 set fd [git_read [list for-each-ref --format=%(refname) $rh]]
11 - fconfigure $fd -translation binary -encoding utf-8
11 + fconfigure $fd -encoding utf-8
12 while {[gets $fd line] > 0} {
13 if {!$some_heads_tracking || ![is_tracking_branch $line]} {
14 lappend all_heads [string range $line $rh_len end]
@@ -25,7 +25,7 @@ proc load_all_tags {} {
25 --sort=-taggerdate \
26 --format=%(refname) \
27 refs/tags]]
28 - fconfigure $fd -translation binary -encoding utf-8
28 + fconfigure $fd -encoding utf-8
29 while {[gets $fd line] > 0} {
30 if {![regsub ^refs/tags/ $line {} name]} continue
31 lappend all_tags $name
lib/browser.tcl
+1 -1
@@ -195,7 +195,7 @@ method _ls {tree_id {name {}}} {
195 $w conf -state disabled
196
197 set fd [git_read [list ls-tree -z $tree_id]]
198 - fconfigure $fd -blocking 0 -translation binary -encoding utf-8
198 + fconfigure $fd -blocking 0 -encoding utf-8
199 fileevent $fd readable [cb _read $fd]
200 }
201
lib/choose_rev.tcl
+1 -1
@@ -570,7 +570,7 @@ method _reflog_last {name} {
570 set last {}
571 if {[catch {set last [file mtime [gitdir $name]]}]
572 && ![catch {set g [safe_open_file [gitdir logs $name] r]}]} {
573 - fconfigure $g -translation binary
573 + fconfigure $g -encoding iso8859-1
574 while {[gets $g line] >= 0} {
575 if {[regexp {> ([1-9][0-9]*) } $line line when]} {
576 set last $when