-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add a Win32 askpass #371
add a Win32 askpass #371
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
git-extra/PKGBUILD
Outdated
@@ -52,7 +52,10 @@ source=('inputrc' | |||
'update-via-pacman.bat' | |||
'git-credential-helper-selector.c' | |||
'git-credential-helper-selector.manifest' | |||
'git-credential-helper-selector.rc') | |||
'git-credential-helper-selector.rc' | |||
'git-win32-askpass.c' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intend to stop shipping GCM soon (and only retain GCM Core, its official successor). At that point at the latest, using the name git-askpass
would actually bring a benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that cause a new name conflict with git-ecosystem/git-credential-manager#385 or obsolete that issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will obsolete git-ecosystem/git-credential-manager#385
b9184fd
to
350810e
Compare
I think I've addressed all concerns. I've also added the new |
This is a drop-in replacement for `git gui--askpass`. Since we added an option to use an external `ssh` found on the `PATH` (git-for-windows#367) we'll need an `askpass` implementation that can be called by any windows application even without understanding shebang lines. `git gui--askpass` probably also has the same problems with screenreaders that `git gui--askyesno` had(git-for-windows#234), so we'll likely get improved accessibility as a positive side-effect. Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
The new `git-askpass.exe` doesn't use shebang lines and thus works with non-msys2 OpenSSH. It's also likely to interact more nicely with screen readers. Signed-off-by: Matthias Aßhauer <mha1993@live.de>
I modified this a little, locally. This is the range-diff: 1: 7e0a028098 ! 1: da9ba5d86b git-extra: include an simple Win32 `git askpass`
@@ Commit message
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
## git-extra/Makefile ##
+@@ git-extra/Makefile: CXXFLAGS ?= -Wall
+ all: $(BUILDDIR)/create-shortcut.exe $(BUILDDIR)/WhoUses.exe \
+ $(BUILDDIR)/blocked-file-util.exe $(BUILDDIR)/proxy-lookup.exe \
+ $(BUILDDIR)/git-askyesno.exe \
++ $(BUILDDIR)/git-askpass.exe \
+ $(BUILDDIR)/git-credential-helper-selector.exe
+
+ $(BUILDDIR)/create-shortcut.exe: $(BUILDDIR)/create-shortcut.o
@@ git-extra/Makefile: $(BUILDDIR)/git-credential-helper-selector.exe: \
$(BUILDDIR)/git-credential-helper-selector.o \
$(BUILDDIR)/git-credential-helper-selector.res
@@ git-extra/git-askpass.c (new)
+ case WM_INITDIALOG:
+ /* Display the prompt */
+ SetDlgItemTextW(hDlg, IDC_PROMPT, (wchar_t *) lParam);
-+ return TRUE;
++ if (GetDlgCtrlID((HWND) wParam) != IDE_PASSWORDEDIT) {
++ SetFocus(GetDlgItem(hDlg, IDE_PASSWORDEDIT));
++ return FALSE;
++ }
++ return TRUE;
+ case WM_COMMAND:
+ switch(wParam)
+ {
+ case IDOK:
+ /* Get number of characters. */
+ cchPassword = (WORD) SendDlgItemMessage(hDlg,
-+ IDE_PASSWORDEDIT,
-+ EM_LINELENGTH,
-+ (WPARAM) 0,
-+ (LPARAM) 0);
++ IDE_PASSWORDEDIT,
++ EM_LINELENGTH,
++ (WPARAM) 0,
++ (LPARAM) 0);
+
+ lpszPassword = (wchar_t *) malloc(sizeof(wchar_t) * (cchPassword + 1));
+ if (!lpszPassword) {
@@ git-extra/git-askpass.c (new)
+
+ /* Get the characters. */
+ SendDlgItemMessageW(hDlg,
-+ IDE_PASSWORDEDIT,
-+ EM_GETLINE,
-+ (WPARAM) 0, /* line 0 */
-+ (LPARAM) lpszPassword);
++ IDE_PASSWORDEDIT,
++ EM_GETLINE,
++ (WPARAM) 0, /* line 0 */
++ (LPARAM) lpszPassword);
+
+ /* Null-terminate the string. */
+ lpszPassword[cchPassword] = 0;
@@ git-extra/git-askpass.c (new)
+{
+ INT_PTR res;
+ wchar_t *prompt = NULL;
-+
++
+ if (argc < 2) {
+ MessageBoxW(NULL, L"Usage: git askpass <prompt>", L"Error!", MB_OK);
+ return 1;
@@ git-extra/git-askpass.c (new)
+ free(prompt);
+ return !res;
+}
- \ No newline at end of file
## git-extra/git-askpass.h (new) ##
@@
2: 1976019925 = 2: dc55377e79 git-extra: set `DISPLAY` and `SSH_ASKPASS` for ARM64
3: 350810e4a9 = 3: c292bffd28 env.sh: prefer git-askpass.exe over git-gui--askpass Summary:
|
|
Thank you so much @rimrul!!! |
Oh, and once this is built, we will have to fix |
Is it? I'm looking at the contents of MinGit-2.32.0.2-64-bit.zip and |
Hrm. I thought I had moved them all into |
Turns out that I only moved the Lines 126 to 140 in 36a1cbd
So I think we're actually good here. |
It's currently as bare-bones as it gets, but seems to be functional.
The prompt does get wrapped into multiple lines if it gets too long. The code is obviously heavily based on the sample code for line edits and slightly on
git-askyesno
.I intend to add the Git for Windows icon on the right (similar to the GCM
askpass
) at some point in the near future, but that'll probably happen after v2.33.0 is out.The name isn't set in stone yet, but I think shipping two significantly different
git-askpass.exe
that are more or less intended for the same purpose might lead to confusion.Changes since v1:
git-askpass
DialogBoxW()
toDialogBoxParamW()
. This allows passing the prompt directly and gives us easier access to the result of the Dialogssh-askpass
)ssh-askpass
)%ls
over%S
env.sh
to also handleMSYSTEM=ARM64
askpass
toenv.sh