From b57bc7d8b9b290e872e9fa3d023ebeea7e7485ad Mon Sep 17 00:00:00 2001 From: "Chris West (Faux)" Date: Mon, 26 Jul 2010 00:36:19 +0100 Subject: [PATCH] Fix another invocation of git from gitk with an overly long command-line Signed-off-by: Sebastian Schuberth --- gitk-git/gitk | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index 1682042f5a..03bc1f60d2 100755 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -394,7 +394,7 @@ proc start_rev_list {view} { if {$revs eq {}} { return 0 } - set args [concat $vflags($view) $revs] + set args [limit_arg_length [concat $vflags($view) $revs]] } else { set args $vorigargs($view) } @@ -9576,18 +9576,7 @@ proc getallcommits {} { } } if {$ids ne {}} { - set cmd [concat $cmd $ids] - # The maximum command line length for the CreateProcess function is 32767 characters, see - # http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx - # Be a little conservative in case Tcl adds some more stuff to the command line we do not - # know about and truncate the command line at a SHA1-boundary below 32000 characters. - if {[tk windowingsystem] == "win32" && - [string length $cmd] > 32000} { - set ndx [string last " " $cmd 32000] - if {$ndx != -1} { - set cmd [string range $cmd 0 $ndx] - } - } + set cmd [limit_arg_length [concat $cmd $ids]] set fd [open $cmd r] fconfigure $fd -blocking 0 incr allcommits @@ -9598,6 +9587,21 @@ proc getallcommits {} { } } +# The maximum command line length for the CreateProcess function is 32767 characters, see +# http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx +# Be a little conservative in case Tcl adds some more stuff to the command line we do not +# know about and truncate the command line at a SHA1-boundary below 32000 characters. +proc limit_arg_length {cmd} { + if {[tk windowingsystem] == "win32" && + [string length $cmd] > 32000} { + set ndx [string last " " $cmd 32000] + if {$ndx != -1} { + return [string range $cmd 0 $ndx] + } + } + return $cmd +} + # Since most commits have 1 parent and 1 child, we group strings of # such commits into "arcs" joining branch/merge points (BMPs), which # are commits that either don't have 1 parent or don't have 1 child. -- 2.11.4.GIT