]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui: assure -eofchar {} on all channels
authorMark Levedahl <mlevedahl@gmail.com>
Wed, 21 May 2025 21:38:10 +0000 (17:38 -0400)
committerMark Levedahl <mlevedahl@gmail.com>
Tue, 22 Jul 2025 16:32:58 +0000 (12:32 -0400)
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>
git-gui.sh
lib/blame.tcl
lib/checkout_op.tcl
lib/commit.tcl
lib/diff.tcl
lib/spellcheck.tcl

index 8bb121db4f5f8c12b780aa65c0f00a658ce9f924..e9c2650bcf756f12e314d7358eeae2f8c72e38b9 100755 (executable)
@@ -183,7 +183,9 @@ if {[is_Windows]} {
                        set command_line [string trim [string range $arg0 1 end]]
                        lset args 0 "| [sanitize_command_line $command_line 0]"
                }
-               uplevel 1 real_open $args
+               set fd [real_open {*}$args]
+               fconfigure $fd -eofchar {}
+               return $fd
        }
 
 } else {
@@ -607,7 +609,6 @@ proc safe_open_command {cmd {redir {}}} {
        } err]} {
                error $err
        }
-       fconfigure $fd -eofchar {}
        return $fd
 }
 
@@ -1427,7 +1428,6 @@ proc load_message {file {encoding {}}} {
                if {[catch {set fd [safe_open_file $f r]}]} {
                        return 0
                }
-               fconfigure $fd -eofchar {}
                if {$encoding ne {}} {
                        fconfigure $fd -encoding $encoding
                }
@@ -1484,7 +1484,7 @@ proc run_prepare_commit_msg_hook {} {
        ui_status [mc "Calling prepare-commit-msg hook..."]
        set pch_error {}
 
-       fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
+       fconfigure $fd_ph -blocking 0 -translation binary
        fileevent $fd_ph readable \
                [list prepare_commit_msg_hook_wait $fd_ph]
 
index 9d4d1ac8723d36246e9f057588a88e6e3537dc90..63a59fdbb348ca46042c2404e462d640437106c1 100644 (file)
@@ -483,7 +483,6 @@ method _load {jump} {
                } else {
                        set fd [safe_open_file $path r]
                }
-               fconfigure $fd -eofchar {}
        } else {
                if {$do_textconv ne 0} {
                        set fd [git_read [list cat-file --textconv "$commit:$path"]]
index 987486a4b6024bd1ba1a53763ad7d57e7d610650..449e89e2bc0c0ef7bbbf72ef425f3c1dd4966bb9 100644 (file)
@@ -462,7 +462,7 @@ If you wanted to be on a branch, create one now starting from 'This Detached Che
        if {$fd_ph ne {}} {
                global pch_error
                set pch_error {}
-               fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
+               fconfigure $fd_ph -blocking 0 -translation binary
                fileevent $fd_ph readable [cb _postcheckout_wait $fd_ph]
        } else {
                _update_repo_state $this
index 2fd57a51fb085a4750290e76f6466b1b1de6b9b2..d6313e568b2bad381f4f1d1f60c06b66f9150aea 100644 (file)
@@ -252,7 +252,7 @@ A good commit message has the following format:
 
        ui_status [mc "Calling pre-commit hook..."]
        set pch_error {}
-       fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
+       fconfigure $fd_ph -blocking 0 -translation binary
        fileevent $fd_ph readable \
                [list commit_prehook_wait $fd_ph $curHEAD $msg_p]
 }
@@ -307,7 +307,7 @@ Do you really want to proceed with your Commit?"]
 
        ui_status [mc "Calling commit-msg hook..."]
        set pch_error {}
-       fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
+       fconfigure $fd_ph -blocking 0 -translation binary
        fileevent $fd_ph readable \
                [list commit_commitmsg_wait $fd_ph $curHEAD $msg_p]
 }
@@ -460,7 +460,7 @@ A rescan will be automatically started now.
        if {$fd_ph ne {}} {
                global pch_error
                set pch_error {}
-               fconfigure $fd_ph -blocking 0 -translation binary -eofchar {}
+               fconfigure $fd_ph -blocking 0 -translation binary
                fileevent $fd_ph readable \
                        [list commit_postcommit_wait $fd_ph $cmt_id]
        }
index 1acd37bdb4c6e88817caf27a35bc46ee55572bbd..65d0997b79b55533a849df88fb2a2030b1dbbd11 100644 (file)
@@ -191,7 +191,6 @@ proc show_other_diff {path w m cont_info} {
                                file {
                                        set fd [safe_open_file $path r]
                                        fconfigure $fd \
-                                               -eofchar {} \
                                                -encoding [get_path_encoding $path]
                                        set content [read $fd $max_sz]
                                        close $fd
index 538d61c792defa7a8e19736039fa5a9af630125c..634656820dc526b29ae0f946d3befcbad76f3fb2 100644 (file)
@@ -33,7 +33,6 @@ constructor init {pipe_fd ui_text ui_menu} {
 method _connect {pipe_fd} {
        fconfigure $pipe_fd \
                -encoding utf-8 \
-               -eofchar {} \
                -translation lf
 
        if {[gets $pipe_fd s_version] <= 0} {