From 160204121d4beabeede436491c5d9ab80f5b4778 Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 10 Mar 2010 11:56:19 +0100 Subject: [PATCH] gitk: Second try to work around the command line limit on Windows The first fix caused Tcl to fail to compile the regexp, see msysGit issue 427. Here is another fix without using regexp, and using a more relaxed command line length limit to fix the original issue 387. Signed-off-by: Sebastian Schuberth Signed-off-by: Pat Thoyts --- gitk-git/gitk | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/gitk-git/gitk b/gitk-git/gitk index 2331694bb5..1fa5acb910 100644 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -9418,11 +9418,16 @@ proc getallcommits {} { } if {$ids ne {}} { set cmd [concat $cmd $ids] - # XP and later accept up to 8191 characters in the command line - # see http://support.microsoft.com/kb/830473 + # 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] > 8191} { - set cmd [regsub "^(.{1,8191}) .*\$" $cmd "\\1"] + [string length $cmd] > 32000} { + set ndx [string last " " $cmd 32000] + if {$ndx != -1} { + set cmd [string range $cmd 0 $ndx] + } } set fd [open $cmd r] fconfigure $fd -blocking 0 -- 2.11.4.GIT