git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-mv is not able to handle big directories
@ 2005-11-23  5:41 Alexander Litvinov
  2005-11-23  6:14 ` Junio C Hamano
  0 siblings, 1 reply; 23+ messages in thread
From: Alexander Litvinov @ 2005-11-23  5:41 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 473 bytes --]

When moving directory with large number of files git-mv says:
> git-mv jsp* .
Can't exec "git-update-index": Argument list too long at /usr/local/bin/git-mv 
line 193.
git-update-index failed to add new names with code -1

This patch fixes this by building list of files with limited len (currently 
5000) and executing git-update-index few times until all files will be 
processed. I don't know how to determinate limit of command line but 5000 
seems safe enougth to me.

[-- Attachment #2: git-mv.perl.patch --]
[-- Type: text/x-diff, Size: 1492 bytes --]

--- git-mv.perl.orig	2005-11-23 11:24:10.000000000 +0600
+++ git-mv.perl	2005-11-23 11:33:31.000000000 +0600
@@ -185,13 +185,36 @@
 }
 	
 my $rc;
-if (scalar @changedfiles >0) {
-	$rc = system("git-update-index","--",@changedfiles);
+while (scalar @changedfiles >0) {
+	my @toHandle = ();
+	my $len = 0;
+	while ($len < 5000 && scalar(@changedfiles) >0) {
+		my $f = pop(@changedfiles);
+		$len += length($f) + 1;
+		push(@toHandle, $f);
+	}
+	$rc = system("git-update-index","--",@toHandle);
 	die "git-update-index failed to update changed files with code $?\n" if $rc;
 }
-if (scalar @addedfiles >0) {
-	$rc = system("git-update-index","--add","--",@addedfiles);
+while (scalar @addedfiles >0) {
+	my @toHandle = ();
+	my $len = 0;
+	while ($len < 5000 && scalar(@addedfiles) >0) {
+		my $f = pop(@addedfiles);
+		$len += length($f) + 1;
+		push(@toHandle, $f);
+	}
+	$rc = system("git-update-index","--add","--",@toHandle);
 	die "git-update-index failed to add new names with code $?\n" if $rc;
 }
-$rc = system("git-update-index","--remove","--",@deletedfiles);
-die "git-update-index failed to remove old names with code $?\n" if $rc;
+while (scalar @deletedfiles > 0) {
+	my @toHandle = ();
+	my $len = 0;
+	while ($len < 5000 && scalar(@deletedfiles) >0) {
+		my $f = pop(@deletedfiles);
+		$len += length($f) + 1;
+		push(@toHandle, $f);
+	}
+	$rc = system("git-update-index","--remove","--",@toHandle);
+	die "git-update-index failed to remove old names with code $?\n" if $rc;
+}

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2005-11-28  8:49 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-23  5:41 [PATCH] git-mv is not able to handle big directories Alexander Litvinov
2005-11-23  6:14 ` Junio C Hamano
2005-11-23  6:32   ` Junio C Hamano
2005-11-23  7:55     ` Randal L. Schwartz
2005-11-23  8:37       ` Junio C Hamano
2005-11-23 13:56         ` Ryan Anderson
2005-11-23 14:27           ` Perl version support (was Re: [PATCH] git-mv is not able to handle big directories) Randal L. Schwartz
2005-11-23 19:47             ` Perl version support Junio C Hamano
2005-11-23 19:59               ` Randal L. Schwartz
2005-11-23 21:56             ` Perl version support (was Re: [PATCH] git-mv is not able to handle big directories) H. Peter Anvin
2005-11-23 22:01               ` Randal L. Schwartz
2005-11-23 22:02               ` Morten Welinder
2005-11-28  1:46             ` Ryan Anderson
2005-11-28  8:49               ` Andreas Ericsson
2005-11-23 18:53           ` [PATCH] git-mv is not able to handle big directories Junio C Hamano
2005-11-23 19:54             ` Ryan Anderson
     [not found]         ` <200511231619.41497.lan@ac-sw.com>
2005-11-23 14:29           ` Randal L. Schwartz
2005-11-23  7:26   ` git-mv is not able to handle directory with one file in it Alexander Litvinov
2005-11-23  7:57     ` Andreas Ericsson
2005-11-23  9:57       ` Alexander Litvinov
2005-11-23 10:21       ` Alexander Litvinov
2005-11-23 11:07         ` Josef Weidendorfer
2005-11-23 14:47     ` Josef Weidendorfer

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).