git-gui: assure -eofchar {} on all channels

Per 6eb420ef61 ("git-gui: Always disable the Tcl EOF character when reading", 2007-07-17), git-gui should disable Tcl's EOF character detection on all files when on Windows: the default is disabled on all other platforms (and with Tcl 9.0, is disabled on Windows too). This EOF character is for compatibility with files / applications written for file systems that know only the disc sectors allocated, and not the number of bytes used. This has nothing to do with git. But, git-gui does not set -eofchar {} on all channels. To avoid any further leakage, let's just add this to the Windows specific override of open. This override is needed only as long as Tcl 8.x is in use (Tcl 9.0 makes -eofchar {} default on all platforms). Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>

Mark Levedahl committed May 21, 2025 at 17:38 UTC 847c8a2ec4e9504fd112be263c261f2ea2690444
6 files changed +8 -11
git-gui.sh
+4 -4
@@ -183,7 +183,9 @@ if {[is_Windows]} {
183 set command_line [string trim [string range $arg0 1 end]]
184 lset args 0 "| [sanitize_command_line $command_line 0]"
185 }
186 - uplevel 1 real_open $args
186 + set fd [real_open {*}$args]
187 + fconfigure $fd -eofchar {}
188 + return $fd
189 }
190
191 } else {
@@ -607,7 +609,6 @@ proc safe_open_command {cmd {redir {}}} {
609 } err]} {
610 error $err
611 }
610 - fconfigure $fd -eofchar {}
612 return $fd
613 }
614
@@ -1427,7 +1428,6 @@ proc load_message {file {encoding {}}} {
1428 if {[catch {set fd [safe_open_file $f r]}]} {
1429 return 0
1430 }
1430 - fconfigure $fd -eofchar {}
1431 if {$encoding ne {}} {
1432 fconfigure $fd -encoding $encoding
1433 }
@@ -1484,7 +1484,7 @@ proc run_prepare_commit_msg_hook {} {
1484 ui_status [mc "Calling prepare-commit-msg hook..."]
1485 set pch_error {}
1486
1487 - fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
1487 + fconfigure $fd_ph -blocking 0 -translation binary
1488 fileevent $fd_ph readable \
1489 [list prepare_commit_msg_hook_wait $fd_ph]
1490
lib/blame.tcl
-1
@@ -483,7 +483,6 @@ method _load {jump} {
483 } else {
484 set fd [safe_open_file $path r]
485 }
486 - fconfigure $fd -eofchar {}
486 } else {
487 if {$do_textconv ne 0} {
488 set fd [git_read [list cat-file --textconv "$commit:$path"]]
lib/checkout_op.tcl
+1 -1
@@ -462,7 +462,7 @@ If you wanted to be on a branch, create one now starting from 'This Detached Che
462 if {$fd_ph ne {}} {
463 global pch_error
464 set pch_error {}
465 - fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
465 + fconfigure $fd_ph -blocking 0 -translation binary
466 fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
467 } else {
468 _update_repo_state $this
lib/commit.tcl
+3 -3
@@ -252,7 +252,7 @@ A good commit message has the following format:
252
253 ui_status [mc "Calling pre-commit hook..."]
254 set pch_error {}
255 - fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
255 + fconfigure $fd_ph -blocking 0 -translation binary
256 fileevent $fd_ph readable \
257 [list commit_prehook_wait $fd_ph $curHEAD $msg_p]
258 }
@@ -307,7 +307,7 @@ Do you really want to proceed with your Commit?"]
307
308 ui_status [mc "Calling commit-msg hook..."]
309 set pch_error {}
310 - fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
310 + fconfigure $fd_ph -blocking 0 -translation binary
311 fileevent $fd_ph readable \
312 [list commit_commitmsg_wait $fd_ph $curHEAD $msg_p]
313 }
@@ -460,7 +460,7 @@ A rescan will be automatically started now.
460 if {$fd_ph ne {}} {
461 global pch_error
462 set pch_error {}
463 - fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
463 + fconfigure $fd_ph -blocking 0 -translation binary
464 fileevent $fd_ph readable \
465 [list commit_postcommit_wait $fd_ph $cmt_id]
466 }
lib/diff.tcl
-1
@@ -191,7 +191,6 @@ proc show_other_diff {path w m cont_info} {
191 file {
192 set fd [safe_open_file $path r]
193 fconfigure $fd \
194 - -eofchar {} \
194 -encoding [get_path_encoding $path]
195 set content [read $fd $max_sz]
196 close $fd
lib/spellcheck.tcl
-1
@@ -33,7 +33,6 @@ constructor init {pipe_fd ui_text ui_menu} {
33 method _connect {pipe_fd} {
34 fconfigure $pipe_fd \
35 -encoding utf-8 \
36 - -eofchar {} \
36 -translation lf
37
38 if {[gets $pipe_fd s_version] <= 0} {