Skip to content

Commit d8f76c8

Browse files
FauxFauxnalla
authored andcommitted
Fix another invocation of git from gitk with an overly long command-line
Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 95d8be2 commit d8f76c8

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

gitk-git/gitk

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ proc start_rev_list {view} {
406406
if {$revs eq {}} {
407407
return 0
408408
}
409-
set args [concat $vflags($view) $revs]
409+
set args [limit_arg_length [concat $vflags($view) $revs]]
410410
} else {
411411
set args $vorigargs($view)
412412
}
@@ -9910,18 +9910,7 @@ proc getallcommits {} {
99109910
}
99119911
}
99129912
if {$ids ne {}} {
9913-
set cmd [concat $cmd $ids]
9914-
# The maximum command line length for the CreateProcess function is 32767 characters, see
9915-
# http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx
9916-
# Be a little conservative in case Tcl adds some more stuff to the command line we do not
9917-
# know about and truncate the command line at a SHA1-boundary below 32000 characters.
9918-
if {[tk windowingsystem] == "win32" &&
9919-
[string length $cmd] > 32000} {
9920-
set ndx [string last " " $cmd 32000]
9921-
if {$ndx != -1} {
9922-
set cmd [string range $cmd 0 $ndx]
9923-
}
9924-
}
9913+
set cmd [limit_arg_length [concat $cmd $ids]]
99259914
set fd [open $cmd r]
99269915
fconfigure $fd -blocking 0
99279916
incr allcommits
@@ -9932,6 +9921,21 @@ proc getallcommits {} {
99329921
}
99339922
}
99349923

9924+
# The maximum command line length for the CreateProcess function is 32767 characters, see
9925+
# http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx
9926+
# Be a little conservative in case Tcl adds some more stuff to the command line we do not
9927+
# know about and truncate the command line at a SHA1-boundary below 32000 characters.
9928+
proc limit_arg_length {cmd} {
9929+
if {[tk windowingsystem] == "win32" &&
9930+
[string length $cmd] > 32000} {
9931+
set ndx [string last " " $cmd 32000]
9932+
if {$ndx != -1} {
9933+
return [string range $cmd 0 $ndx]
9934+
}
9935+
}
9936+
return $cmd
9937+
}
9938+
99359939
# Since most commits have 1 parent and 1 child, we group strings of
99369940
# such commits into "arcs" joining branch/merge points (BMPs), which
99379941
# are commits that either don't have 1 parent or don't have 1 child.

0 commit comments

Comments
 (0)