git-for-windows / git

A fork of Git containing Windows-specific patches.
http://gitforwindows.org/
Other
8.36k stars 2.54k forks source link

Windows Setup » 'Choose the default editor used by Git': two small but useful suggestions #2818

Closed schittli closed 2 years ago

schittli commented 4 years ago

The new Git Windows Setup is annoying because the new Wizard-Step Choosing the default editor udes by Git is a great idea, but not yet finished. Therefore, I have two suggestions.

Setup

Details

Suggestion #1: If the user selects an Editor in the DropDown-List which is not found by Git Setup,

then please offer that the user can define the path to the installed Editor. This allows the Git setup to automatically add the correct command-line arguments because it already knows which arguments are needed :-)

image

Suggestion #2: In the DropDown-List, please offer this new item: Use settings from current .gitconfig file:

I guess that the selection of the Git Editor will be saved in the .gitconfig file. Therefore, if the user migrated to a new computer and copied the .gitconfig file, then it would be great if Git Setup would offer to use this existing config :-)

image

Thanks a lot for all your great work!, kind regards, Thomas

dscho commented 4 years ago

Hi Thomas, thank you for raising these suggestions.

First, a quick note: please include our non-male users by avoiding the pronoun "he" for each and every Git for Windows user. We do have a diverse audience here, and we really want them to feel welcome and respected.

Your suggestions are intriguing! I wonder whether I could talk you into looking further into this by pointing you to the source code for those options: https://github.com/git-for-windows/build-extra/blob/cb639270d282db6653c3771f1603bbf65b4cdafd/installer/install.iss#L1645-L1835

You will note that the hard part, namely adding that text box to house the path to the executable, is already added for the custom editor: https://github.com/git-for-windows/build-extra/blob/cb639270d282db6653c3771f1603bbf65b4cdafd/installer/install.iss#L1768-L1781

All you would need to do is to make sure that it is populated and shown also for Notepad++. Or maybe for all editors (except the vim one)? That would be super valuable, I think.

As to the "use .gitconfig" option: I assume you are referring to ~/.gitconfig, i.e. the file you can edit via git config --global -e?

This is the "user-wide" (or, for historical reasons that you are totally entitled to blame me for: "global") settings. They will always override the system settings anyway, and the system settings are what the installer will configure.

Having said that, it sounds like a good idea to be able to persist the user's settings to the system settings. The way I would try to implement it is to imitate the custom editor and fill in the core.editor value configured in the user-wide config. The way I would do this is to run git config --global core.editor via ExecAsOriginalUser(), redirecting the output (as is done here and reading the redirected output back via ReadFileAsString().

Alternative idea: instead of having a separate option for the ~/.gitconfig one, have an additional button (that is grayed out if ~/.gitconfig does not specify core.editor) in the custom editor option.

So how can you get started with this? Basically, follow https://github.com/git-for-windows/git/wiki/Making-an-installer. To test the Editor selection, you can run ./installer/release.sh -d Editor in /usr/src/build-extra/, which will generate and run a "fake" installer that does not actually bundle any files but instead shows only the Editor page to you.

I look forward to working with you on this!

dscho commented 2 years ago

Closing as stale.