public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Jeff King <peff@peff•net>
To: Martin Langhoff <martin.langhoff@gmail•com>,
	Junio C Hamano <junkio@cox•net>,
	Matthias Urlichs <smurf@smurf•noris.de>,
	git@vger•kernel.org
Subject: [PATCH 1/2] cvsimport: use git-update-index --index-info
Date: Tue, 23 May 2006 03:01:02 -0400	[thread overview]
Message-ID: <20060523070102.GD6180@coredump.intra.peff.net> (raw)
In-Reply-To: <20060523065810.GB6180@coredump.intra.peff.net>

This should reduce the number of git-update-index forks required per
commit. We now do adds/removes in one call, and we are no longer forced to
deal with argv limitations.

---

Oops, apparently using a mail reader is too challenging for me. Here's a
repost with the headers correctly merged.

cb6452bbfda9c52ad8dbeaac6e3440ae61099a05
 git-cvsimport.perl |   36 +++++++++++++-----------------------
 1 files changed, 13 insertions(+), 23 deletions(-)

cb6452bbfda9c52ad8dbeaac6e3440ae61099a05
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index d257e66..4efb0a5 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -565,29 +565,19 @@ my($patchset,$date,$author_name,$author_
 my(@old,@new,@skipped);
 sub commit {
 	my $pid;
-	while(@old) {
-		my @o2;
-		if(@old > 55) {
-			@o2 = splice(@old,0,50);
-		} else {
-			@o2 = @old;
-			@old = ();
-		}
-		system("git-update-index","--force-remove","--",@o2);
-		die "Cannot remove files: $?\n" if $?;
-	}
-	while(@new) {
-		my @n2;
-		if(@new > 12) {
-			@n2 = splice(@new,0,10);
-		} else {
-			@n2 = @new;
-			@new = ();
-		}
-		system("git-update-index","--add",
-			(map { ('--cacheinfo', @$_) } @n2));
-		die "Cannot add files: $?\n" if $?;
-	}
+
+      	open(my $fh, '|-', qw(git-update-index --index-info))
+		or die "unable to open git-update-index: $!";
+	print $fh 
+		(map { "0 0000000000000000000000000000000000000000\t$_\n" }
+			@old),
+		(map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\n" }
+			@new)
+		or die "unable to write to git-update-index: $!";
+	close $fh
+		or die "unable to write to git-update-index: $!";
+	$? and die "git-update-index reported error: $?";
+	@old = @new = ();
 
 	$pid = open(C,"-|");
 	die "Cannot fork: $!" unless defined $pid;
-- 
1.3.3.gcb64-dirty

  reply	other threads:[~2006-05-23  7:01 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-20 17:26 irc usage Linus Torvalds
2006-05-20 17:50 ` Junio C Hamano
2006-05-20 18:52   ` Jakub Narebski
2006-05-20 20:39 ` Yann Dirson
2006-05-20 22:18   ` Donnie Berkholz
2006-05-20 22:45     ` Linus Torvalds
2006-05-20 23:12       ` Donnie Berkholz
2006-05-21 19:24         ` Linus Torvalds
2006-05-22  3:59           ` Linus Torvalds
2006-05-22  4:19             ` Donnie Berkholz
2006-05-22  4:50               ` Linus Torvalds
2006-05-22  5:04                 ` Martin Langhoff
2006-05-22  5:21                 ` Donnie Berkholz
2006-05-22  7:42                 ` Martin Langhoff
2006-05-22  9:13                   ` Linus Torvalds
2006-05-22 12:54                     ` Martin Langhoff
2006-05-22 17:27                       ` Linus Torvalds
2006-05-22 17:51                         ` Jakub Narebski
2006-05-22 18:03                           ` Linus Torvalds
2006-05-22 19:03                             ` Matthias Lederhofer
2006-05-22 19:09                               ` Junio C Hamano
2006-05-23 20:19                             ` Jakub Narebski
2006-05-22 19:46                         ` Martin Langhoff
2006-05-22 19:09                       ` Donnie Berkholz
2006-05-22 19:38                         ` Linus Torvalds
2006-05-22 19:49                           ` Donnie Berkholz
2006-05-22 20:20                             ` Linus Torvalds
2006-05-22 21:48                               ` Donnie Berkholz
2006-05-29 21:54                                 ` Donnie Berkholz
2006-05-29 22:21                                   ` Martin Langhoff
2006-05-29 22:32                                     ` Donnie Berkholz
2006-05-30  0:19                                       ` Martin Langhoff
2006-05-30  5:31                                         ` Donnie Berkholz
2006-05-30  6:01                                           ` Martin Langhoff
2006-05-30  0:43                                       ` Linus Torvalds
2006-05-30 22:31                                       ` Martin Langhoff
2006-05-30 23:07                                         ` Linus Torvalds
2006-05-31  1:04                                           ` Martin Langhoff
2006-05-31  2:49                                             ` Donnie Berkholz
2006-05-31  6:05                                               ` Martin Langhoff
2006-05-31 13:54                                                 ` Alec Warner
2006-05-31 22:03                                                   ` Martin Langhoff
2006-06-01  1:42                                                     ` Alec Warner
2006-06-01  7:47                                                       ` Martin Langhoff
2006-06-05  0:33                                                         ` Alec Warner
2006-06-05  2:06                                                           ` Martin Langhoff
2006-06-05  2:36                                                             ` Alec Warner
2006-06-05  3:49                                                               ` Martin Langhoff
     [not found]                                                               ` <20060605120743.566fb85f.seanlkml@sympatico.ca>
2006-06-05 16:07                                                                 ` Sean
2006-05-22 19:41                         ` Martin Langhoff
2006-05-22 20:11                           ` Linus Torvalds
2006-05-22 20:33                             ` Linus Torvalds
2006-05-22 21:41                             ` Matthias Urlichs
2006-05-22 22:18                               ` Linus Torvalds
2006-05-22 23:23                                 ` Martin Langhoff
2006-05-22 23:29                                   ` Martin Langhoff
2006-05-22 23:33                                   ` Linus Torvalds
2006-05-22 22:39                               ` Junio C Hamano
2006-05-22 23:15                                 ` Martin Langhoff
2006-05-23  6:52                                   ` Jeff King
2006-05-23  6:58                                     ` Jeff King
2006-05-23  7:01                                       ` Jeff King [this message]
2006-05-23  7:00                                     ` [PATCH 2/2] cvsimport: cleanup commit function Jeff King
     [not found]                                       ` <7v4pzh6wtr.fsf@assigned-by-dhcp.cox.net>
2006-05-23  7:13                                         ` Jeff King
2006-05-23  7:27                                       ` [PATCH 1/2] cvsimport: use git-update-index --index-info Jeff King
2006-05-23  8:13                                       ` [PATCH 2/2] cvsimport: cleanup commit function Martin Langhoff
2006-05-23  8:24                                         ` Junio C Hamano
2006-05-23 20:32                                           ` Martin Langhoff
2006-05-23 16:50                                         ` Linus Torvalds
2006-05-23 19:36                                           ` Linus Torvalds
2006-05-23 20:25                                             ` Junio C Hamano
2006-05-23 20:29                                             ` Martin Langhoff
2006-05-23 21:10                                               ` Jeff King
2006-05-23 21:13                                                 ` Martin Langhoff
2006-05-23 17:47                                       ` Morten Welinder
2006-05-23 20:59                                         ` Jeff King
2006-05-23 23:41                                           ` Junio C Hamano
2006-05-24  9:52                                             ` Jeff King
2006-05-22 20:16                         ` irc usage Donnie Berkholz
2006-05-21  9:46       ` Thomas Glanzmann
2006-05-21  1:14     ` Donnie Berkholz
2006-05-22  1:45   ` Linus Torvalds

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=20060523070102.GD6180@coredump.intra.peff.net \
    --to=peff@peff$(echo .)net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=junkio@cox$(echo .)net \
    --cc=martin.langhoff@gmail$(echo .)com \
    --cc=smurf@smurf$(echo .)noris.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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