-
Notifications
You must be signed in to change notification settings - Fork 156
git-gui: GIT_ASK_YESNO/GIT_ASKPASS patches from Git for Windows #358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: git-gui/master
Are you sure you want to change the base?
Changes from all commits
08b106e
e1aef53
2e7e2c1
4b04832
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Pratyush Yadav wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Pratyush Yadav wrote (reply to this):
|
||
# 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} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Mark Levedahl wrote (reply to this): git-gui includes git-gui--yesno that relies upon Tk 8.5 constructs, and
this dialog box is not supported with Tk 9.0. Tk provides tk_messagebox
for this same purpose, fully supported in Tk 8.5+, so use tk_messagebox
instead.
Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
---
git-gui--askyesno | 35 +++++++----------------------------
1 file changed, 7 insertions(+), 28 deletions(-)
diff --git a/git-gui--askyesno b/git-gui--askyesno
index 142d1bc..cd986f2 100755
--- a/git-gui--askyesno
+++ b/git-gui--askyesno
@@ -10,12 +10,6 @@ exec wish "$0" -- "$@"
# 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>"
@@ -28,25 +22,7 @@ if {$argc < 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}
-
+set dlgicon {question}
if {$::tcl_platform(platform) eq {windows}} {
set icopath [file dirname [file normalize $argv0]]
if {[file tail $icopath] eq {git-core}} {
@@ -55,9 +31,12 @@ 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 dlgicon $icopath
}
}
-wm title . $title
-tk::PlaceWindow .
+wm withdraw .
+
+option add *Dialog.msg.font {Sans 10}
+set ans [tk_messageBox -icon $dlgicon -message $prompt -title $title -type yesno]
+exit [expr $ans eq {no}]
--
2.51.0.99.15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Schindelin wrote (reply to this): Hi Mark,
On Thu, 28 Aug 2025, Mark Levedahl wrote:
> git-gui includes git-gui--yesno that relies upon Tk 8.5 constructs, and
> this dialog box is not supported with Tk 9.0. Tk provides tk_messagebox
> for this same purpose, fully supported in Tk 8.5+, so use tk_messagebox
> instead.
Thank you very much!
Let's keep your patch separate, to give you full credit, and to keep
Heiko's patch as close to the original that has survived in Git for
Windows for so long.
Ciao,
Johannes
>
> Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
> ---
> git-gui--askyesno | 35 +++++++----------------------------
> 1 file changed, 7 insertions(+), 28 deletions(-)
>
> diff --git a/git-gui--askyesno b/git-gui--askyesno
> index 142d1bc..cd986f2 100755
> --- a/git-gui--askyesno
> +++ b/git-gui--askyesno
> @@ -10,12 +10,6 @@ exec wish "$0" -- "$@"
> # 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>"
> @@ -28,25 +22,7 @@ if {$argc < 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}
> -
> +set dlgicon {question}
> if {$::tcl_platform(platform) eq {windows}} {
> set icopath [file dirname [file normalize $argv0]]
> if {[file tail $icopath] eq {git-core}} {
> @@ -55,9 +31,12 @@ 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 dlgicon $icopath
> }
> }
>
> -wm title . $title
> -tk::PlaceWindow .
> +wm withdraw .
> +
> +option add *Dialog.msg.font {Sans 10}
> +set ans [tk_messageBox -icon $dlgicon -message $prompt -title $title -type yesno]
> +exit [expr $ans eq {no}]
> --
> 2.51.0.99.15
>
>
> There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Sixt wrote (reply to this): Am 28.08.25 um 15:33 schrieb Mark Levedahl:
> git-gui includes git-gui--yesno that relies upon Tk 8.5 constructs, and
/--yesno/--askyesno/? BTW, I wonder which constructs you mean.
> this dialog box is not supported with Tk 9.0. Tk provides tk_messagebox
> for this same purpose, fully supported in Tk 8.5+, so use tk_messagebox
> instead.
Which "this dialog box" do you mean here? The old code looks like a
usual Tk main window to me.
>
> Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
> ---
> git-gui--askyesno | 35 +++++++----------------------------
> 1 file changed, 7 insertions(+), 28 deletions(-)
>
> diff --git a/git-gui--askyesno b/git-gui--askyesno
> index 142d1bc..cd986f2 100755
> --- a/git-gui--askyesno
> +++ b/git-gui--askyesno
> @@ -10,12 +10,6 @@ exec wish "$0" -- "$@"
> # 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>"
> @@ -28,25 +22,7 @@ if {$argc < 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}
> -
> +set dlgicon {question}
> if {$::tcl_platform(platform) eq {windows}} {
> set icopath [file dirname [file normalize $argv0]]
> if {[file tail $icopath] eq {git-core}} {
> @@ -55,9 +31,12 @@ 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 dlgicon $icopath
> }
> }
I think there is a misunderstanding what the purpose of this icon is. It
is the icon shown on the window frame/decoration, not the icon next to
the text.
>
> -wm title . $title
> -tk::PlaceWindow .
> +wm withdraw .
> +
> +option add *Dialog.msg.font {Sans 10}
Is this to replicate the old appearance? I don't think it is necessary.
Let's assume tk_messageBox does a sensible thing.
> +set ans [tk_messageBox -icon $dlgicon -message $prompt -title $title -type yesno]
This option -icon can only be one of the words error, info, question or
warning. It has nothing to do with the icon above.
> +exit [expr $ans eq {no}]
-- Hannes
|
||
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 . |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1130,6 +1130,12 @@ set argv0dir [file dirname [file normalize $::argv0]] | |
if {![info exists env(SSH_ASKPASS)]} { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Pratyush Yadav wrote (reply to this):
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the Git mailing list, Johannes Sixt wrote (reply to this): Am 28.08.25 um 10:58 schrieb Johannes Schindelin via GitGitGadget:
> @@ -1130,6 +1130,9 @@ 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) [gitexec git-gui--askpass]
Is this [gitexec ...] deliberate, or can this be [file join ...] like in
the surrounding cases? If it is deliberate, we need an updated commit
message and/or a comment, otherwise, I can amend locally while queuing.
> +}
> if {![info exists env(GIT_ASK_YESNO)]} {
> set env(GIT_ASK_YESNO) [file join $argv0dir git-gui--askyesno]
> }
|
||
set env(SSH_ASKPASS) [file join $argv0dir 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) [file join $argv0dir git-gui--askyesno] | ||
} | ||
unset argv0dir | ||
|
||
###################################################################### | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the Git mailing list, Pratyush Yadav wrote (reply to this):