Skip to content

Commit 79a3ef5

Browse files
j6tttaylorr
authored andcommitted
gitk: collect construction of blameargs into a single conditional
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 <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 2aeb448 commit 79a3ef5

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

gitk

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3967,17 +3967,15 @@ proc show_line_source {} {
39673967
}
39683968
set line [lindex $h 1]
39693969
}
3970-
set blameargs {}
3970+
set blamefile [file join $cdup $flist_menu_file]
39713971
if {$from_index ne {}} {
3972-
lappend blameargs | git cat-file blob $from_index
3973-
}
3974-
lappend blameargs | git blame -p -L$line,+1
3975-
if {$from_index ne {}} {
3976-
lappend blameargs --contents -
3972+
set blameargs [list \
3973+
| git cat-file blob $from_index \
3974+
| git blame -p -L$line,+1 --contents - -- $blamefile]
39773975
} else {
3978-
lappend blameargs $id
3976+
set blameargs [list \
3977+
| git blame -p -L$line,+1 $id -- $blamefile]
39793978
}
3980-
lappend blameargs -- [file join $cdup $flist_menu_file]
39813979
if {[catch {
39823980
set f [open $blameargs r]
39833981
} err]} {

0 commit comments

Comments
 (0)