{"thread":{"id":"52523","subject":"[PATCH 0/1] git-gui: add possibility to open currently selected file","startedAt":"2019-12-26T19:02:00Z","lastAt":"2019-12-30T20:31:31Z","messageCount":14,"participants":["Zoli Szabó via GitGitGadget","Pratyush Yadav","Junio C Hamano","Zoli Szabó"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"388938","messageId":"pull.499.git.1577386915.gitgitgadget@gmail.com","threadId":"52523","inReplyTo":null,"subject":"[PATCH 0/1] git-gui: add possibility to open currently selected file","fromName":"Zoli Szabó via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-26T19:01:54Z","receivedAt":"2019-12-26T19:02:00Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"...in the default associated app (e.g. in a text editor / IDE).\n\nMany times there's the need to quickly open a source file (the one you're\nlooking at in Git GUI) in the predefined text editor / IDE. Of course, the\nfile can be searched for in your preferred file manager or directly in the\ntext editor, but having the option to directly open the current file from\nGit GUI would be just faster. This change enables just that by:\n\n * Diff header path context menu -> Open;\n * or double-clicking the diff header path.\n\nOne \"downside\" of the approach is that executable files will be run and not\nopened for editing.\n\nSigned-off-by: Zoli Szabó zoli.szabo@gmail.com [zoli.szabo@gmail.com]\n\nZoli Szabó (1):\n  git-gui: add possibility to open currently selected file\n\n git-gui.sh | 26 ++++++++++++++++++++++++--\n 1 file changed, 24 insertions(+), 2 deletions(-)\n\n\nbase-commit: 23cbe427c44645a3ab0449919e55bade5eb264bc\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-499%2Fzoliszabo%2Fgit-gui%2Fopen-current-file-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-499/zoliszabo/git-gui/open-current-file-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/499\n-- \ngitgitgadget\n"},{"id":"388939","messageId":"fce80f1b95f83915076640ca0be01aa473744777.1577386915.git.gitgitgadget@gmail.com","threadId":"52523","inReplyTo":"pull.499.git.1577386915.gitgitgadget@gmail.com","subject":"[PATCH 1/1] git-gui: add possibility to open currently selected file","fromName":"Zoli Szabó via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-26T19:01:55Z","receivedAt":"2019-12-26T19:02:01Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"From: =?UTF-8?q?Zoli=20Szab=C3=B3?= <zoli.szabo@gmail.com>\n\n...in the default associated app (e.g. in a text editor / IDE).\n\nMany times there's the need to quickly open a source file (the one you're\nlooking at in Git GUI) in the predefined text editor / IDE. Of course,\nthe file can be searched for in your preferred file manager or directly\nin the text editor, but having the option to directly open the current\nfile from Git GUI would be just faster. This change enables just that by:\n - Diff header path context menu -> Open;\n - or double-clicking the diff header path.\n\nOne \"downside\" of the approach is that executable files will be run\nand not opened for editing.\n\nSigned-off-by: Zoli Szabó <zoli.szabo@gmail.com>\n---\n git-gui.sh | 26 ++++++++++++++++++++++++--\n 1 file changed, 24 insertions(+), 2 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex c1be733e3e..705b97f7ab 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2248,8 +2248,8 @@ proc do_git_gui {} {\n \t}\n }\n \n-proc do_explore {} {\n-\tglobal _gitworktree\n+# Get the system-specific explorer app/command.\n+proc get_explorer {} {\n \tset explorer {}\n \tif {[is_Cygwin] || [is_Windows]} {\n \t\tset explorer \"explorer.exe\"\n@@ -2259,9 +2259,25 @@ proc do_explore {} {\n \t\t# freedesktop.org-conforming system is our best shot\n \t\tset explorer \"xdg-open\"\n \t}\n+\treturn $explorer\n+}\n+\n+proc do_explore {} {\n+\tglobal _gitworktree\n+\tset explorer [get_explorer]\n \teval exec $explorer [list [file nativename $_gitworktree]] &\n }\n \n+# Trigger opening a file (relative to the working tree) by the default\n+# associated app of the OS (e.g. a text editor or IDE).\n+# FIXME: What about executables (will be run, not opened for editing)?\n+proc do_file_open {file} {\n+\tglobal _gitworktree\n+\tset explorer [get_explorer]\n+\tset full_file_path [file join $_gitworktree $file]\n+\teval exec $explorer [list [file nativename $full_file_path]] &\n+}\n+\n set is_quitting 0\n set ret_code    1\n \n@@ -3530,8 +3546,14 @@ $ctxm add command \\\n \t\t\t-type STRING \\\n \t\t\t-- $current_diff_path\n \t}\n+$ctxm add command \\\n+\t-label [mc Open] \\\n+\t-command {\n+\t\tdo_file_open $current_diff_path\n+\t}\n lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]\n bind_button3 .vpane.lower.diff.header.path \"tk_popup $ctxm %X %Y\"\n+bind .vpane.lower.diff.header.path <Double-1> {do_file_open $current_diff_path}\n \n # -- Diff Body\n #\n-- \ngitgitgadget\n"},{"id":"389000","messageId":"20191227193418.36uzeizs37nv7ywb@yadavpratyush.com","threadId":"52523","inReplyTo":"fce80f1b95f83915076640ca0be01aa473744777.1577386915.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] git-gui: add possibility to open currently selected file","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-12-27T19:34:18Z","receivedAt":"2019-12-27T19:36:20Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Zoli,\n\nThanks for the patch.\n\nOn 26/12/19 07:01PM, Zoli Szabó via GitGitGadget wrote:\n> From: =?UTF-8?q?Zoli=20Szab=C3=B3?= <zoli.szabo@gmail.com>\n> \n> ...in the default associated app (e.g. in a text editor / IDE).\n> \n> Many times there's the need to quickly open a source file (the one you're\n> looking at in Git GUI) in the predefined text editor / IDE. Of course,\n> the file can be searched for in your preferred file manager or directly\n> in the text editor, but having the option to directly open the current\n> file from Git GUI would be just faster. This change enables just that by:\n>  - Diff header path context menu -> Open;\n\nWould it be a better idea to have this option in the diff body context \nmenu (.vpane.lower.diff.body.ctxm) instead? The problem I see with the \nway its currently done is visibility/discovery. It is not very likely \nfor a user to try and click the file name which doesn't give any \nindication that it is clickable. So how will someone who hasn't read \nthis commit message know that they can use this neat feature. The diff \nbody context menu is much more \"visible\" IMO.\n\n>  - or double-clicking the diff header path.\n\nAn alternative to the above suggestion would be to make this path \nunderlined and blue in color (like a hyperlink in a web browser). This \nwill give the indication that this is not just plain text.\n\nI like the latter idea more, but I don't mind either.\n \n> One \"downside\" of the approach is that executable files will be run\n> and not opened for editing.\n\nFWIW, I do not see it as a downside at all. The menu option is called \n\"open\" not \"edit\". So if you click it, you should expect the file to \nopen. In case its a binary file, executing it is the correct outcome. In \ncase its a text file, opening it in the editor is the correct outcome.\n \n> Signed-off-by: Zoli Szabó <zoli.szabo@gmail.com>\n> ---\n>  git-gui.sh | 26 ++++++++++++++++++++++++--\n>  1 file changed, 24 insertions(+), 2 deletions(-)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index c1be733e3e..705b97f7ab 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -2248,8 +2248,8 @@ proc do_git_gui {} {\n>  \t}\n>  }\n>  \n> -proc do_explore {} {\n> -\tglobal _gitworktree\n> +# Get the system-specific explorer app/command.\n> +proc get_explorer {} {\n>  \tset explorer {}\n\nNot exactly related to this patch, but this line is redundant. No point \nin clearing 'explorer' only to set it in the very next if-else chain.\n\n>  \tif {[is_Cygwin] || [is_Windows]} {\n>  \t\tset explorer \"explorer.exe\"\n> @@ -2259,9 +2259,25 @@ proc do_explore {} {\n>  \t\t# freedesktop.org-conforming system is our best shot\n>  \t\tset explorer \"xdg-open\"\n>  \t}\n> +\treturn $explorer\n> +}\n> +\n> +proc do_explore {} {\n> +\tglobal _gitworktree\n> +\tset explorer [get_explorer]\n>  \teval exec $explorer [list [file nativename $_gitworktree]] &\n>  }\n>  \n> +# Trigger opening a file (relative to the working tree) by the default\n> +# associated app of the OS (e.g. a text editor or IDE).\n\nNitpick: This comment doesn't really add a whole lot of information. The \nprocedure name already make it pretty clear that it will open a file. \nAnd it is pretty easy to understand from reading the body of the \nprocedure that it will be relative to the working tree. So, I think it \ncan be removed altogether.\n\nBut even if you think it should stay, please at least make it more \nconcise. Maybe something like:\n\n  Open file relative to the working tree by the default associated app.\n\n> +# FIXME: What about executables (will be run, not opened for editing)?\n\nAgain, I think running the executables is the correct behaviour. So I \ndon't think this needs any fixing.\n\n> +proc do_file_open {file} {\n> +\tglobal _gitworktree\n> +\tset explorer [get_explorer]\n> +\tset full_file_path [file join $_gitworktree $file]\n> +\teval exec $explorer [list [file nativename $full_file_path]] &\n\nThis executes $explorer, which is 'explorer.exe' on Windows. I'm not a \nheavy Windows user but AFAIK it is a file manager. This makes it quite \ndifferent from 'xdg-open' which is used to open _any_ file/URL in the \nuser's default application. So it also happens to open _directories_ in \nthe default file explorer which was the original intention of this \nprocedure.\n\nHave you tested it on Windows? Does 'explorer.exe' do the correct thing? \n\nLooking at MacOS's 'open' man page, I think it should also work like \nxdg-open and shouldn't be a problem.\n\n> +}\n> +\n>  set is_quitting 0\n>  set ret_code    1\n>  \n> @@ -3530,8 +3546,14 @@ $ctxm add command \\\n>  \t\t\t-type STRING \\\n>  \t\t\t-- $current_diff_path\n>  \t}\n> +$ctxm add command \\\n> +\t-label [mc Open] \\\n> +\t-command {\n> +\t\tdo_file_open $current_diff_path\n> +\t}\n\nNitpick: no need to make the command multi-line. So, change it to \nsomething like:\n\n  -command {do_file_open $current_diff_path}\n\n>  lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]\n>  bind_button3 .vpane.lower.diff.header.path \"tk_popup $ctxm %X %Y\"\n> +bind .vpane.lower.diff.header.path <Double-1> {do_file_open $current_diff_path}\n>  \n>  # -- Diff Body\n>  #\n\nTested on Linux. Works fine. Looking forward to the re-roll.\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"389012","messageId":"xmqqy2uxiemt.fsf@gitster-ct.c.googlers.com","threadId":"52523","inReplyTo":"20191227193418.36uzeizs37nv7ywb@yadavpratyush.com","subject":"Re: [PATCH 1/1] git-gui: add possibility to open currently selected file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-12-27T22:32:10Z","receivedAt":"2019-12-27T22:32:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pratyush Yadav <me@yadavpratyush.com> writes:\n\n> Have you tested it on Windows? Does 'explorer.exe' do the correct thing? \n>\n> Looking at MacOS's 'open' man page, I think it should also work like \n> xdg-open and shouldn't be a problem.\n> ...\n> Tested on Linux. Works fine. Looking forward to the re-roll.\n\n> Subject: Re: [PATCH 1/1] git-gui: add possibility to open currently selected file\n\nThe phrasing on the title is a bit awkward.  \"add possibility to do\nX\" is better spelled \"allow doing X\", no?\n"},{"id":"389028","messageId":"c681ca1b-cdcb-d021-95a9-ca3ad944cfa3@gmail.com","threadId":"52523","inReplyTo":"20191227193418.36uzeizs37nv7ywb@yadavpratyush.com","subject":"Re: Re: [PATCH 1/1] git-gui: add possibility to open currently selected file","fromName":"Zoli Szabó","fromEmail":"zoli.szabo@gmail.com","sentAt":"2019-12-29T13:23:37Z","receivedAt":"2019-12-29T13:23:41Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"Hi Pratyush,\n\nThanks for your thorough review.\n\nOn 2019.12.27 21:34, Pratyush Yadav wrote:\n>> ...This change enables just that by:\n>>   - Diff header path context menu -> Open;\n> \n> Would it be a better idea to have this option in the diff body context\n> menu (.vpane.lower.diff.body.ctxm) instead? The problem I see with the\n> way its currently done is visibility/discovery. It is not very likely\n> for a user to try and click the file name which doesn't give any\n> indication that it is clickable. So how will someone who hasn't read\n> this commit message know that they can use this neat feature. The diff\n> body context menu is much more \"visible\" IMO.\n> \n>>   - or double-clicking the diff header path.\n> \n> An alternative to the above suggestion would be to make this path\n> underlined and blue in color (like a hyperlink in a web browser). This\n> will give the indication that this is not just plain text.\n> \n> I like the latter idea more, but I don't mind either.\n\nFor me, the body context menu holds the diff-related options, I am not \nsure the \"Open\" fits in there. But I do like your suggestion of making \nthe filename web browser-link-like. I'll try to implement that.\n\n\n>> One \"downside\" of the approach is that executable files will be run\n>> and not opened for editing.\n> \n> FWIW, I do not see it as a downside at all. The menu option is called\n> \"open\" not \"edit\". So if you click it, you should expect the file to\n> open. In case its a binary file, executing it is the correct outcome. In\n> case its a text file, opening it in the editor is the correct outcome.\n\nAlright then.\n\n>> +proc do_file_open {file} {\n>> +\tglobal _gitworktree\n>> +\tset explorer [get_explorer]\n>> +\tset full_file_path [file join $_gitworktree $file]\n>> +\teval exec $explorer [list [file nativename $full_file_path]] &\n> \n> This executes $explorer, which is 'explorer.exe' on Windows. I'm not a\n> heavy Windows user but AFAIK it is a file manager. This makes it quite\n> different from 'xdg-open' which is used to open _any_ file/URL in the\n> user's default application. So it also happens to open _directories_ in\n> the default file explorer which was the original intention of this\n> procedure.\n> \n> Have you tested it on Windows? Does 'explorer.exe' do the correct thing?\n> \n> Looking at MacOS's 'open' man page, I think it should also work like\n> xdg-open and shouldn't be a problem.\n\nI am in fact working on this patch on Windows. explorer.exe works also \nfor files and even brings up the \"Open with...\" dialog for \nnot-recognized file types.\n\n> Tested on Linux. Works fine. Looking forward to the re-roll.\n\nThanks for testing it on Linux. Since I am working on Windows, I just \nread about `xdg-open` and `open` and assumed everything should work OK.\n\nAll other points I agree with you and will push a new version of the patch.\n\nThanks,\nZoli\n"},{"id":"389039","messageId":"a6fde256f818f934beb0228db95ac551ddb5d6b1.1577647930.git.gitgitgadget@gmail.com","threadId":"52523","inReplyTo":"pull.499.v2.git.1577647930.gitgitgadget@gmail.com","subject":"[PATCH v2 1/1] git-gui: allow opening currently selected file","fromName":"Zoli Szabó via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-29T19:32:10Z","receivedAt":"2019-12-29T19:32:16Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"From: =?UTF-8?q?Zoli=20Szab=C3=B3?= <zoli.szabo@gmail.com>\n\n...in the default associated app (e.g. in a text editor / IDE).\n\nMany times there's the need to quickly open a source file (the one you're\nlooking at in Git GUI) in the predefined text editor / IDE. Of course,\nthe file can be searched for in your preferred file manager or directly\nin the text editor, but having the option to directly open the current\nfile from Git GUI would be just faster. This change enables just that by:\n - clicking the diff header path (which is now highlighted as a hyperlink)\n - or diff header path context menu -> Open;\n\nNote: executable files will be run and not opened for editing.\n\nSigned-off-by: Zoli Szabó <zoli.szabo@gmail.com>\n---\n git-gui.sh | 29 ++++++++++++++++++++++++-----\n 1 file changed, 24 insertions(+), 5 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex c1be733e3e..8920e4ddb0 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2248,9 +2248,8 @@ proc do_git_gui {} {\n \t}\n }\n \n-proc do_explore {} {\n-\tglobal _gitworktree\n-\tset explorer {}\n+# Get the system-specific explorer app/command.\n+proc get_explorer {} {\n \tif {[is_Cygwin] || [is_Windows]} {\n \t\tset explorer \"explorer.exe\"\n \t} elseif {[is_MacOSX]} {\n@@ -2259,9 +2258,23 @@ proc do_explore {} {\n \t\t# freedesktop.org-conforming system is our best shot\n \t\tset explorer \"xdg-open\"\n \t}\n+\treturn $explorer\n+}\n+\n+proc do_explore {} {\n+\tglobal _gitworktree\n+\tset explorer [get_explorer]\n \teval exec $explorer [list [file nativename $_gitworktree]] &\n }\n \n+# Open file relative to the working tree by the default associated app.\n+proc do_file_open {file} {\n+\tglobal _gitworktree\n+\tset explorer [get_explorer]\n+\tset full_file_path [file join $_gitworktree $file]\n+\teval exec $explorer [list [file nativename $full_file_path]] &\n+}\n+\n set is_quitting 0\n set ret_code    1\n \n@@ -3513,9 +3526,11 @@ tlabel .vpane.lower.diff.header.file \\\n \t-justify left\n tlabel .vpane.lower.diff.header.path \\\n \t-background gold \\\n-\t-foreground black \\\n+\t-foreground blue \\\n \t-anchor w \\\n-\t-justify left\n+\t-justify left \\\n+\t-font [eval font create [font configure font_ui] -underline 1] \\\n+\t-cursor hand2\n pack .vpane.lower.diff.header.status -side left\n pack .vpane.lower.diff.header.file -side left\n pack .vpane.lower.diff.header.path -fill x\n@@ -3530,8 +3545,12 @@ $ctxm add command \\\n \t\t\t-type STRING \\\n \t\t\t-- $current_diff_path\n \t}\n+$ctxm add command \\\n+\t-label [mc Open] \\\n+\t-command {do_file_open $current_diff_path}\n lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]\n bind_button3 .vpane.lower.diff.header.path \"tk_popup $ctxm %X %Y\"\n+bind .vpane.lower.diff.header.path <Button-1> {do_file_open $current_diff_path}\n \n # -- Diff Body\n #\n-- \ngitgitgadget\n"},{"id":"389040","messageId":"pull.499.v2.git.1577647930.gitgitgadget@gmail.com","threadId":"52523","inReplyTo":"pull.499.git.1577386915.gitgitgadget@gmail.com","subject":"[PATCH v2 0/1] git-gui: allow opening currently selected file","fromName":"Zoli Szabó via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-29T19:32:09Z","receivedAt":"2019-12-29T19:32:21Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"...in the default associated app (e.g. in a text editor / IDE).\n\nMany times there's the need to quickly open a source file (the one you're\nlooking at in Git GUI) in the predefined text editor / IDE. Of course, the\nfile can be searched for in your preferred file manager or directly in the\ntext editor, but having the option to directly open the current file from\nGit GUI would be just faster. This change enables just that by:\n\n * clicking the diff header path (which is now highlighted as a hyperlink)\n * or diff header path context menu -> Open;\n\nNote: executable files will be run and not opened for editing.\n\nSigned-off-by: Zoli Szabó zoli.szabo@gmail.com [zoli.szabo@gmail.com]\n\nZoli Szabó (1):\n  git-gui: allow opening currently selected file\n\n git-gui.sh | 29 ++++++++++++++++++++++++-----\n 1 file changed, 24 insertions(+), 5 deletions(-)\n\n\nbase-commit: 23cbe427c44645a3ab0449919e55bade5eb264bc\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-499%2Fzoliszabo%2Fgit-gui%2Fopen-current-file-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-499/zoliszabo/git-gui/open-current-file-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/499\n\nRange-diff vs v1:\n\n 1:  fce80f1b95 ! 1:  a6fde256f8 git-gui: add possibility to open currently selected file\n     @@ -1,6 +1,6 @@\n      Author: Zoli Szabó <zoli.szabo@gmail.com>\n      \n     -    git-gui: add possibility to open currently selected file\n     +    git-gui: allow opening currently selected file\n      \n          ...in the default associated app (e.g. in a text editor / IDE).\n      \n     @@ -9,11 +9,10 @@\n          the file can be searched for in your preferred file manager or directly\n          in the text editor, but having the option to directly open the current\n          file from Git GUI would be just faster. This change enables just that by:\n     -     - Diff header path context menu -> Open;\n     -     - or double-clicking the diff header path.\n     +     - clicking the diff header path (which is now highlighted as a hyperlink)\n     +     - or diff header path context menu -> Open;\n      \n     -    One \"downside\" of the approach is that executable files will be run\n     -    and not opened for editing.\n     +    Note: executable files will be run and not opened for editing.\n      \n          Signed-off-by: Zoli Szabó <zoli.szabo@gmail.com>\n      \n     @@ -26,11 +25,12 @@\n       \n      -proc do_explore {} {\n      -\tglobal _gitworktree\n     +-\tset explorer {}\n      +# Get the system-specific explorer app/command.\n      +proc get_explorer {} {\n     - \tset explorer {}\n       \tif {[is_Cygwin] || [is_Windows]} {\n       \t\tset explorer \"explorer.exe\"\n     + \t} elseif {[is_MacOSX]} {\n      @@\n       \t\t# freedesktop.org-conforming system is our best shot\n       \t\tset explorer \"xdg-open\"\n     @@ -44,9 +44,7 @@\n       \teval exec $explorer [list [file nativename $_gitworktree]] &\n       }\n       \n     -+# Trigger opening a file (relative to the working tree) by the default\n     -+# associated app of the OS (e.g. a text editor or IDE).\n     -+# FIXME: What about executables (will be run, not opened for editing)?\n     ++# Open file relative to the working tree by the default associated app.\n      +proc do_file_open {file} {\n      +\tglobal _gitworktree\n      +\tset explorer [get_explorer]\n     @@ -57,18 +55,30 @@\n       set is_quitting 0\n       set ret_code    1\n       \n     +@@\n     + \t-justify left\n     + tlabel .vpane.lower.diff.header.path \\\n     + \t-background gold \\\n     +-\t-foreground black \\\n     ++\t-foreground blue \\\n     + \t-anchor w \\\n     +-\t-justify left\n     ++\t-justify left \\\n     ++\t-font [eval font create [font configure font_ui] -underline 1] \\\n     ++\t-cursor hand2\n     + pack .vpane.lower.diff.header.status -side left\n     + pack .vpane.lower.diff.header.file -side left\n     + pack .vpane.lower.diff.header.path -fill x\n      @@\n       \t\t\t-type STRING \\\n       \t\t\t-- $current_diff_path\n       \t}\n      +$ctxm add command \\\n      +\t-label [mc Open] \\\n     -+\t-command {\n     -+\t\tdo_file_open $current_diff_path\n     -+\t}\n     ++\t-command {do_file_open $current_diff_path}\n       lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]\n       bind_button3 .vpane.lower.diff.header.path \"tk_popup $ctxm %X %Y\"\n     -+bind .vpane.lower.diff.header.path <Double-1> {do_file_open $current_diff_path}\n     ++bind .vpane.lower.diff.header.path <Button-1> {do_file_open $current_diff_path}\n       \n       # -- Diff Body\n       #\n\n-- \ngitgitgadget\n"},{"id":"389042","messageId":"ee041086-3579-190d-e607-1973bcc94c23@gmail.com","threadId":"52523","inReplyTo":"xmqqy2uxiemt.fsf@gitster-ct.c.googlers.com","subject":"Re: Re: [PATCH 1/1] git-gui: add possibility to open currently selected file","fromName":"Zoli Szabó","fromEmail":"zoli.szabo@gmail.com","sentAt":"2019-12-29T20:15:34Z","receivedAt":"2019-12-29T20:15:37Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"\nOn 2019.12.28 00:32, Junio C Hamano wrote:\n\n> The phrasing on the title is a bit awkward.  \"add possibility to do\n> X\" is better spelled \"allow doing X\", no?\n\nThank you, Junio, for the hint. Updated the commit message accordingly \n(PATCH v2).\n\n"},{"id":"389048","messageId":"xmqqh81iiv18.fsf@gitster-ct.c.googlers.com","threadId":"52523","inReplyTo":"ee041086-3579-190d-e607-1973bcc94c23@gmail.com","subject":"Re: [PATCH 1/1] git-gui: add possibility to open currently selected file","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-12-29T23:14:43Z","receivedAt":"2019-12-29T23:15:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Zoli Szabó <zoli.szabo@gmail.com> writes:\n\n> On 2019.12.28 00:32, Junio C Hamano wrote:\n>\n>> The phrasing on the title is a bit awkward.  \"add possibility to do\n>> X\" is better spelled \"allow doing X\", no?\n>\n> Thank you, Junio, for the hint. Updated the commit message accordingly\n> (PATCH v2).\n\nAlso, do not start the body of the proposed log message with half\nsentence.  The title is supposed to be a full sentence.\n\n\n"},{"id":"389068","messageId":"pull.499.v3.git.1577721419.gitgitgadget@gmail.com","threadId":"52523","inReplyTo":"pull.499.v2.git.1577647930.gitgitgadget@gmail.com","subject":"[PATCH v3 0/1] git-gui: allow opening currently selected file","fromName":"Zoli Szabó via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-30T15:56:58Z","receivedAt":"2019-12-30T15:57:04Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"...in the default associated app (e.g. in a text editor / IDE).\n\nMany times there's the need to quickly open a source file (the one you're\nlooking at in Git GUI) in the predefined text editor / IDE. Of course, the\nfile can be searched for in your preferred file manager or directly in the\ntext editor, but having the option to directly open the current file from\nGit GUI would be just faster. This change enables just that by:\n\n * clicking the diff header path (which is now highlighted as a hyperlink)\n * or diff header path context menu -> Open;\n\nNote: executable files will be run and not opened for editing.\n\nSigned-off-by: Zoli Szabó zoli.szabo@gmail.com [zoli.szabo@gmail.com]\n\nZoli Szabó (1):\n  git-gui: allow opening currently selected file in default app\n\n git-gui.sh | 29 ++++++++++++++++++++++++-----\n 1 file changed, 24 insertions(+), 5 deletions(-)\n\n\nbase-commit: 23cbe427c44645a3ab0449919e55bade5eb264bc\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-499%2Fzoliszabo%2Fgit-gui%2Fopen-current-file-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-499/zoliszabo/git-gui/open-current-file-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/499\n\nRange-diff vs v2:\n\n 1:  a6fde256f8 ! 1:  1b2363be72 git-gui: allow opening currently selected file\n     @@ -1,8 +1,6 @@\n      Author: Zoli Szabó <zoli.szabo@gmail.com>\n      \n     -    git-gui: allow opening currently selected file\n     -\n     -    ...in the default associated app (e.g. in a text editor / IDE).\n     +    git-gui: allow opening currently selected file in default app\n      \n          Many times there's the need to quickly open a source file (the one you're\n          looking at in Git GUI) in the predefined text editor / IDE. Of course,\n\n-- \ngitgitgadget\n"},{"id":"389069","messageId":"1b2363be726c6d70746aec9fae62edaf857cd665.1577721419.git.gitgitgadget@gmail.com","threadId":"52523","inReplyTo":"pull.499.v3.git.1577721419.gitgitgadget@gmail.com","subject":"[PATCH v3 1/1] git-gui: allow opening currently selected file in default app","fromName":"Zoli Szabó via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-12-30T15:56:59Z","receivedAt":"2019-12-30T15:57:06Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"From: =?UTF-8?q?Zoli=20Szab=C3=B3?= <zoli.szabo@gmail.com>\n\nMany times there's the need to quickly open a source file (the one you're\nlooking at in Git GUI) in the predefined text editor / IDE. Of course,\nthe file can be searched for in your preferred file manager or directly\nin the text editor, but having the option to directly open the current\nfile from Git GUI would be just faster. This change enables just that by:\n - clicking the diff header path (which is now highlighted as a hyperlink)\n - or diff header path context menu -> Open;\n\nNote: executable files will be run and not opened for editing.\n\nSigned-off-by: Zoli Szabó <zoli.szabo@gmail.com>\n---\n git-gui.sh | 29 ++++++++++++++++++++++++-----\n 1 file changed, 24 insertions(+), 5 deletions(-)\n\ndiff --git a/git-gui.sh b/git-gui.sh\nindex c1be733e3e..8920e4ddb0 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -2248,9 +2248,8 @@ proc do_git_gui {} {\n \t}\n }\n \n-proc do_explore {} {\n-\tglobal _gitworktree\n-\tset explorer {}\n+# Get the system-specific explorer app/command.\n+proc get_explorer {} {\n \tif {[is_Cygwin] || [is_Windows]} {\n \t\tset explorer \"explorer.exe\"\n \t} elseif {[is_MacOSX]} {\n@@ -2259,9 +2258,23 @@ proc do_explore {} {\n \t\t# freedesktop.org-conforming system is our best shot\n \t\tset explorer \"xdg-open\"\n \t}\n+\treturn $explorer\n+}\n+\n+proc do_explore {} {\n+\tglobal _gitworktree\n+\tset explorer [get_explorer]\n \teval exec $explorer [list [file nativename $_gitworktree]] &\n }\n \n+# Open file relative to the working tree by the default associated app.\n+proc do_file_open {file} {\n+\tglobal _gitworktree\n+\tset explorer [get_explorer]\n+\tset full_file_path [file join $_gitworktree $file]\n+\teval exec $explorer [list [file nativename $full_file_path]] &\n+}\n+\n set is_quitting 0\n set ret_code    1\n \n@@ -3513,9 +3526,11 @@ tlabel .vpane.lower.diff.header.file \\\n \t-justify left\n tlabel .vpane.lower.diff.header.path \\\n \t-background gold \\\n-\t-foreground black \\\n+\t-foreground blue \\\n \t-anchor w \\\n-\t-justify left\n+\t-justify left \\\n+\t-font [eval font create [font configure font_ui] -underline 1] \\\n+\t-cursor hand2\n pack .vpane.lower.diff.header.status -side left\n pack .vpane.lower.diff.header.file -side left\n pack .vpane.lower.diff.header.path -fill x\n@@ -3530,8 +3545,12 @@ $ctxm add command \\\n \t\t\t-type STRING \\\n \t\t\t-- $current_diff_path\n \t}\n+$ctxm add command \\\n+\t-label [mc Open] \\\n+\t-command {do_file_open $current_diff_path}\n lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]\n bind_button3 .vpane.lower.diff.header.path \"tk_popup $ctxm %X %Y\"\n+bind .vpane.lower.diff.header.path <Button-1> {do_file_open $current_diff_path}\n \n # -- Diff Body\n #\n-- \ngitgitgadget\n"},{"id":"389071","messageId":"090d6c63-ccc0-e83b-3673-1bbe29c5991c@gmail.com","threadId":"52523","inReplyTo":"xmqqh81iiv18.fsf@gitster-ct.c.googlers.com","subject":"Re: Re: [PATCH 1/1] git-gui: add possibility to open currently selected file","fromName":"Zoli Szabó","fromEmail":"zoli.szabo@gmail.com","sentAt":"2019-12-30T16:13:33Z","receivedAt":"2019-12-30T16:13:33Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"Adapted the commit message once again (PATCH v3).\n\nOn 2019.12.30 01:14, Junio C Hamano wrote:\n> Zoli Szabó <zoli.szabo@gmail.com> writes:\n> \n>> On 2019.12.28 00:32, Junio C Hamano wrote:\n>>\n>>> The phrasing on the title is a bit awkward.  \"add possibility to do\n>>> X\" is better spelled \"allow doing X\", no?\n>>\n>> Thank you, Junio, for the hint. Updated the commit message accordingly\n>> (PATCH v2).\n> \n> Also, do not start the body of the proposed log message with half\n> sentence.  The title is supposed to be a full sentence.\n> \n> \n> \n"},{"id":"389096","messageId":"20191230194129.kjmp6r5xuwmq4wum@yadavpratyush.com","threadId":"52523","inReplyTo":"1b2363be726c6d70746aec9fae62edaf857cd665.1577721419.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/1] git-gui: allow opening currently selected file in default app","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-12-30T19:41:29Z","receivedAt":"2019-12-30T19:41:38Z","isPatch":true,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"Hi Zoli,\n\nOn 30/12/19 03:56PM, Zoli Szabó via GitGitGadget wrote:\n> From: =?UTF-8?q?Zoli=20Szab=C3=B3?= <zoli.szabo@gmail.com>\n> \n> Many times there's the need to quickly open a source file (the one you're\n> looking at in Git GUI) in the predefined text editor / IDE. Of course,\n> the file can be searched for in your preferred file manager or directly\n> in the text editor, but having the option to directly open the current\n> file from Git GUI would be just faster. This change enables just that by:\n>  - clicking the diff header path (which is now highlighted as a hyperlink)\n>  - or diff header path context menu -> Open;\n\nSemi-colon left in by mistake?\n\n> \n> Note: executable files will be run and not opened for editing.\n> \n> Signed-off-by: Zoli Szabó <zoli.szabo@gmail.com>\n> ---\n>  git-gui.sh | 29 ++++++++++++++++++++++++-----\n>  1 file changed, 24 insertions(+), 5 deletions(-)\n> \n> diff --git a/git-gui.sh b/git-gui.sh\n> index c1be733e3e..8920e4ddb0 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -2259,9 +2258,23 @@ proc do_explore {} {\n> +# Open file relative to the working tree by the default associated \n> app.\n> +proc do_file_open {file} {\n> +\tglobal _gitworktree\n> +\tset explorer [get_explorer]\n> +\tset full_file_path [file join $_gitworktree $file]\n> +\teval exec $explorer [list [file nativename $full_file_path]] &\n\nIIUC, this line can be simplified to:\n\n  exec $explorer [file nativename $full_file_path] &\n\nIt works fine for me including on files with spaces in their names, but \na test on Windows would be appreciated just to rule out any hidden \nsurprises.\n\nNo need to send a re-roll just for these two small things. I have \nupdated the commit locally before pushing the new version out [0]. The \nrest of the patch looks good. Will merge. Thanks.\n\n> +}\n> +\n>  set is_quitting 0\n>  set ret_code    1\n>  \n\n[0] https://github.com/prati0100/git-gui/tree/zs/open-current-file\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"389100","messageId":"2fac0090-8db7-885a-9b1b-0017db7ce91b@gmail.com","threadId":"52523","inReplyTo":"20191230194129.kjmp6r5xuwmq4wum@yadavpratyush.com","subject":"Re: Re: [PATCH v3 1/1] git-gui: allow opening currently selected file in default app","fromName":"Zoli Szabó","fromEmail":"zoli.szabo@gmail.com","sentAt":"2019-12-30T20:31:32Z","receivedAt":"2019-12-30T20:31:31Z","isPatch":true,"sender":{"key":"zoli.szabo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9949042?v=4"},"body":"\nOn 2019.12.30 21:41, Pratyush Yadav wrote:\n> Hi Zoli,\n> \n> On 30/12/19 03:56PM, Zoli Szabó via GitGitGadget wrote:\n>> From: =?UTF-8?q?Zoli=20Szab=C3=B3?= <zoli.szabo@gmail.com>\n>>\n>> Many times there's the need to quickly open a source file (the one you're\n>> looking at in Git GUI) in the predefined text editor / IDE. Of course,\n>> the file can be searched for in your preferred file manager or directly\n>> in the text editor, but having the option to directly open the current\n>> file from Git GUI would be just faster. This change enables just that by:\n>>   - clicking the diff header path (which is now highlighted as a hyperlink)\n>>   - or diff header path context menu -> Open;\n> \n> Semi-colon left in by mistake?\n> \n\nYes, that should have been a simple period (.), signaling the end of the \nsentence.\n\n\n>> +\teval exec $explorer [list [file nativename $full_file_path]] &\n> \n> IIUC, this line can be simplified to:\n> \n>    exec $explorer [file nativename $full_file_path] &\n> \n> It works fine for me including on files with spaces in their names, but\n> a test on Windows would be appreciated just to rule out any hidden\n> surprises.\n\nYou're right. It can be simplified like you have proposed. Tested it and \nworks correctly also on Windows. (Since I have copied that line from the \nexisting `do_explore` proc, the same simplification can be done there \ntoo. (I did not realize this myself, since I am just learning some TCL \nin order to have this feature in Git GUI...))\n\n> \n> No need to send a re-roll just for these two small things. I have\n> updated the commit locally before pushing the new version out [0]. The\n> rest of the patch looks good. Will merge. Thanks.\n>  \n> [0] https://github.com/prati0100/git-gui/tree/zs/open-current-file\n> \n\nThank you very much for your support!\n\nAll the best,\nZoli\n"}]}