From a30e296d6bdd412283f3a04e44bf96de695886a6 Mon Sep 17 00:00:00 2001 From: Heiko Voigt Date: Thu, 26 Sep 2019 08:29:56 -0700 Subject: [PATCH 1/5] 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 Signed-off-by: Johannes Schindelin Signed-off-by: Pratyush Yadav --- Makefile | 2 ++ git-gui--askyesno | 51 +++++++++++++++++++++++++++++++++++++++++++++++ git-gui.sh | 3 +++ 3 files changed, 56 insertions(+) create mode 100755 git-gui--askyesno diff --git a/Makefile b/Makefile index f10caed..d529cab 100644 --- a/Makefile +++ b/Makefile @@ -293,6 +293,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)' @@ -311,6 +312,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) diff --git a/git-gui--askyesno b/git-gui--askyesno new file mode 100755 index 0000000..cf9c990 --- /dev/null +++ b/git-gui--askyesno @@ -0,0 +1,51 @@ +#!/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. + +set NS {} +set use_ttk [package vsatisfies [package provide Tk] 8.5] +if {$use_ttk} { + set NS ttk +} + +if {$argc < 1} { + puts stderr "Usage: $argv0 " + exit 1 +} else { + set prompt [join $argv " "] +} + +${NS}::frame .t +${NS}::label .t.m -text $prompt -justify center -width 400px +.t.m configure -wraplength 400px +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 yes +${NS}::button .b.no -text No -command no + + +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 . {exit 0} +bind . {exit 1} + +proc no {} { + exit 1 +} + +proc yes {} { + exit 0 +} + +wm title . "Question?" +tk::PlaceWindow . diff --git a/git-gui.sh b/git-gui.sh index fd476b6..06eb99c 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1229,6 +1229,9 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}] if {![info exists env(SSH_ASKPASS)]} { set env(SSH_ASKPASS) [gitexec git-gui--askpass] } +if {![info exists env(GIT_ASK_YESNO)]} { + set env(GIT_ASK_YESNO) [gitexec git-gui--askyesno] +} ###################################################################### ## From c1bf222d2c85f31d13f92570404d5345ff516297 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 26 Sep 2019 08:29:57 -0700 Subject: [PATCH 2/5] git gui: set GIT_ASKPASS=git-gui--askpass if not set yet Signed-off-by: Johannes Schindelin Signed-off-by: Pratyush Yadav --- git-gui.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index 06eb99c..0d6feb1 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -1229,6 +1229,9 @@ set have_tk85 [expr {[package vcompare $tk_version "8.5"] >= 0}] if {![info exists env(SSH_ASKPASS)]} { set env(SSH_ASKPASS) [gitexec git-gui--askpass] } +if {![info exists env(GIT_ASKPASS)]} { + set env(GIT_ASKPASS) [gitexec git-gui--askpass] +} if {![info exists env(GIT_ASK_YESNO)]} { set env(GIT_ASK_YESNO) [gitexec git-gui--askyesno] } From 86d967a0a683ea0e2e34d1e89ad1f72cc47e65b7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 26 Sep 2019 08:29:58 -0700 Subject: [PATCH 3/5] git-gui--askyesno: allow overriding the window title "Question?" is maybe not the most informative thing to ask. In the absence of better information, it is the best we can do, of course. However, Git for Windows' auto updater just learned the trick to use git-gui--askyesno to ask the user whether to update now or not. And in this scripted scenario, we can easily pass a command-line option to change the window title. So let's support that with the new `--title ` option. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com> --- git-gui--askyesno | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-gui--askyesno b/git-gui--askyesno index cf9c990..45b0260 100755 --- a/git-gui--askyesno +++ b/git-gui--askyesno @@ -12,10 +12,15 @@ 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 " "] } @@ -47,5 +52,5 @@ proc yes {} { exit 0 } -wm title . "Question?" +wm title . $title tk::PlaceWindow . From 3b9bed7058d337163cd0934293f090e3e00551b4 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin <johannes.schindelin@gmx.de> Date: Thu, 26 Sep 2019 08:30:00 -0700 Subject: [PATCH 4/5] git-gui--askyesno (mingw): use Git for Windows' icon, if available For additional GUI goodness. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com> --- git-gui--askyesno | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/git-gui--askyesno b/git-gui--askyesno index 45b0260..c0c82e7 100755 --- a/git-gui--askyesno +++ b/git-gui--askyesno @@ -52,5 +52,17 @@ proc yes {} { exit 0 } +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 . From e3de896df73add0daa9721c5cc813faf16529c6d Mon Sep 17 00:00:00 2001 From: Mark Levedahl <mlevedahl@gmail.com> Date: Fri, 1 Aug 2025 12:48:14 -0400 Subject: [PATCH 5/5] git-gui: use tk_dialog for ask yes/no git-gui's proposed command-line dialog script relies upon Tk 8.5'ish constructs and is incompatible with Tcl 9.0. This dialog is hand crafted from several widgets, while Tk provides tk_dialog that handles the need here, and is fully supported in Tk 8.6 and 9.0. So, let's switch to that. Signed-off-by: Mark Levedahl <mlevedahl@gmail.com> --- git-gui--askyesno | 42 +++++------------------------------------- 1 file changed, 5 insertions(+), 37 deletions(-) diff --git a/git-gui--askyesno b/git-gui--askyesno index c0c82e7..9f084ce 100755 --- a/git-gui--askyesno +++ b/git-gui--askyesno @@ -6,12 +6,6 @@ exec wish "$0" -- "$@" # which is injected into the git commandline by git gui # in case a yesno question needs to be answered. -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>" @@ -24,34 +18,7 @@ if {$argc < 1} { set prompt [join $argv " "] } -${NS}::frame .t -${NS}::label .t.m -text $prompt -justify center -width 400px -.t.m configure -wraplength 400px -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 yes -${NS}::button .b.no -text No -command no - - -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} - -proc no {} { - exit 1 -} - -proc yes {} { - exit 0 -} - +set dicon {question} if {$::tcl_platform(platform) eq {windows}} { set icopath [file dirname [file normalize $argv0]] if {[file tail $icopath] eq {git-core}} { @@ -60,9 +27,10 @@ if {$::tcl_platform(platform) eq {windows}} { set icopath [file dirname $icopath] set icopath [file join $icopath share git git-for-windows.ico] if {[file exists $icopath]} { - wm iconbitmap . -default $icopath + set dicon $iconpath } } -wm title . $title -tk::PlaceWindow . +wm withdraw . +set ans [tk_dialog .d $title $prompt $dicon 1 "Yes" "No"] +exit $ans