Skip to content

Commit c242b89

Browse files
committed
Merge branch 'js/ask-yesno'
* js/ask-yesno: git-gui--askyesno (mingw): use Git for Windows' icon, if available git-gui--askyesno: allow overriding the window title git gui: set GIT_ASKPASS=git-gui--askpass if not set yet git-gui: provide question helper for retry fallback on Windows Signed-off-by: Johannes Sixt <[email protected]>
2 parents c461528 + 74c90b0 commit c242b89

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed

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: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
# The window title, which defaults to "Question?", can be
10+
# overridden via the optional `--title` command-line
11+
# option.
12+
13+
set NS {}
14+
set use_ttk [package vsatisfies [package provide Tk] 8.5]
15+
if {$use_ttk} {
16+
set NS ttk
17+
}
18+
19+
set title "Question?"
20+
if {$argc < 1} {
21+
puts stderr "Usage: $argv0 <question>"
22+
exit 1
23+
} else {
24+
if {$argc > 2 && [lindex $argv 0] == "--title"} {
25+
set title [lindex $argv 1]
26+
set argv [lreplace $argv 0 1]
27+
}
28+
set prompt [join $argv " "]
29+
}
30+
31+
${NS}::frame .t
32+
${NS}::label .t.m -text $prompt -justify center -width 40
33+
.t.m configure -wraplength 400
34+
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
35+
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
36+
37+
${NS}::frame .b
38+
${NS}::frame .b.left -width 200
39+
${NS}::button .b.yes -text Yes -command {exit 0}
40+
${NS}::button .b.no -text No -command {exit 1}
41+
42+
pack .b.left -side left -expand 1 -fill x
43+
pack .b.yes -side left -expand 1
44+
pack .b.no -side right -expand 1 -ipadx 5
45+
pack .b -side bottom -fill x -ipadx 20 -ipady 15
46+
47+
bind . <Key-Return> {exit 0}
48+
bind . <Key-Escape> {exit 1}
49+
50+
if {$::tcl_platform(platform) eq {windows}} {
51+
set icopath [file dirname [file normalize $argv0]]
52+
if {[file tail $icopath] eq {git-core}} {
53+
set icopath [file dirname $icopath]
54+
}
55+
set icopath [file dirname $icopath]
56+
set icopath [file join $icopath share git git-for-windows.ico]
57+
if {[file exists $icopath]} {
58+
wm iconbitmap . -default $icopath
59+
}
60+
}
61+
62+
wm title . $title
63+
tk::PlaceWindow .

git-gui.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,12 @@ 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_ASKPASS)]} {
1134+
set env(GIT_ASKPASS) [file join $argv0dir git-gui--askpass]
1135+
}
1136+
if {![info exists env(GIT_ASK_YESNO)]} {
1137+
set env(GIT_ASK_YESNO) [file join $argv0dir git-gui--askyesno]
1138+
}
11331139
unset argv0dir
11341140

11351141
######################################################################

0 commit comments

Comments
 (0)