Skip to content

Commit 847c8a2

Browse files
committed
git-gui: assure -eofchar {} on all channels
Per 6eb420e ("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 <[email protected]>
1 parent 436dad0 commit 847c8a2

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

git-gui.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ if {[is_Windows]} {
183183
set command_line [string trim [string range $arg0 1 end]]
184184
lset args 0 "| [sanitize_command_line $command_line 0]"
185185
}
186-
uplevel 1 real_open $args
186+
set fd [real_open {*}$args]
187+
fconfigure $fd -eofchar {}
188+
return $fd
187189
}
188190
189191
} else {
@@ -607,7 +609,6 @@ proc safe_open_command {cmd {redir {}}} {
607609
} err]} {
608610
error $err
609611
}
610-
fconfigure $fd -eofchar {}
611612
return $fd
612613
}
613614

@@ -1427,7 +1428,6 @@ proc load_message {file {encoding {}}} {
14271428
if {[catch {set fd [safe_open_file $f r]}]} {
14281429
return 0
14291430
}
1430-
fconfigure $fd -eofchar {}
14311431
if {$encoding ne {}} {
14321432
fconfigure $fd -encoding $encoding
14331433
}
@@ -1484,7 +1484,7 @@ proc run_prepare_commit_msg_hook {} {
14841484
ui_status [mc "Calling prepare-commit-msg hook..."]
14851485
set pch_error {}
14861486

1487-
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
1487+
fconfigure $fd_ph -blocking 0 -translation binary
14881488
fileevent $fd_ph readable \
14891489
[list prepare_commit_msg_hook_wait $fd_ph]
14901490

lib/blame.tcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ method _load {jump} {
483483
} else {
484484
set fd [safe_open_file $path r]
485485
}
486-
fconfigure $fd -eofchar {}
487486
} else {
488487
if {$do_textconv ne 0} {
489488
set fd [git_read [list cat-file --textconv "$commit:$path"]]

lib/checkout_op.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ If you wanted to be on a branch, create one now starting from 'This Detached Che
462462
if {$fd_ph ne {}} {
463463
global pch_error
464464
set pch_error {}
465-
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
465+
fconfigure $fd_ph -blocking 0 -translation binary
466466
fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
467467
} else {
468468
_update_repo_state $this

lib/commit.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ A good commit message has the following format:
252252

253253
ui_status [mc "Calling pre-commit hook..."]
254254
set pch_error {}
255-
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
255+
fconfigure $fd_ph -blocking 0 -translation binary
256256
fileevent $fd_ph readable \
257257
[list commit_prehook_wait $fd_ph $curHEAD $msg_p]
258258
}
@@ -307,7 +307,7 @@ Do you really want to proceed with your Commit?"]
307307

308308
ui_status [mc "Calling commit-msg hook..."]
309309
set pch_error {}
310-
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
310+
fconfigure $fd_ph -blocking 0 -translation binary
311311
fileevent $fd_ph readable \
312312
[list commit_commitmsg_wait $fd_ph $curHEAD $msg_p]
313313
}
@@ -460,7 +460,7 @@ A rescan will be automatically started now.
460460
if {$fd_ph ne {}} {
461461
global pch_error
462462
set pch_error {}
463-
fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
463+
fconfigure $fd_ph -blocking 0 -translation binary
464464
fileevent $fd_ph readable \
465465
[list commit_postcommit_wait $fd_ph $cmt_id]
466466
}

lib/diff.tcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ proc show_other_diff {path w m cont_info} {
191191
file {
192192
set fd [safe_open_file $path r]
193193
fconfigure $fd \
194-
-eofchar {} \
195194
-encoding [get_path_encoding $path]
196195
set content [read $fd $max_sz]
197196
close $fd

lib/spellcheck.tcl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ constructor init {pipe_fd ui_text ui_menu} {
3333
method _connect {pipe_fd} {
3434
fconfigure $pipe_fd \
3535
-encoding utf-8 \
36-
-eofchar {} \
3736
-translation lf
3837

3938
if {[gets $pipe_fd s_version] <= 0} {

0 commit comments

Comments
 (0)