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

Re: Re: [PATCH 1/1] git-gui: add possibility to open currently selected file

From
Zoli Szabó <zoli.szabo@gmail.com>
Date
Dec 29, 2019, 13:23 UTC
Message-ID
<c681ca1b-cdcb-d021-95a9-ca3ad944cfa3@gmail.com>
In-Reply-To
<20191227193418.36uzeizs37nv7ywb@yadavpratyush.com>
Hi Pratyush,
Thanks for your thorough review.
On 2019.12.27 21:34, Pratyush Yadav wrote:
Show 18 quoted lines
>> ...This change enables just that by:
>>   - Diff header path context menu -> Open;
> 
> Would it be a better idea to have this option in the diff body context
> menu (.vpane.lower.diff.body.ctxm) instead? The problem I see with the
> way its currently done is visibility/discovery. It is not very likely
> for a user to try and click the file name which doesn't give any
> indication that it is clickable. So how will someone who hasn't read
> this commit message know that they can use this neat feature. The diff
> body context menu is much more "visible" IMO.
> 
>>   - or double-clicking the diff header path.
> 
> An alternative to the above suggestion would be to make this path
> underlined and blue in color (like a hyperlink in a web browser). This
> will give the indication that this is not just plain text.
> 
> I like the latter idea more, but I don't mind either.

For me, the body context menu holds the diff-related options, I am not sure the "Open" fits in there. But I do like your suggestion of making the filename web browser-link-like. I'll try to implement that.

Show 7 quoted lines
>> One "downside" of the approach is that executable files will be run
>> and not opened for editing.
> 
> FWIW, I do not see it as a downside at all. The menu option is called
> "open" not "edit". So if you click it, you should expect the file to
> open. In case its a binary file, executing it is the correct outcome. In
> case its a text file, opening it in the editor is the correct outcome.
Alright then.
Show 17 quoted lines
>> +proc do_file_open {file} {
>> +	global _gitworktree
>> +	set explorer [get_explorer]
>> +	set full_file_path [file join $_gitworktree $file]
>> +	eval exec $explorer [list [file nativename $full_file_path]] &
> 
> This executes $explorer, which is 'explorer.exe' on Windows. I'm not a
> heavy Windows user but AFAIK it is a file manager. This makes it quite
> different from 'xdg-open' which is used to open _any_ file/URL in the
> user's default application. So it also happens to open _directories_ in
> the default file explorer which was the original intention of this
> procedure.
> 
> Have you tested it on Windows? Does 'explorer.exe' do the correct thing?
> 
> Looking at MacOS's 'open' man page, I think it should also work like
> xdg-open and shouldn't be a problem.

I am in fact working on this patch on Windows. explorer.exe works also for files and even brings up the "Open with..." dialog for not-recognized file types.

> Tested on Linux. Works fine. Looking forward to the re-roll.

Thanks for testing it on Linux. Since I am working on Windows, I just read about `xdg-open` and `open` and assumed everything should work OK.

All other points I agree with you and will push a new version of the patch.

Thanks, Zoli

Previous: Zoli SzabóNext: Zoli Szabó via GitGitGadget
Message 8 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.