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

[PATCH] git-mv is not able to handle big directories

From
ALAlexander Litvinov <lan@ac-sw.com>
Date
Nov 23, 2005, 05:41 UTC
Message-ID
<200511231141.57683.lan@ac-sw.com>
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.

--- 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;
+}
Next: Junio C Hamano
Message 1 of 23 in “git-mv is not able to handle big directories”
  1. git-mv is not able to handle big directoriesAlexander Litvinov, Nov 23, 2005
  2. Junio C HamanoNov 23, 2005
  3. Junio C HamanoNov 23, 2005
  4. Randal L. SchwartzNov 23, 2005
  5. Junio C HamanoNov 23, 2005
  6. Ryan AndersonNov 23, 2005
  7. Perl version support (was Re: [PATCH] git-mv is not able to handle big directories)Randal L. Schwartz, Nov 23, 2005
  8. Junio C HamanoNov 23, 2005
  9. Randal L. SchwartzNov 23, 2005
  10. H. Peter AnvinNov 23, 2005
  11. Randal L. SchwartzNov 23, 2005
  12. Morten WelinderNov 23, 2005
  13. Ryan AndersonNov 28, 2005
  14. Andreas EricssonNov 28, 2005
  15. Junio C HamanoNov 23, 2005
  16. Ryan AndersonNov 23, 2005
  17. Alexander LitvinovNov 23, 2005
  18. Andreas EricssonNov 23, 2005
  19. Alexander LitvinovNov 23, 2005
  20. Alexander LitvinovNov 23, 2005
  21. Josef WeidendorferNov 23, 2005
  22. Josef WeidendorferNov 23, 2005
  23. Randal L. SchwartzNov 23, 2005

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.