Skip to content

Commit aef0b48

Browse files
committed
git-gui: ensure correct application termination in git-gui--askpass
With Tk 8.5 the askpass utility can hang waiting for the wish shell implicit event loop to exit. This patch uses an explicit event loop to ensure correct application termination. Reported-by: Anders Kaseorg <[email protected]> Tested-by: Jonathan Nieder <[email protected]> Signed-off-by: Pat Thoyts <[email protected]>
1 parent d5257fb commit aef0b48

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

git-gui--askpass

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ exec wish "$0" -- "$@"
55
# This is a trivial implementation of an SSH_ASKPASS handler.
66
# Git-gui uses this script if none are already configured.
77

8+
package require Tk
9+
810
set answer {}
911
set yesno 0
1012
set rc 255
@@ -30,16 +32,20 @@ if {!$yesno} {
3032

3133
frame .b
3234
button .b.ok -text OK -command finish
33-
button .b.cancel -text Cancel -command {destroy .}
35+
button .b.cancel -text Cancel -command cancel
3436

3537
pack .b.ok -side left -expand 1
3638
pack .b.cancel -side right -expand 1
3739
pack .b -side bottom -fill x -padx 10 -pady 10
3840

3941
bind . <Visibility> {focus -force .e}
40-
bind . <Key-Return> finish
41-
bind . <Key-Escape> {destroy .}
42-
bind . <Destroy> {exit $rc}
42+
bind . <Key-Return> [list .b.ok invoke]
43+
bind . <Key-Escape> [list .b.cancel invoke]
44+
bind . <Destroy> {set rc $rc}
45+
46+
proc cancel {} {
47+
set ::rc 255
48+
}
4349

4450
proc finish {} {
4551
if {$::yesno} {
@@ -50,10 +56,11 @@ proc finish {} {
5056
}
5157
}
5258

53-
set ::rc 0
5459
puts $::answer
55-
destroy .
60+
set ::rc 0
5661
}
5762

5863
wm title . "OpenSSH"
5964
tk::PlaceWindow .
65+
vwait rc
66+
exit $rc

0 commit comments

Comments
 (0)