Skip to content

Commit e749c87

Browse files
hvoigtj6t
authored andcommitted
git-gui: provide question helper for retry fallback on Windows
Make use of the new environment variable GIT_ASK_YESNO to support the recently implemented fallback in case unlink, rename or rmdir fail for files in use on Windows. The added dialog will present a yes/no question to the the user which will currently be used by the windows compat layer to let the user retry a failed file operation. Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Johannes Sixt <j6t@kdbg.org>
1 parent e3923e3 commit e749c87

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ install: all
185185
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
186186
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
187187
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
188+
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
188189
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(INSTALL_L0)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L1)'$(DESTDIR_SQ)$(gitexecdir_SQ)/git-gui' $(INSTALL_L2)'$(DESTDIR_SQ)$(gitexecdir_SQ)/$p' $(INSTALL_L3) &&) true
189190
ifdef GITGUI_WINDOWS_WRAPPER
190191
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
@@ -199,6 +200,7 @@ uninstall:
199200
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
200201
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
201202
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
203+
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
202204
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
203205
ifdef GITGUI_WINDOWS_WRAPPER
204206
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)

git-gui--askyesno

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/sh
2+
# Tcl ignores the next line -*- tcl -*- \
3+
exec wish "$0" -- "$@"
4+
5+
# This is an implementation of a simple yes no dialog
6+
# which is injected into the git commandline by git gui
7+
# in case a yesno question needs to be answered.
8+
9+
set NS {}
10+
set use_ttk [package vsatisfies [package provide Tk] 8.5]
11+
if {$use_ttk} {
12+
set NS ttk
13+
}
14+
15+
if {$argc < 1} {
16+
puts stderr "Usage: $argv0 <question>"
17+
exit 1
18+
} else {
19+
set prompt [join $argv " "]
20+
}
21+
22+
${NS}::frame .t
23+
${NS}::label .t.m -text $prompt -justify center -width 40
24+
.t.m configure -wraplength 400
25+
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
26+
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
27+
28+
${NS}::frame .b
29+
${NS}::frame .b.left -width 200
30+
${NS}::button .b.yes -text Yes -command {exit 0}
31+
${NS}::button .b.no -text No -command {exit 1}
32+
33+
pack .b.left -side left -expand 1 -fill x
34+
pack .b.yes -side left -expand 1
35+
pack .b.no -side right -expand 1 -ipadx 5
36+
pack .b -side bottom -fill x -ipadx 20 -ipady 15
37+
38+
bind . <Key-Return> {exit 0}
39+
bind . <Key-Escape> {exit 1}
40+
41+
wm title . "Question?"
42+
tk::PlaceWindow .

git-gui.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,9 @@ set argv0dir [file dirname [file normalize $::argv0]]
11301130
if {![info exists env(SSH_ASKPASS)]} {
11311131
set env(SSH_ASKPASS) [file join $argv0dir git-gui--askpass]
11321132
}
1133+
if {![info exists env(GIT_ASK_YESNO)]} {
1134+
set env(GIT_ASK_YESNO) [file join $argv0dir git-gui--askyesno]
1135+
}
11331136
unset argv0dir
11341137

11351138
######################################################################

0 commit comments

Comments
 (0)