]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: collect construction of blameargs into a single conditional
authorJohannes Sixt <j6t@kdbg.org>
Sun, 23 Mar 2025 21:34:11 +0000 (22:34 +0100)
committerTaylor Blau <me@ttaylorr.com>
Fri, 23 May 2025 21:03:30 +0000 (17:03 -0400)
The command line to invoke 'git blame' for a single line is constructed
using several if-conditionals, each with the same condition
{$from_index new {}}. Merge all of them into a single conditional.
This requires to duplicate significant parts of the command, but it
helps the next change, where we will have to deal with a nested list
structure.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
gitk

diff --git a/gitk b/gitk
index 22da6a811c2081f542365154d576fc0cd81e53c3..2e37ddea969d1ed62cffabce9d271be0ca634bec 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -3967,17 +3967,15 @@ proc show_line_source {} {
         }
         set line [lindex $h 1]
     }
-    set blameargs {}
+    set blamefile [file join $cdup $flist_menu_file]
     if {$from_index ne {}} {
-        lappend blameargs | git cat-file blob $from_index
-    }
-    lappend blameargs | git blame -p -L$line,+1
-    if {$from_index ne {}} {
-        lappend blameargs --contents -
+        set blameargs [list \
+            | git cat-file blob $from_index \
+            | git blame -p -L$line,+1 --contents - -- $blamefile]
     } else {
-        lappend blameargs $id
+        set blameargs [list \
+            | git blame -p -L$line,+1 $id -- $blamefile]
     }
-    lappend blameargs -- [file join $cdup $flist_menu_file]
     if {[catch {
         set f [open $blameargs r]
     } err]} {