Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit efd5f2a

Browse files
dschokblees
authored andcommitted
Work around the command line limit on Windows
On Windows, there are dramatic problems when a command line grows beyond PATH_MAX, which is restricted to 8191 characters on XP and later (according to http://support.microsoft.com/kb/830473). Work around this by just cutting off the command line at that length (actually, at a space boundary) in the hope that only negative refs are chucked: gitk will then do unnecessary work, but that is still better than flashing the gitk window and exiting with exit status 5 (which no Windows user is able to make sense of). 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 <[email protected]> Signed-off-by: Pat Thoyts <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 20ba112 commit efd5f2a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

gitk-git/gitk

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9969,7 +9969,19 @@ proc getallcommits {} {
99699969
}
99709970
}
99719971
if {$ids ne {}} {
9972-
set fd [open [concat $cmd $ids] r]
9972+
set cmd [concat $cmd $ids]
9973+
# The maximum command line length for the CreateProcess function is 32767 characters, see
9974+
# http://blogs.msdn.com/oldnewthing/archive/2003/12/10/56028.aspx
9975+
# Be a little conservative in case Tcl adds some more stuff to the command line we do not
9976+
# know about and truncate the command line at a SHA1-boundary below 32000 characters.
9977+
if {[tk windowingsystem] == "win32" &&
9978+
[string length $cmd] > 32000} {
9979+
set ndx [string last " " $cmd 32000]
9980+
if {$ndx != -1} {
9981+
set cmd [string range $cmd 0 $ndx]
9982+
}
9983+
}
9984+
set fd [open $cmd r]
99739985
fconfigure $fd -blocking 0
99749986
incr allcommits
99759987
nowbusy allcommits

0 commit comments

Comments
 (0)