All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pat Thoyts <patthoyts@users.sourceforge.net>
To: "Murphy, John" <john.murphy@bankofamerica.com>
Cc: git@vger.kernel.org
Cc: "Paul Mackerras" <paulus@samba.org>
Subject: [PATCH] Re: Gitk --all error when there are more than 797 refs in a repository
Date: 18 Sep 2009 15:06:17 +0100	[thread overview]
Message-ID: <878wgcbb52.fsf@users.sourceforge.net> (raw)
In-Reply-To: <6F87406399731F489FBACE5C5FFA04584BFA53@ex2k.bankofamerica.com>

"Murphy, John" <john.murphy@bankofamerica.com> writes:

>There is a error when running  gitk --all when there are more than 797 refs in a repository.
>We get an error message:
>
>Error reading commits: fatal ambiguous argument '3': unknown revision or path not in the working tree.
>Use '--' to separate paths from revisions.
>
>I believe issue is with this line of the code in proc parseviewrevs:
>
>       if {[catch {set ids [eval exec git rev-parse "$revs"]} err]}
>
>When there are more than 797 refs the output of git rev-parse is too large to fit into the string, ids.
>
>797 refs = 32,677 bytes.
>798 refs = 32,718 bytes my guess is a little too close for comfort to 32,768 bytes.
>
>As I was deleting refs locally the error message would change from '3' to any char [A-Z,0-9].
>
>I am a novice tcl programmer but is seems like ids could be an array.
>There are also many other areas in the code where git rev-parse is called and using array may also be necessary.
>

Tcl strings can eat all your memory. However, there is a limit to the
size of the command line argument passed to CreateProcess.  MSDN says
of the lpCommandLine parameter:
  "The maximum length of this string is 32K characters."
A solution for this case will be to use a pipe to read the responses
instead of having it all returned to the caller.
The following patch might be sufficient:

--- patch begins -----

[PATCH] Avoid command-line limits when executing git rev-parse on windows.

This patch solves the problem handling large numbers of references
reported by John Murphy that is due to limits in executing processes
in Windows by reading the rev-parse result over a pipe.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
---
 gitk |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gitk b/gitk
index 1306178..1bd7d65 100755
--- a/gitk
+++ b/gitk
@@ -236,13 +236,23 @@ proc parseviewargs {n arglist} {
     return $allknown
 }
 
+proc git-rev-parse {args} {
+    set ids {}
+    set pipe [open |[linsert $args 0 git rev-parse] r]
+    while {[gets $pipe line] != -1} {
+        lappend ids $line
+    }
+    close $pipe
+    return $ids
+}
+    
 proc parseviewrevs {view revs} {
     global vposids vnegids
 
     if {$revs eq {}} {
 	set revs HEAD
     }
-    if {[catch {set ids [eval exec git rev-parse $revs]} err]} {
+    if {[catch {set ids [git-rev-parse $revs]} err]} {
 	# we get stdout followed by stderr in $err
 	# for an unknown rev, git rev-parse echoes it and then errors out
 	set errlines [split $err "\n"]
@@ -273,7 +283,7 @@ proc parseviewrevs {view revs} {
     set pos {}
     set neg {}
     set sdm 0
-    foreach id [split $ids "\n"] {
+    foreach id $ids {
 	if {$id eq "--gitk-symmetric-diff-marker"} {
 	    set sdm 4
 	} elseif {[string match "^*" $id]} {
-- 
1.6.4.msysgit.0



-- 
Pat Thoyts                            http://www.patthoyts.tk/
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD

  reply	other threads:[~2009-09-18 14:06 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-17 19:07 Gitk --all error when there are more than 797 refs in a repository Murphy, John
2009-09-18 14:06 ` Pat Thoyts [this message]
2009-09-18 15:16   ` [PATCH] " Johannes Sixt
2009-09-19  0:07   ` Paul Mackerras
2009-09-21 14:02     ` Murphy, John
2009-09-21 14:09       ` Johannes Sixt
2009-09-21 14:11         ` Murphy, John
2009-09-21 15:59           ` Johannes Sixt
2009-09-21 23:56             ` Pat Thoyts
2009-09-22  1:23               ` Murphy, John
2009-09-22  1:39               ` Junio C Hamano
2009-09-22  1:47                 ` Junio C Hamano
2009-09-22 22:48                   ` Pat Thoyts
2009-11-03 10:04                 ` Alex Riesen
2009-11-03 10:41                   ` Paul Mackerras
2009-09-22 23:30               ` Paul Mackerras
2009-09-23  0:02                 ` Junio C Hamano
2009-11-03  9:40                   ` Paul Mackerras
2009-11-03 14:59                     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878wgcbb52.fsf@users.sourceforge.net \
    --to=patthoyts@users.sourceforge.net \
    --cc=git@vger.kernel.org \
    --cc=john.murphy@bankofamerica.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.