Message ID | pull.1599.git.1697619043944.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | git-gui: add support for filenames starting with tilde | expand |
"Matthias Aßhauer via GitGitGadget" <gitgitgadget@gmail.com> writes: > From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <mha1993@live.de> > > When git-gui encounters a file name starting with a tilde character (~), > TCL "helpfully" expands that tilde into a (probably non-existing) users > home directory. But in git-gui we're often not dealing with user supplied > paths, where such an expansion might be expected, but actual names of files. > > Prevent TCL from doing tilde expansion on these literal filenames. I do not have stake in git-gui (or gitk) and take the changes the subsystem owners have decided to take from them, but I have to wonder if this is merely robbing Peter to pay Paul? If the above description were not "we're often not" but "the only paths we use are repository relative, and a path that begin with a tilde NEVER refers to somebody's home directory", then I would buy into the change (but again, I am not even a user of git-gui, so take this with a moderate grains of salt). Thanks.
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh index 3e5907a4609..e8d60cf3324 100755 --- a/git-gui/git-gui.sh +++ b/git-gui/git-gui.sh @@ -2273,6 +2273,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/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl index 871ad488c2a..b7686caa962 100644 --- a/git-gui/lib/diff.tcl +++ b/git-gui/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/git-gui/lib/index.tcl b/git-gui/lib/index.tcl index d2ec24bd80e..2fbe1447975 100644 --- a/git-gui/lib/index.tcl +++ b/git-gui/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"]