git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-svnimport.perl: fix for 'arg list too long...'

From
Junio C Hamano <junkio@cox.net>
Date
Feb 1, 2006, 22:50 UTC
Message-ID
<7v3bj27kxe.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20060201215454.GB31711@sashak.voltaire.com>
Sasha Khapyorsky <sashak@voltaire.com> writes:
Show 11 quoted lines
> On 12:27 Wed 01 Feb     , Junio C Hamano wrote:
>> Sasha Khapyorsky <sashak@voltaire.com> writes:
>> 
>> > This fixes 'arg list too long..' problem with git-ls-files.
>> 
>> I wonder if feeding the list into a pipe to 'update-index --stdin' 
>> would be an option.
>
> This can be option for git-update-index, but my problem was with
> git-ls-files, git-update-index was ok (arg list processing were splitted
> already).

I was commenting on the "while (@o1)" loop that splices at 50 when the list has more than 55 items to feed update-index. You could accumulate output from multiple invocations of ls-files and feed everything to a single "update-index --stdin" after the "while (@old)" loop is done. Batch of 50 vs a single batch may not matter though [*1*].

But you are right; that git-ls-files can get too many arguments unless you split like that.

A casual skimming over the rest of the code tells me that this fixes the last instance of such a command invocation with too many arguments. Good catch.

Smurf, I do not have problems with Sasha's patch. Are you OK if I apply it?

-- >8 --

*1* I do not think this makes much of a difference but here is what I mean.

diff --git a/git-svnimport.perl b/git-svnimport.perl
index b6799d8..d76a595 100755
--- a/git-svnimport.perl
+++ b/git-svnimport.perl
@@ -546,7 +546,8 @@ sub commit {
 			}
 		}
 
-		while(@old) {
+		my @u = ();
+		while (@old) {
 			my @o1;
 			if(@old > 55) {
 				@o1 = splice(@old,0,50);
@@ -555,26 +556,19 @@ sub commit {
 				@old = ();
 			}
 			open my $F, "-|", "git-ls-files", "-z", @o1 or die $!;
-			@o1 = ();
 			local $/ = "\0";
 			while(<$F>) {
 				chomp;
-				push(@o1,$_);
+				push(@u,$_);
 			}
 			close($F);
-
-			while(@o1) {
-				my @o2;
-				if(@o1 > 55) {
-					@o2 = splice(@o1,0,50);
-				} else {
-					@o2 = @o1;
-					@o1 = ();
-				}
-				system("git-update-index","--force-remove","--",@o2);
-				die "Cannot remove files: $?\n" if $?;
-			}
 		}
+		open my $F, "|-",
+			qw(git-update-index --force-remove -z --stdin)
+				or die $!;
+		print $F "$_\0" for @u;
+		close $F or die $!;
+
 		while(@new) {
 			my @n2;
 			if(@new > 12) {
Previous: Sasha KhapyorskyNext: Matthias Urlichs
Message 4 of 6 in “git-svnimport.perl: fix for 'arg list too long...'”
  1. git-svnimport.perl: fix for 'arg list too long...'Sasha Khapyorsky, Feb 1, 2006
  2. Junio C HamanoFeb 1, 2006
  3. Sasha KhapyorskyFeb 1, 2006
  4. Junio C HamanoFeb 1, 2006
  5. Matthias UrlichsFeb 1, 2006
  6. Sasha KhapyorskyFeb 2, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.