mirror of
https://github.com/git/git.git
synced 2026-01-11 21:33:13 +09:00
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 <j6t@kdbg.org>
This commit is contained in:
commit
c242b89b03
2
Makefile
2
Makefile
@ -185,6 +185,7 @@ install: all
|
||||
$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)
|
||||
$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(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
|
||||
ifdef GITGUI_WINDOWS_WRAPPER
|
||||
$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
@ -199,6 +200,7 @@ uninstall:
|
||||
$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)
|
||||
$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true
|
||||
ifdef GITGUI_WINDOWS_WRAPPER
|
||||
$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)
|
||||
|
||||
63
git-gui--askyesno
Executable file
63
git-gui--askyesno
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/sh
|
||||
# Tcl ignores the next line -*- tcl -*- \
|
||||
exec wish "$0" -- "$@"
|
||||
|
||||
# This is an implementation of a simple yes no dialog
|
||||
# which is injected into the git commandline by git gui
|
||||
# in case a yesno question needs to be answered.
|
||||
#
|
||||
# The window title, which defaults to "Question?", can be
|
||||
# overridden via the optional `--title` command-line
|
||||
# option.
|
||||
|
||||
set NS {}
|
||||
set use_ttk [package vsatisfies [package provide Tk] 8.5]
|
||||
if {$use_ttk} {
|
||||
set NS ttk
|
||||
}
|
||||
|
||||
set title "Question?"
|
||||
if {$argc < 1} {
|
||||
puts stderr "Usage: $argv0 <question>"
|
||||
exit 1
|
||||
} else {
|
||||
if {$argc > 2 && [lindex $argv 0] == "--title"} {
|
||||
set title [lindex $argv 1]
|
||||
set argv [lreplace $argv 0 1]
|
||||
}
|
||||
set prompt [join $argv " "]
|
||||
}
|
||||
|
||||
${NS}::frame .t
|
||||
${NS}::label .t.m -text $prompt -justify center -width 40
|
||||
.t.m configure -wraplength 400
|
||||
pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1
|
||||
pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1
|
||||
|
||||
${NS}::frame .b
|
||||
${NS}::frame .b.left -width 200
|
||||
${NS}::button .b.yes -text Yes -command {exit 0}
|
||||
${NS}::button .b.no -text No -command {exit 1}
|
||||
|
||||
pack .b.left -side left -expand 1 -fill x
|
||||
pack .b.yes -side left -expand 1
|
||||
pack .b.no -side right -expand 1 -ipadx 5
|
||||
pack .b -side bottom -fill x -ipadx 20 -ipady 15
|
||||
|
||||
bind . <Key-Return> {exit 0}
|
||||
bind . <Key-Escape> {exit 1}
|
||||
|
||||
if {$::tcl_platform(platform) eq {windows}} {
|
||||
set icopath [file dirname [file normalize $argv0]]
|
||||
if {[file tail $icopath] eq {git-core}} {
|
||||
set icopath [file dirname $icopath]
|
||||
}
|
||||
set icopath [file dirname $icopath]
|
||||
set icopath [file join $icopath share git git-for-windows.ico]
|
||||
if {[file exists $icopath]} {
|
||||
wm iconbitmap . -default $icopath
|
||||
}
|
||||
}
|
||||
|
||||
wm title . $title
|
||||
tk::PlaceWindow .
|
||||
@ -1130,6 +1130,12 @@ set argv0dir [file dirname [file normalize $::argv0]]
|
||||
if {![info exists env(SSH_ASKPASS)]} {
|
||||
set env(SSH_ASKPASS) [file join $argv0dir git-gui--askpass]
|
||||
}
|
||||
if {![info exists env(GIT_ASKPASS)]} {
|
||||
set env(GIT_ASKPASS) [file join $argv0dir git-gui--askpass]
|
||||
}
|
||||
if {![info exists env(GIT_ASK_YESNO)]} {
|
||||
set env(GIT_ASK_YESNO) [file join $argv0dir git-gui--askyesno]
|
||||
}
|
||||
unset argv0dir
|
||||
|
||||
######################################################################
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user