From: Scott Lamb <slamb@slamb.org>
To: Simon Hausmann <simon@lst.de>
Cc: git@vger.kernel.org, Scott Lamb <slamb@slamb.org>
Subject: [PATCH 2/2] git-p4: input to "p4 files" by stdin instead of arguments
Date: Sun, 15 Jul 2007 20:58:11 -0700 [thread overview]
Message-ID: <11845582942124-git-send-email-slamb@slamb.org> (raw)
In-Reply-To: <11845582912155-git-send-email-slamb@slamb.org>
This approach, suggested by Alex Riesen, bypasses the need for xargs-style
argument list handling. The handling in question looks broken in a corner
case with SC_ARG_MAX=4096 and final argument over 96 characters.
Signed-off-by: Scott Lamb <slamb@slamb.org>
---
contrib/fast-import/git-p4 | 28 +++++++---------------------
1 files changed, 7 insertions(+), 21 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index d93e656..54053e3 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -725,27 +725,13 @@ class P4Sync(Command):
if not files:
return
- # We cannot put all the files on the command line
- # OS have limitations on the max lenght of arguments
- # POSIX says it's 4096 bytes, default for Linux seems to be 130 K.
- # and all OS from the table below seems to be higher than POSIX.
- # See http://www.in-ulm.de/~mascheck/various/argmax/
- if (self.isWindows):
- argmax = 2000
- else:
- argmax = min(4000, os.sysconf('SC_ARG_MAX'))
-
- chunk = ''
- filedata = []
- for i in xrange(len(files)):
- f = files[i]
- chunk += '"%s#%s" ' % (f['path'], f['rev'])
- if len(chunk) > argmax or i == len(files)-1:
- data = p4CmdList('print %s' % chunk)
- if "p4ExitCode" in data[0]:
- die("Problems executing p4. Error: [%d]." % (data[0]['p4ExitCode']));
- filedata.extend(data)
- chunk = ''
+ filedata = p4CmdList('-x - print',
+ stdin='\n'.join(['%s#%s' % (f['path'], f['rev'])
+ for f in files]),
+ stdin_mode='w+')
+ if "p4ExitCode" in filedata[0]:
+ die("Problems executing p4. Error: [%d]."
+ % (filedata[0]['p4ExitCode']));
j = 0;
contents = {}
--
1.5.2.2.238.g7cbf2f2-dirty
next prev parent reply other threads:[~2007-07-16 3:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-16 3:58 [PATCH 1/2] git-p4: use subprocess in p4CmdList Scott Lamb
2007-07-16 3:58 ` Scott Lamb [this message]
2007-07-16 18:33 ` Simon Hausmann
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=11845582942124-git-send-email-slamb@slamb.org \
--to=slamb@slamb.org \
--cc=git@vger.kernel.org \
--cc=simon@lst.de \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).