Skip to content

Commit

Permalink
git-gui: ensure correct application termination in git-gui--askpass
Browse files Browse the repository at this point in the history
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 <andersk@mit.edu>
Tested-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
  • Loading branch information
Pat Thoyts committed Aug 18, 2010
1 parent d5257fb commit aef0b48
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions git-gui--askpass
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ 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
Expand All @@ -30,16 +32,20 @@ if {!$yesno} {

frame .b
button .b.ok -text OK -command finish
button .b.cancel -text Cancel -command {destroy .}
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> finish
bind . <Key-Escape> {destroy .}
bind . <Destroy> {exit $rc}
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} {
Expand All @@ -50,10 +56,11 @@ proc finish {} {
}
}

set ::rc 0
puts $::answer
destroy .
set ::rc 0
}

wm title . "OpenSSH"
tk::PlaceWindow .
vwait rc
exit $rc

0 comments on commit aef0b48

Please sign in to comment.