git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 0/1] git-gui: allow opening currently selected file

From
Zoli Szabó via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 29, 2019, 19:32 UTC
Message-ID
<pull.499.v2.git.1577647930.gitgitgadget@gmail.com>
In-Reply-To
<pull.499.git.1577386915.gitgitgadget@gmail.com>
...in the default associated app (e.g. in a text editor / IDE).

Many times there's the need to quickly open a source file (the one you're looking at in Git GUI) in the predefined text editor / IDE. Of course, the file can be searched for in your preferred file manager or directly in the text editor, but having the option to directly open the current file from Git GUI would be just faster. This change enables just that by:

 * clicking the diff header path (which is now highlighted as a hyperlink)
 * or diff header path context menu -> Open;
Note: executable files will be run and not opened for editing.
Signed-off-by: Zoli Szabó zoli.szabo@gmail.com [zoli.szabo@gmail.com]
Zoli Szabó (1):
  git-gui: allow opening currently selected file
 git-gui.sh | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)
base-commit: 23cbe427c44645a3ab0449919e55bade5eb264bc
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-499%2Fzoliszabo%2Fgit-gui%2Fopen-current-file-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-499/zoliszabo/git-gui/open-current-file-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/499
Range-diff vs v1:
 1:  fce80f1b95 ! 1:  a6fde256f8 git-gui: add possibility to open currently selected file
     @@ -1,6 +1,6 @@
      Author: Zoli Szabó <zoli.szabo@gmail.com>
      
     -    git-gui: add possibility to open currently selected file
     +    git-gui: allow opening currently selected file
      
          ...in the default associated app (e.g. in a text editor / IDE).
      
     @@ -9,11 +9,10 @@
          the file can be searched for in your preferred file manager or directly
          in the text editor, but having the option to directly open the current
          file from Git GUI would be just faster. This change enables just that by:
     -     - Diff header path context menu -> Open;
     -     - or double-clicking the diff header path.
     +     - clicking the diff header path (which is now highlighted as a hyperlink)
     +     - or diff header path context menu -> Open;
      
     -    One "downside" of the approach is that executable files will be run
     -    and not opened for editing.
     +    Note: executable files will be run and not opened for editing.
      
          Signed-off-by: Zoli Szabó <zoli.szabo@gmail.com>
      
     @@ -26,11 +25,12 @@
       
      -proc do_explore {} {
      -	global _gitworktree
     +-	set explorer {}
      +# Get the system-specific explorer app/command.
      +proc get_explorer {} {
     - 	set explorer {}
       	if {[is_Cygwin] || [is_Windows]} {
       		set explorer "explorer.exe"
     + 	} elseif {[is_MacOSX]} {
      @@
       		# freedesktop.org-conforming system is our best shot
       		set explorer "xdg-open"
     @@ -44,9 +44,7 @@
       	eval exec $explorer [list [file nativename $_gitworktree]] &
       }
       
     -+# Trigger opening a file (relative to the working tree) by the default
     -+# associated app of the OS (e.g. a text editor or IDE).
     -+# FIXME: What about executables (will be run, not opened for editing)?
     ++# Open file relative to the working tree by the default associated app.
      +proc do_file_open {file} {
      +	global _gitworktree
      +	set explorer [get_explorer]
     @@ -57,18 +55,30 @@
       set is_quitting 0
       set ret_code    1
       
     +@@
     + 	-justify left
     + tlabel .vpane.lower.diff.header.path \
     + 	-background gold \
     +-	-foreground black \
     ++	-foreground blue \
     + 	-anchor w \
     +-	-justify left
     ++	-justify left \
     ++	-font [eval font create [font configure font_ui] -underline 1] \
     ++	-cursor hand2
     + pack .vpane.lower.diff.header.status -side left
     + pack .vpane.lower.diff.header.file -side left
     + pack .vpane.lower.diff.header.path -fill x
      @@
       			-type STRING \
       			-- $current_diff_path
       	}
      +$ctxm add command \
      +	-label [mc Open] \
     -+	-command {
     -+		do_file_open $current_diff_path
     -+	}
     ++	-command {do_file_open $current_diff_path}
       lappend diff_actions [list $ctxm entryconf [$ctxm index last] -state]
       bind_button3 .vpane.lower.diff.header.path "tk_popup $ctxm %X %Y"
     -+bind .vpane.lower.diff.header.path <Double-1> {do_file_open $current_diff_path}
     ++bind .vpane.lower.diff.header.path <Button-1> {do_file_open $current_diff_path}
       
       # -- Diff Body
       #
-- 
gitgitgadget
Previous: Zoli SzabóNext: Zoli Szabó via GitGitGadget
Message 9 of 14 in “git-gui: add possibility to open currently selected file”
  1. 0/1 git-gui: add possibility to open currently selected fileZoli Szabó via GitGitGadget, Dec 26, 2019
  2. 1/1 git-gui: add possibility to open currently selected fileZoli Szabó via GitGitGadget, Dec 26, 2019
  3. Pratyush YadavDec 27, 2019
  4. Junio C HamanoDec 27, 2019
  5. Zoli SzabóDec 29, 2019
  6. Junio C HamanoDec 29, 2019
  7. Zoli SzabóDec 30, 2019
  8. Zoli SzabóDec 29, 2019
  9. 0/1 git-gui: allow opening currently selected fileZoli Szabó via GitGitGadget, Dec 29, 2019
  10. 1/1 git-gui: allow opening currently selected fileZoli Szabó via GitGitGadget, Dec 29, 2019
  11. 0/1 git-gui: allow opening currently selected fileZoli Szabó via GitGitGadget, Dec 30, 2019
  12. 1/1 git-gui: allow opening currently selected file in default appZoli Szabó via GitGitGadget, Dec 30, 2019
  13. Pratyush YadavDec 30, 2019
  14. Zoli SzabóDec 30, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.