about summary refs log tree commit diff
path: root/git-gui/git-gui--askpass
diff options
context:
space:
mode:
authorVincent Ambo <Vincent Ambo>2020-01-11T23·36+0000
committerVincent Ambo <Vincent Ambo>2020-01-11T23·36+0000
commit1b593e1ea4d2af0f6444d9a7788d5d99abd6fde5 (patch)
treee3accb9beed5c4c1b5a05c99db71ab2841f0ed04 /git-gui/git-gui--askpass
Squashed 'third_party/git/' content from commit cb71568594
git-subtree-dir: third_party/git
git-subtree-split: cb715685942260375e1eb8153b0768a376e4ece7
Diffstat (limited to 'git-gui/git-gui--askpass')
-rwxr-xr-xgit-gui/git-gui--askpass66
1 files changed, 66 insertions, 0 deletions
diff --git a/git-gui/git-gui--askpass b/git-gui/git-gui--askpass
new file mode 100755
index 000000000000..4277f30c4116
--- /dev/null
+++ b/git-gui/git-gui--askpass
@@ -0,0 +1,66 @@
+#!/bin/sh
+# Tcl ignores the next line -*- tcl -*- \
+exec wish "$0" -- "$@"
+
+# This is a trivial implementation of an SSH_ASKPASS handler.
+# Git-gui uses this script if none are already configured.
+
+package require Tk
+
+set answer {}
+set yesno  0
+set rc     255
+
+if {$argc < 1} {
+	set prompt "Enter your OpenSSH passphrase:"
+} else {
+	set prompt [join $argv " "]
+	if {[regexp -nocase {\(yes\/no\)\?\s*$} $prompt]} {
+		set yesno 1
+	}
+}
+
+message .m -text $prompt -justify center -aspect 4000
+pack .m -side top -fill x -padx 20 -pady 20 -expand 1
+
+entry .e -textvariable answer -width 50
+pack .e -side top -fill x -padx 10 -pady 10
+
+if {!$yesno} {
+	.e configure -show "*"
+}
+
+frame .b
+button .b.ok     -text OK     -command finish
+button .b.cancel -text Cancel -command cancel
+
+pack .b.ok -side left -expand 1
+pack .b.cancel -side right -expand 1
+pack .b -side bottom -fill x -padx 10 -pady 10
+
+bind . <Visibility> {focus -force .e}
+bind . <Key-Return> [list .b.ok invoke]
+bind . <Key-Escape> [list .b.cancel invoke]
+bind . <Destroy>    {set rc $rc}
+
+proc cancel {} {
+	set ::rc 255
+}
+
+proc finish {} {
+	if {$::yesno} {
+		if {$::answer ne "yes" && $::answer ne "no"} {
+			tk_messageBox -icon error -title "Error" -type ok \
+				-message "Only 'yes' or 'no' input allowed."
+			return
+		}
+	}
+
+	puts $::answer
+	set ::rc 0
+}
+
+wm title . "OpenSSH"
+tk::PlaceWindow .
+vwait rc
+exit $rc