Git fork

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>

+71
+2
Makefile
··· 185 185 $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1) 186 186 $(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)' 187 187 $(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)' 188 189 $(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 189 190 ifdef GITGUI_WINDOWS_WRAPPER 190 191 $(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)' ··· 199 200 $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)' 200 201 $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1) 201 202 $(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) 202 204 $(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true 203 205 ifdef GITGUI_WINDOWS_WRAPPER 204 206 $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)
+63
git-gui--askyesno
··· 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 .
+6
git-gui.sh
··· 1130 1130 if {![info exists env(SSH_ASKPASS)]} { 1131 1131 set env(SSH_ASKPASS) [file join $argv0dir git-gui--askpass] 1132 1132 } 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 + } 1133 1139 unset argv0dir 1134 1140 1135 1141 ######################################################################