{"thread":{"id":"26843","subject":"[PATCH] git-gui: provide question helper for retry fallback on Windows","startedAt":"2011-03-23T20:31:19Z","lastAt":"2011-03-24T00:06:32Z","messageCount":2,"participants":["Heiko Voigt","Pat Thoyts"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"164182","messageId":"20110323203119.GA23905@book.hvoigt.net","threadId":"26843","inReplyTo":null,"subject":"[PATCH] git-gui: provide question helper for retry fallback on Windows","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2011-03-23T20:31:19Z","receivedAt":"2011-03-23T20:31:19Z","isPatch":true,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Make use of the new environment variable GIT_ASK_YESNO to support the\nrecently implemented fallback in case unlink, rename or rmdir fail for\nfiles in use on Windows. The added dialog will present a yes/no question\nto the the user which will currently be used by the windows compat layer\nto let the user retry a failed file operation.\n\nSigned-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n---\n\nSince the infrastructure for this is now in Junio's master lets also add\nit to git-gui. This patch contains a fix of the question helper which\ncorrectly wraps long lines in questions. I also disabled the\nresizeability of the dialog because the text would not be rewrapped\nanyway.\n\nCheers Heiko\n\n Makefile                  |    2 +\n git-gui.sh                |    3 ++\n git-gui/git-gui--askyesno |   52 +++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 57 insertions(+), 0 deletions(-)\n create mode 100755 git-gui/git-gui--askyesno\n\ndiff --git a/Makefile b/Makefile\nindex e22ba5c..d50b455 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -290,6 +290,7 @@ install: all\n \t$(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)\n \t$(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n \t$(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n+\t$(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n \t$(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\n ifdef GITGUI_WINDOWS_WRAPPER\n \t$(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n@@ -308,6 +309,7 @@ uninstall:\n \t$(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n \t$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)\n \t$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)\n+\t$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)\n \t$(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true\n ifdef GITGUI_WINDOWS_WRAPPER\n \t$(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)\ndiff --git a/git-gui.sh b/git-gui.sh\nindex d96df63..049bc70 100755\n--- a/git-gui.sh\n+++ b/git-gui.sh\n@@ -1158,6 +1158,9 @@ set have_tk85 [expr {[package vcompare $tk_version \"8.5\"] >= 0}]\n if {![info exists env(SSH_ASKPASS)]} {\n \tset env(SSH_ASKPASS) [gitexec git-gui--askpass]\n }\n+if {![info exists env(GIT_ASK_YESNO)]} {\n+\tset env(GIT_ASK_YESNO) [gitexec git-gui--askyesno]\n+}\n \n ######################################################################\n ##\ndiff --git a/git-gui/git-gui--askyesno b/git-gui/git-gui--askyesno\nnew file mode 100755\nindex 0000000..7604610\n--- /dev/null\n+++ b/git-gui/git-gui--askyesno\n@@ -0,0 +1,52 @@\n+#!/bin/sh\n+# Tcl ignores the next line -*- tcl -*- \\\n+exec wish \"$0\" -- \"$@\"\n+\n+# This is an implementation of a simple yes no dialog\n+# which is injected into the git commandline by git gui\n+# in case a yesno question needs to be answered.\n+\n+set NS {}\n+set use_ttk [package vsatisfies [package provide Tk] 8.5]\n+if {$use_ttk} {\n+\tset NS ttk\n+}\n+\n+if {$argc < 1} {\n+\tputs stderr \"Usage: $argv0 <question>\"\n+\texit 1\n+} else {\n+\tset prompt [join $argv \" \"]\n+}\n+\n+${NS}::frame .t\n+${NS}::label .t.m -text $prompt -justify left -width 40\n+pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1\n+pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1\n+bind .t.m <Map> {.t.m configure -wraplength [winfo width .t.m]}\n+\n+${NS}::frame .b\n+${NS}::frame .b.left -width 200\n+${NS}::button .b.yes -text Yes -command yes\n+${NS}::button .b.no  -text No  -command no\n+\n+\n+pack .b.left -side left -expand 1 -fill x\n+pack .b.yes -side left -expand 1\n+pack .b.no -side right -expand 1 -ipadx 5\n+pack .b -side bottom -fill x -ipadx 20 -ipady 15\n+\n+bind . <Key-Return> {exit 0}\n+bind . <Key-Escape> {exit 1}\n+\n+proc no {} {\n+\texit 1\n+}\n+\n+proc yes {} {\n+\texit 0\n+}\n+\n+wm title . \"Question?\"\n+wm resizable . 0 0\n+tk::PlaceWindow .\n-- \n1.7.4.rc3.9.gbf3bd\n"},{"id":"164191","messageId":"AANLkTikwa=PikZvAtvo_5FNuhG_D1052WsL5FraJMwic@mail.gmail.com","threadId":"26843","inReplyTo":"20110323203119.GA23905@book.hvoigt.net","subject":"Re: [PATCH] git-gui: provide question helper for retry fallback on Windows","fromName":"Pat Thoyts","fromEmail":"patthoyts@gmail.com","sentAt":"2011-03-24T00:06:32Z","receivedAt":"2011-03-24T00:06:32Z","isPatch":true,"sender":{"key":"patthoyts@gmail.com","avatar":"https://gravatar.com/avatar/bee887a777c790bd241f398217723fbe4b854428671db83db32216a28654cb25?d=mp&s=160"},"body":"On 23 March 2011 20:31, Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> Make use of the new environment variable GIT_ASK_YESNO to support the\n> recently implemented fallback in case unlink, rename or rmdir fail for\n> files in use on Windows. The added dialog will present a yes/no question\n> to the the user which will currently be used by the windows compat layer\n> to let the user retry a failed file operation.\n>\n> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>\n> ---\n>\n> Since the infrastructure for this is now in Junio's master lets also add\n> it to git-gui. This patch contains a fix of the question helper which\n> correctly wraps long lines in questions. I also disabled the\n> resizeability of the dialog because the text would not be rewrapped\n> anyway.\n>\n> Cheers Heiko\n>\n>  Makefile                  |    2 +\n>  git-gui.sh                |    3 ++\n>  git-gui/git-gui--askyesno |   52 +++++++++++++++++++++++++++++++++++++++++++++\n>  3 files changed, 57 insertions(+), 0 deletions(-)\n>  create mode 100755 git-gui/git-gui--askyesno\n>\n> diff --git a/Makefile b/Makefile\n> index e22ba5c..d50b455 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -290,6 +290,7 @@ install: all\n>        $(QUIET)$(INSTALL_D0)'$(DESTDIR_SQ)$(gitexecdir_SQ)' $(INSTALL_D1)\n>        $(QUIET)$(INSTALL_X0)git-gui $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n>        $(QUIET)$(INSTALL_X0)git-gui--askpass $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n> +       $(QUIET)$(INSTALL_X0)git-gui--askyesno $(INSTALL_X1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n>        $(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\n>  ifdef GITGUI_WINDOWS_WRAPPER\n>        $(QUIET)$(INSTALL_R0)git-gui.tcl $(INSTALL_R1) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n> @@ -308,6 +309,7 @@ uninstall:\n>        $(QUIET)$(CLEAN_DST) '$(DESTDIR_SQ)$(gitexecdir_SQ)'\n>        $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui $(REMOVE_F1)\n>        $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askpass $(REMOVE_F1)\n> +       $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui--askyesno $(REMOVE_F1)\n>        $(QUIET)$(foreach p,$(GITGUI_BUILT_INS), $(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/$p $(REMOVE_F1) &&) true\n>  ifdef GITGUI_WINDOWS_WRAPPER\n>        $(QUIET)$(REMOVE_F0)'$(DESTDIR_SQ)$(gitexecdir_SQ)'/git-gui.tcl $(REMOVE_F1)\n> diff --git a/git-gui.sh b/git-gui.sh\n> index d96df63..049bc70 100755\n> --- a/git-gui.sh\n> +++ b/git-gui.sh\n> @@ -1158,6 +1158,9 @@ set have_tk85 [expr {[package vcompare $tk_version \"8.5\"] >= 0}]\n>  if {![info exists env(SSH_ASKPASS)]} {\n>        set env(SSH_ASKPASS) [gitexec git-gui--askpass]\n>  }\n> +if {![info exists env(GIT_ASK_YESNO)]} {\n> +       set env(GIT_ASK_YESNO) [gitexec git-gui--askyesno]\n> +}\n>\n>  ######################################################################\n>  ##\n> diff --git a/git-gui/git-gui--askyesno b/git-gui/git-gui--askyesno\n> new file mode 100755\n> index 0000000..7604610\n> --- /dev/null\n> +++ b/git-gui/git-gui--askyesno\n> @@ -0,0 +1,52 @@\n> +#!/bin/sh\n> +# Tcl ignores the next line -*- tcl -*- \\\n> +exec wish \"$0\" -- \"$@\"\n> +\n> +# This is an implementation of a simple yes no dialog\n> +# which is injected into the git commandline by git gui\n> +# in case a yesno question needs to be answered.\n> +\n> +set NS {}\n> +set use_ttk [package vsatisfies [package provide Tk] 8.5]\n> +if {$use_ttk} {\n> +       set NS ttk\n> +}\n> +\n> +if {$argc < 1} {\n> +       puts stderr \"Usage: $argv0 <question>\"\n> +       exit 1\n> +} else {\n> +       set prompt [join $argv \" \"]\n> +}\n> +\n> +${NS}::frame .t\n> +${NS}::label .t.m -text $prompt -justify left -width 40\n> +pack .t.m -side top -fill x -padx 20 -pady 20 -expand 1\n> +pack .t -side top -fill x -ipadx 20 -ipady 20 -expand 1\n> +bind .t.m <Map> {.t.m configure -wraplength [winfo width .t.m]}\n> +\n> +${NS}::frame .b\n> +${NS}::frame .b.left -width 200\n> +${NS}::button .b.yes -text Yes -command yes\n> +${NS}::button .b.no  -text No  -command no\n> +\n> +\n> +pack .b.left -side left -expand 1 -fill x\n> +pack .b.yes -side left -expand 1\n> +pack .b.no -side right -expand 1 -ipadx 5\n> +pack .b -side bottom -fill x -ipadx 20 -ipady 15\n> +\n> +bind . <Key-Return> {exit 0}\n> +bind . <Key-Escape> {exit 1}\n> +\n> +proc no {} {\n> +       exit 1\n> +}\n> +\n> +proc yes {} {\n> +       exit 0\n> +}\n> +\n> +wm title . \"Question?\"\n> +wm resizable . 0 0\n> +tk::PlaceWindow .\n> --\n> 1.7.4.rc3.9.gbf3bd\n>\n>\n\nWhy not use the built-in message box function? This will then provide\nthe correct system defined look (or a suitable dialog on unix).\n\npackage require Tk\nproc main {message {title \"Question?\"}} {\n\twm withdraw .\n\tset r [tk_messageBox -icon question -type yesno -title $title \\\n\t\t\t   -message $message]\n\texit [expr {$r eq \"yes\" ? 0 : 1}]\n}\neval [linsert $argv 0 main]\n\nwould seem to be equivalent.\nI put up an image of the two (standard messagebox on top) at\nhttp://www.patthoyts.tk/screenshots/happy.png\n\nPat.\n"}]}