lambdalisue / vim-gina

👣 Asynchronously control git repositories in Neovim/Vim 8
http://www.vim.org/scripts/script.php?script_id=5531
MIT License
688 stars 27 forks source link

Force GUI askpass to solve #6 #11

Closed lambdalisue closed 7 years ago

lambdalisue commented 7 years ago

It seems a CUI based askpass which git provides ('get_terminal_prompt' in git code) does not works properly in job process. To fix the issue (issue #6), this commit disable CUI based prompt via $GIT_TERMINAL_PROMPT=0 and try to use GUI based prompt.

Linux: User should assign 'gnome-ssh-askpass' to '$GIT_ASKPASS', 'git config --global core.askpass', or '$SSH_ASKPASS'. If non of settings exist, it use a gina's internal askpass script when 'zenity' is available. Otherwise an operation which requires askpass always fail. Note that users may need to specify an absolute path. Use locate gnome-ssh-askpass then.

Mac: AFIK, there is no usable GUI based askpass exists on Mac. However, a gina's internal askpass script should works fine on any Mac environment. If non of settings exist, it use a gina's internal askpass script which use AppleScript internally.

Windows: It seems 'win-ssh-askpass' exists for this purpose. User can try to assign that to '$GIT_ASKPASS', 'git config --global core.askpass', or '$SSH_ASKPASS'. If non of settings exist, an operation which requires askpass always fail while there is no gina's internal script because I don't know Windows well enough. (PR or snippet or any suggestions for making an internal script for Windows is welcome)

lambdalisue commented 7 years ago

@bimlas

Could you test this branch on Windows?

  1. Does everything works as equal to master?
  2. Does :Gina push works OK with procedure below (Optional, if you have enough time and you are OK to install win-ssh-agent)

Procedure

  1. Install win-ssh-askpass (I'm not sure if the program is what I want though)
  2. Set the program to one of GIT_ASKPASS environment variable, git config --global core.askpass=..., or SSH_ASKPASS
  3. Add let $GIT_TERMINAL_PROMPT = '0' on your vimrc (WARN: This should be temporal during this test)
  4. Checkout gina.vim thorugh https:// by git clone https://github.com/lambdalisue/gina.vim
  5. Do :Gina push on the repository. If a GUI prompt comes up, it seems successes 👍
lambdalisue commented 7 years ago

Note:

My friend @Yudaidhun is going to make an internal askpass program for Windows 👍 He has already built a tiny (4k) program and it seems working well but he is new to github so we need to wait until he discover how to create a repository and collaborate in github. Once that tiny program has become ready, I'll put it into this plugin as a default askpass program for user who do not have win-ssh-askpass.

bimlas commented 7 years ago

The behaviour is equivalent in both branches without win-ssh-askpass.

Sorry, but I'm not familiar with Cygwin, thus I cannot try out win-ssh-askpass. It seems for me that the program runs only on Cygwin (a "Linux-emulator" for Windows) - if this is right, then the feature will heavily affect the Windows-compatibility of Gina, because the official installer use Msys (another "Linux-emu").

bimlas commented 7 years ago

I had a mistake: I installed Git with wincred (credential storage for Windows) and set up in .gitconfig. Before the test (pushing a repository) I deleted the relevant line from the config and noticed that Gina opens the GUI to ask password (as Git does from the command line too).

Later I found the proper way to disable credential storage and ran the test again: the push not works in both of master and askpass because the terminal prompt cannot be opened.

bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://github.com': Invalid argument
lambdalisue commented 7 years ago

I deleted the relevant line from the config and noticed that Gina opens the GUI to ask password (as Git does from the command line too).

It sounds a good news. So did you mean if Windows user use wincred which is an official version of git credentail, a GUI prompt comes up even in gina.vim? If so, what Windows user need to do is just execute $ git config --global credential.helper wincred and people can enter password right?

As the PR comment said, this problem exist on Linux/Mac while without proper configuration and software, Linux/Mac user cannot enter password because a terminal version is used. So if an official credentail for Windows use a GUI version, everything would become OK :+1:

bimlas commented 7 years ago

Well yeah, wincred is the official credential manager on Windows but it needs additional installation of Microsoft .NET Framework so it's not works as is on all system. BTW it's the most usable solution for GUI askpass.

lambdalisue commented 7 years ago

If it is an official, I think I should stack on that. Thanks for the information :+1: