Skip to content

Commit 1e2f781

Browse files
committed
Merge pull request #2170 from dscho/gitk-long-cmdline
Fix gitk (long cmdline)
2 parents 0bae942 + f54f915 commit 1e2f781

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

gitk-git/gitk

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,16 @@ proc parseviewrevs {view revs} {
488488
return $ret
489489
}
490490
491+
# Escapes a list of filter paths to be passed to git log via stdin. Note that
492+
# paths must not be quoted.
493+
proc escape_filter_paths {paths} {
494+
set escaped [list]
495+
foreach path $paths {
496+
lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path]
497+
}
498+
return $escaped
499+
}
500+
491501
# Start off a git log process and arrange to read its output
492502
proc start_rev_list {view} {
493503
global startmsecs commitidx viewcomplete curview
@@ -540,14 +550,17 @@ proc start_rev_list {view} {
540550
if {$revs eq {}} {
541551
return 0
542552
}
543-
set args [concat $vflags($view) $revs]
553+
set args $vflags($view)
544554
} else {
555+
set revs {}
545556
set args $vorigargs($view)
546557
}
547558
548559
if {[catch {
549560
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
550-
--parents --boundary $args "--" $files] r]
561+
--parents --boundary $args --stdin \
562+
"<<[join [concat $revs "--" \
563+
[escape_filter_paths $files]] "\\n"]"] r]
551564
} err]} {
552565
error_popup "[mc "Error executing git log:"] $err"
553566
return 0
@@ -689,13 +702,20 @@ proc updatecommits {} {
689702
set revs $newrevs
690703
set vposids($view) [lsort -unique [concat $oldpos $vposids($view)]]
691704
}
692-
set args [concat $vflags($view) $revs --not $oldpos]
705+
set args $vflags($view)
706+
foreach r $oldpos {
707+
lappend revs "^$r"
708+
}
693709
} else {
710+
set revs {}
694711
set args $vorigargs($view)
695712
}
696713
if {[catch {
697714
set fd [open [concat | git log --no-color -z --pretty=raw $show_notes \
698-
--parents --boundary $args "--" $vfilelimit($view)] r]
715+
--parents --boundary $args --stdin \
716+
"<<[join [concat $revs "--" \
717+
[escape_filter_paths \
718+
$vfilelimit($view)]] "\\n"]"] r]
699719
} err]} {
700720
error_popup "[mc "Error executing git log:"] $err"
701721
return
@@ -10366,10 +10386,16 @@ proc getallcommits {} {
1036610386
foreach id $seeds {
1036710387
lappend ids "^$id"
1036810388
}
10389+
lappend ids "--"
1036910390
}
1037010391
}
1037110392
if {$ids ne {}} {
10372-
set fd [open [concat $cmd $ids] r]
10393+
if {$ids eq "--all"} {
10394+
set cmd [concat $cmd "--all"]
10395+
} else {
10396+
set cmd [concat $cmd --stdin "<<[join $ids "\\n"]"]
10397+
}
10398+
set fd [open $cmd r]
1037310399
fconfigure $fd -blocking 0
1037410400
incr allcommits
1037510401
nowbusy allcommits

0 commit comments

Comments
 (0)