{"thread":{"id":"60392","subject":"[PATCH] git-gui: add support for filenames starting with tilde","startedAt":"2023-10-18T08:50:49Z","lastAt":"2023-10-18T18:52:31Z","messageCount":2,"participants":["Matthias Aßhauer via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"483397","messageId":"pull.1599.git.1697619043944.gitgitgadget@gmail.com","threadId":"60392","inReplyTo":null,"subject":"[PATCH] git-gui: add support for filenames starting with tilde","fromName":"Matthias Aßhauer via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-10-18T08:50:43Z","receivedAt":"2023-10-18T08:50:49Z","isPatch":true,"sender":{"key":"mha1993@live.de","avatar":"https://avatars.githubusercontent.com/u/6178234?v=4"},"body":"From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <mha1993@live.de>\n\nWhen git-gui encounters a file name starting with a tilde character (~),\nTCL \"helpfully\" expands that tilde into a (probably non-existing) users\nhome directory. But in git-gui we're often not dealing with user supplied\npaths, where such an expansion might be expected, but actual names of files.\n\nPrevent TCL from doing tilde expansion on these literal filenames.\n\nThis fixes https://github.com/git-for-windows/git/issues/4349\n\nSigned-off-by: Matthias Aßhauer <mha1993@live.de>\n---\n    git-gui: add support for filenames starting with tilde\n    \n    I've originally submitted this patch as a pull request to Pratyush's\n    git-gui repository [1] on March 23rd, but that hasn't received any\n    feedback in almost seven months, so I'm resubmitting it on the mailing\n    list, with an improved patch description.\n    \n    [1] https://github.com/prati0100/git-gui/pull/96\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1599%2Frimrul%2Fgit-gui-tilde-filenames-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1599/rimrul/git-gui-tilde-filenames-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1599\n\n git-gui/git-gui.sh    | 1 +\n git-gui/lib/diff.tcl  | 1 +\n git-gui/lib/index.tcl | 2 +-\n 3 files changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh\nindex 3e5907a4609..e8d60cf3324 100755\n--- a/git-gui/git-gui.sh\n+++ b/git-gui/git-gui.sh\n@@ -2273,6 +2273,7 @@ proc do_explore {} {\n # Open file relative to the working tree by the default associated app.\n proc do_file_open {file} {\n \tglobal _gitworktree\n+\tif {[string index $file 0] eq {~}} {set file ./$file}\n \tset explorer [get_explorer]\n \tset full_file_path [file join $_gitworktree $file]\n \texec $explorer [file nativename $full_file_path] &\ndiff --git a/git-gui/lib/diff.tcl b/git-gui/lib/diff.tcl\nindex 871ad488c2a..b7686caa962 100644\n--- a/git-gui/lib/diff.tcl\n+++ b/git-gui/lib/diff.tcl\n@@ -190,6 +190,7 @@ proc show_other_diff {path w m cont_info} {\n \t\tset max_sz 100000\n \t\tset type unknown\n \t\tif {[catch {\n+\t\t\t\tif {[string index $path 0] eq {~}} {set path ./$path}\n \t\t\t\tset type [file type $path]\n \t\t\t\tswitch -- $type {\n \t\t\t\tdirectory {\ndiff --git a/git-gui/lib/index.tcl b/git-gui/lib/index.tcl\nindex d2ec24bd80e..2fbe1447975 100644\n--- a/git-gui/lib/index.tcl\n+++ b/git-gui/lib/index.tcl\n@@ -617,7 +617,7 @@ proc delete_helper {path_list path_index deletion_errors batch_size \\\n \n \t\tset path [lindex $path_list $path_index]\n \n-\t\tset deletion_failed [catch {file delete -- $path} deletion_error]\n+\t\tset deletion_failed [catch {file delete -- ./$path} deletion_error]\n \n \t\tif {$deletion_failed} {\n \t\t\tlappend deletion_errors [list \"$deletion_error\"]\n\nbase-commit: a9ecda2788e229afc9b611acaa26d0d9d4da53ed\n-- \ngitgitgadget\n"},{"id":"483446","messageId":"xmqqpm1bsqz8.fsf@gitster.g","threadId":"60392","inReplyTo":"pull.1599.git.1697619043944.gitgitgadget@gmail.com","subject":"Re: [PATCH] git-gui: add support for filenames starting with tilde","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-10-18T18:52:27Z","receivedAt":"2023-10-18T18:52:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Matthias Aßhauer via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= <mha1993@live.de>\n>\n> When git-gui encounters a file name starting with a tilde character (~),\n> TCL \"helpfully\" expands that tilde into a (probably non-existing) users\n> home directory. But in git-gui we're often not dealing with user supplied\n> paths, where such an expansion might be expected, but actual names of files.\n>\n> Prevent TCL from doing tilde expansion on these literal filenames.\n\nI do not have stake in git-gui (or gitk) and take the changes the\nsubsystem owners have decided to take from them, but I have to\nwonder if this is merely robbing Peter to pay Paul?\n\nIf the above description were not \"we're often not\" but \"the only\npaths we use are repository relative, and a path that begin with a\ntilde NEVER refers to somebody's home directory\", then I would buy\ninto the change (but again, I am not even a user of git-gui, so take\nthis with a moderate grains of salt).\n\nThanks.\n"}]}