]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-gui--askyesno: allow overriding the window title
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 28 Aug 2025 08:58:49 +0000 (08:58 +0000)
committerJohannes Sixt <j6t@kdbg.org>
Thu, 28 Aug 2025 20:54:20 +0000 (22:54 +0200)
"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 <title>` option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
git-gui--askyesno

index f7312c70c2ca68e9d8fcb81fba013c4158f341ba..d0c801c42c7c9441bbf7e25184015f6ba1297b7c 100755 (executable)
@@ -5,6 +5,10 @@ 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]
@@ -12,10 +16,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 " "]
 }
 
@@ -38,5 +47,5 @@ pack .b -side bottom -fill x -ipadx 20 -ipady 15
 bind . <Key-Return> {exit 0}
 bind . <Key-Escape> {exit 1}
 
-wm title . "Question?"
+wm title . $title
 tk::PlaceWindow .