From 19195fbd73994d05abaa0a2976143da96b320f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ansgar=20R=C3=B6ber?= Date: Thu, 9 Apr 2020 18:03:25 +0000 Subject: [PATCH 1/2] Subject: git-gui: fix syntax error because of missing semicolon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For some asynchronous operations, we build a chain of callbacks to execute when the operation is done. These callbacks are held in $after, and a new callback can be added by appending to $after. Once the operation is done, $after is executed as a script. But if we don't append a semi-colon after the procedure calls, they will appear to Tcl as arguments to the previous procedure's arguments. So, for example, if $after is "foo", and we just append "bar", then $after becomes "foo bar", and bar will be treated as an argument to foo. If foo does not accept any optional arguments, it would result in Tcl throwing an error. If instead we do append a semi-colon, $after will look like "foo;bar;", and these will be treated as two separate procedure calls. Before d9c6469 (git-gui: update status bar to track operations, 2019-12-01), this problem was masked because ui_ready/ui_status did accept an optional argument. In d9c6469, ui_ready stopped accepting an optional argument, and this error started showing up. Another instance of this problem is when a call to ui_status without a trailing semicolon. ui_status never accepted an optional argument to begin with, but the issue never managed to surface. So, fix these errors by making sure we always append a semi-colon after procedure calls when multiple callbacks are involved in $after. Helped-by: Pratyush Yadav Signed-off-by: Ansgar Röber --- git-gui.sh | 4 ++-- lib/index.tcl | 6 +++--- lib/mergetool.tcl | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/git-gui.sh b/git-gui.sh index 4610e4ca72..faaf93b431 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -2600,12 +2600,12 @@ proc toggle_or_diff {mode w args} { update_indexinfo \ "Unstaging [short_path $path] from commit" \ [list $path] \ - [concat $after [list ui_ready]] + [concat $after {ui_ready;}] } elseif {$w eq $ui_workdir} { update_index \ "Adding [short_path $path]" \ [list $path] \ - [concat $after [list ui_ready]] + [concat $after {ui_ready;}] } } else { set selected_paths($path) 1 diff --git a/lib/index.tcl b/lib/index.tcl index 1fc5b42300..d2ec24bd80 100644 --- a/lib/index.tcl +++ b/lib/index.tcl @@ -60,7 +60,7 @@ proc rescan_on_error {err {after {}}} { $::main_status stop_all unlock_index - rescan [concat $after [list ui_ready]] 0 + rescan [concat $after {ui_ready;}] 0 } proc update_indexinfo {msg path_list after} { @@ -314,7 +314,7 @@ proc unstage_helper {txt paths} { update_indexinfo \ $txt \ $path_list \ - [concat $after [list ui_ready]] + [concat $after {ui_ready;}] } } @@ -366,7 +366,7 @@ proc add_helper {txt paths} { update_index \ $txt \ $path_list \ - [concat $after {ui_status [mc "Ready to commit."]}] + [concat $after {ui_status [mc "Ready to commit."];}] } } diff --git a/lib/mergetool.tcl b/lib/mergetool.tcl index 120bc4064b..e688b016ef 100644 --- a/lib/mergetool.tcl +++ b/lib/mergetool.tcl @@ -59,7 +59,7 @@ proc merge_add_resolution {path} { update_index \ [mc "Adding resolution for %s" [short_path $path]] \ [list $path] \ - [concat $after [list ui_ready]] + [concat $after {ui_ready;}] } proc merge_force_stage {stage} { From e5894146b0e38cd5754ee60676110208c470ff34 Mon Sep 17 00:00:00 2001 From: Ismael Luceno Date: Tue, 12 May 2020 12:28:06 +0200 Subject: [PATCH 2/2] git-gui: Handle Ctrl + BS/Del in the commit msg - Control+BackSpace: Delete word to the left of the cursor. - Control+Delete : Delete word to the right of the cursor. Originally introduced by BRIEF and Turbo Vision between 1985 and 1992, they were adopted by most CUA-Compliant UIs, including those of: OS/2, Windows, Mac OS, Qt, GTK, Open/Libre Office, Gecko, and GNU Emacs. In both cases Tk already implements the functionality bound to other key combination, so we use that. Graphical examples: Deleting to the left: v------ pointer X_WORD____X ^-----^------ selection Deleting to the right: v--------- pointer X_WORD_X ^--^------ selection Signed-off-by: Ismael Luceno Signed-off-by: Pratyush Yadav --- git-gui.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git-gui.sh b/git-gui.sh index faaf93b431..49bd86e635 100755 --- a/git-gui.sh +++ b/git-gui.sh @@ -3928,6 +3928,8 @@ bind $ui_comm <$M1B-Key-KP_Subtract> {show_less_context;break} bind $ui_comm <$M1B-Key-equal> {show_more_context;break} bind $ui_comm <$M1B-Key-plus> {show_more_context;break} bind $ui_comm <$M1B-Key-KP_Add> {show_more_context;break} +bind $ui_comm <$M1B-Key-BackSpace> {event generate %W ;break} +bind $ui_comm <$M1B-Key-Delete> {event generate %W ;break} bind $ui_diff <$M1B-Key-x> {tk_textCopy %W;break} bind $ui_diff <$M1B-Key-X> {tk_textCopy %W;break}