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

[PATCH] git-svn: use git-log rather than rev-list | xargs cat-file

From
Sam Vilain <sam@vilain.net>
Date
Jun 10, 2007, 09:00 UTC
Message-ID
<20070610091259.48F8D13A4F8@magnus.utsl.gen.nz>
This saves a bit of time when rebuilding the git-svn index.
Signed-off-by: Sam Vilain <sam@vilain.net>
---
 git-svn.perl |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index e350061..610563c 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -802,10 +802,15 @@ sub cmt_metadata {
 
 sub working_head_info {
 	my ($head, $refs) = @_;
-	my ($fh, $ctx) = command_output_pipe('rev-list', $head);
-	while (my $hash = <$fh>) {
-		chomp($hash);
-		my ($url, $rev, $uuid) = cmt_metadata($hash);
+	my ($fh, $ctx) = command_output_pipe('log', $head);
+	my $hash;
+	while (<$fh>) {
+		if ( m{^commit ($::sha1)$} ) {
+			$hash = $1;
+			next;
+		}
+		next unless s{^\s+(git-svn-id:)}{$1};
+		my ($url, $rev, $uuid) = extract_metadata($_);
 		if (defined $url && defined $rev) {
 			if (my $gs = Git::SVN->find_by_url($url)) {
 				my $c = $gs->rev_db_get($rev);
@@ -1964,16 +1969,19 @@ sub rebuild {
 		return;
 	}
 	print "Rebuilding $db_path ...\n";
-	my ($rev_list, $ctx) = command_output_pipe("rev-list", $self->refname);
+	my ($log, $ctx) = command_output_pipe("log", $self->refname);
 	my $latest;
 	my $full_url = $self->full_url;
 	remove_username($full_url);
 	my $svn_uuid;
-	while (<$rev_list>) {
-		chomp;
-		my $c = $_;
-		die "Non-SHA1: $c\n" unless $c =~ /^$::sha1$/o;
-		my ($url, $rev, $uuid) = ::cmt_metadata($c);
+	my $c;
+	while (<$log>) {
+		if ( m{^commit ($::sha1)$} ) {
+			$c = $1;
+			next;
+		}
+		next unless s{^\s*(git-svn-id:)}{$1};
+		my ($url, $rev, $uuid) = ::extract_metadata($_);
 		remove_username($url);
 
 		# ignore merges (from set-tree)
@@ -1991,7 +1999,7 @@ sub rebuild {
 		$self->rev_db_set($rev, $c);
 		print "r$rev = $c\n";
 	}
-	command_close_pipe($rev_list, $ctx);
+	command_close_pipe($log, $ctx);
 	print "Done rebuilding $db_path\n";
 }
 
-- 
1.5.0.4.210.gf8a7c-dirty
Next: Eric Wong
Message 1 of 5 in “git-svn: use git-log rather than rev-list | xargs cat-file”
  1. git-svn: use git-log rather than rev-list | xargs cat-fileSam Vilain, Jun 10, 2007
  2. Eric WongJun 10, 2007
  3. Junio C HamanoJun 11, 2007
  4. Extend --pretty=oneline to cover the first paragraph, so that an ugly commit message like this can be handled sanely.Junio C Hamano, Jun 12, 2007
  5. Eric WongJun 12, 2007

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.