From bf0ac3287698e2694f4315f7c17e9c857b8855ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Thu, 23 Mar 2023 13:26:35 +0100 Subject: [PATCH] git-gui: add support for filenames starting with tilde MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit prevent TCL from doing tilde expansion on literal filenames. This fixes https://github.com/git-for-windows/git/issues/4349 Signed-off-by: Matthias Aßhauer --- git-gui.sh | 1 + lib/diff.tcl | 1 + lib/index.tcl | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/git-gui.sh b/git-gui.sh index cb92bba1c4..296a628b34 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2338,6 +2338,7 @@ proc do_explore {} { # Open file relative to the working tree by the default associated app. proc do_file_open {file} { global _gitworktree + if {[string index $file 0] eq {~}} {set file ./$file} set explorer [get_explorer] set full_file_path [file join $_gitworktree $file] exec $explorer [file nativename $full_file_path] & diff --git a/lib/diff.tcl b/lib/diff.tcl index 871ad488c2..b7686caa96 100644 --- a/lib/diff.tcl +++ b/lib/diff.tcl @@ -190,6 +190,7 @@ proc show_other_diff {path w m cont_info} { set max_sz 100000 set type unknown if {[catch { + if {[string index $path 0] eq {~}} {set path ./$path} set type [file type $path] switch -- $type { directory { diff --git a/lib/index.tcl b/lib/index.tcl index d2ec24bd80..2fbe144797 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -617,7 +617,7 @@ proc delete_helper {path_list path_index deletion_errors batch_size \ set path [lindex $path_list $path_index] - set deletion_failed [catch {file delete -- $path} deletion_error] + set deletion_failed [catch {file delete -- ./$path} deletion_error] if {$deletion_failed} { lappend deletion_errors [list "$deletion_error"]