Skip to content

Commit 6eb797f

Browse files
j6tttaylorr
authored andcommitted
gitk: have callers of diffcmd supply pipe symbol when necessary
Function 'diffcmd' derives which of git diff-files, git diff-index, or git diff-tree must be invoked depending on the ids provided. It puts the pipe symbol as the first element of the returned command list. Note though that of the four callers only two use the command with Tcl 'open' and need the pipe symbol. The other two callers pass the command to Tcl 'exec' and must remove the pipe symbol. Do not include the pipe symbol in the constructed command list, but let the call sites decide whether to add it or not. Note that Tcl 'open' inspects only the first character of the command list, which is also the first character of the first element in the list. For this reason, it is valid to just tack on the pipe symbol with |$cmd and it is not necessary to use [concat | $cmd]. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent b966b73 commit 6eb797f

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

gitk

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7892,15 +7892,15 @@ proc diffcmd {ids flags} {
78927892
if {$i >= 0} {
78937893
if {[llength $ids] > 1 && $j < 0} {
78947894
# comparing working directory with some specific revision
7895-
set cmd [concat | git diff-index $flags]
7895+
set cmd [concat git diff-index $flags]
78967896
if {$i == 0} {
78977897
lappend cmd -R [lindex $ids 1]
78987898
} else {
78997899
lappend cmd [lindex $ids 0]
79007900
}
79017901
} else {
79027902
# comparing working directory with index
7903-
set cmd [concat | git diff-files $flags]
7903+
set cmd [concat git diff-files $flags]
79047904
if {$j == 1} {
79057905
lappend cmd -R
79067906
}
@@ -7909,7 +7909,7 @@ proc diffcmd {ids flags} {
79097909
if {[package vcompare $git_version "1.7.2"] >= 0} {
79107910
set flags "$flags --ignore-submodules=dirty"
79117911
}
7912-
set cmd [concat | git diff-index --cached $flags]
7912+
set cmd [concat git diff-index --cached $flags]
79137913
if {[llength $ids] > 1} {
79147914
# comparing index with specific revision
79157915
if {$j == 0} {
@@ -7925,7 +7925,7 @@ proc diffcmd {ids flags} {
79257925
if {$log_showroot} {
79267926
lappend flags --root
79277927
}
7928-
set cmd [concat | git diff-tree -r $flags $ids]
7928+
set cmd [concat git diff-tree -r $flags $ids]
79297929
}
79307930
return $cmd
79317931
}
@@ -7937,7 +7937,7 @@ proc gettreediffs {ids} {
79377937
if {$limitdiffs && $vfilelimit($curview) ne {}} {
79387938
set cmd [concat $cmd -- $vfilelimit($curview)]
79397939
}
7940-
if {[catch {set gdtf [open $cmd r]}]} return
7940+
if {[catch {set gdtf [open |$cmd r]}]} return
79417941

79427942
set treepending $ids
79437943
set treediff {}
@@ -8057,7 +8057,7 @@ proc getblobdiffs {ids} {
80578057
if {$limitdiffs && $vfilelimit($curview) ne {}} {
80588058
set cmd [concat $cmd -- $vfilelimit($curview)]
80598059
}
8060-
if {[catch {set bdf [open $cmd r]} err]} {
8060+
if {[catch {set bdf [open |$cmd r]} err]} {
80618061
error_popup [mc "Error getting diffs: %s" $err]
80628062
return
80638063
}
@@ -9080,8 +9080,6 @@ proc getpatchid {id} {
90809080

90819081
if {![info exists patchids($id)]} {
90829082
set cmd [diffcmd [list $id] {-p --root}]
9083-
# trim off the initial "|"
9084-
set cmd [lrange $cmd 1 end]
90859083
if {[catch {
90869084
set x [eval exec $cmd | git patch-id]
90879085
set patchids($id) [lindex $x 0]
@@ -9326,8 +9324,6 @@ proc mkpatchgo {} {
93269324
set newid [$patchtop.tosha1 get]
93279325
set fname [$patchtop.fname get]
93289326
set cmd [diffcmd [list $oldid $newid] -p]
9329-
# trim off the initial "|"
9330-
set cmd [lrange $cmd 1 end]
93319327
lappend cmd >$fname &
93329328
if {[catch {eval exec $cmd} err]} {
93339329
error_popup "[mc "Error creating patch:"] $err" $patchtop

0 commit comments

Comments
 (0)