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

[PATCH 3/13] git-svn: optimize --branch and --branch-all-ref

From
EWEric Wong <normalperson@yhbt.net>
Date
Jun 13, 2006, 18:02 UTC
Message-ID
<11502217393714-git-send-email-normalperson@yhbt.net>
In-Reply-To
<11502217352245-git-send-email-normalperson@yhbt.net>
By breaking the pipe read once we've seen a commit twice.

This should make -B/--branch-all-ref faster and usable on a frequent basis.

We use topological order now for calling git-rev-list, and any commit we've seen before should imply that all parents have been seen (at least I hope that's the case for --topo-order).

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 contrib/git-svn/git-svn.perl |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index c91160d..d4b9323 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -1220,23 +1220,30 @@ sub check_upgrade_needed {
 # fills %tree_map with a reverse mapping of trees to commits.  Useful
 # for finding parents to commit on.
 sub map_tree_joins {
+	my %seen;
 	foreach my $br (@_branch_from) {
 		my $pid = open my $pipe, '-|';
 		defined $pid or croak $!;
 		if ($pid == 0) {
-			exec(qw(git-rev-list --pretty=raw), $br) or croak $?;
+			exec(qw(git-rev-list --topo-order --pretty=raw), $br)
+								or croak $?;
 		}
 		while (<$pipe>) {
 			if (/^commit ($sha1)$/o) {
 				my $commit = $1;
+
+				# if we've seen a commit,
+				# we've seen its parents
+				last if $seen{$commit};
 				my ($tree) = (<$pipe> =~ /^tree ($sha1)$/o);
 				unless (defined $tree) {
 					die "Failed to parse commit $commit\n";
 				}
 				push @{$tree_map{$tree}}, $commit;
+				$seen{$commit} = 1;
 			}
 		}
-		close $pipe or croak $?;
+		close $pipe; # we could be breaking the pipe early
 	}
 }
 
-- 
1.4.0
Previous: Eric WongNext: Eric Wong
Message 4 of 14 in “git-svn: better branch support, SVN:: lib usage, feature additions”
  1. 0/13 git-svn: better branch support, SVN:: lib usage, feature additionsEric Wong, Jun 13, 2006
  2. 1/13 git-svn: support -C<num> passing to git-diff-treeEric Wong, Jun 13, 2006
  3. 2/13 git-svn: --branch-all-refs / -B supportEric Wong, Jun 13, 2006
  4. 3/13 git-svn: optimize --branch and --branch-all-refEric Wong, Jun 13, 2006
  5. 4/13 git-svn: support manually placed initial trees from fetchEric Wong, Jun 13, 2006
  6. 5/13 git-svn: Move all git-svn-related paths into $GIT_DIR/svnEric Wong, Jun 13, 2006
  7. 6/13 git-svn: minor cleanups, extra error-checkingEric Wong, Jun 13, 2006
  8. 7/13 git-svn: add --repack and --repack-flags= optionsEric Wong, Jun 13, 2006
  9. 8/13 git-svn: add --shared and --template= options to pass to init-dbEric Wong, Jun 13, 2006
  10. 9/13 git-svn: add some functionality to better support branches in svnEric Wong, Jun 13, 2006
  11. 10/13 git-svn: add UTF-8 message testEric Wong, Jun 13, 2006
  12. 11/13 git-svn: add 'log' command, a facsimile of basic `svn log'Eric Wong, Jun 13, 2006
  13. 12/13 git-svn: add support for Perl SVN::* librariesEric Wong, Jun 13, 2006
  14. 13/13 git-svn: make the $GIT_DIR/svn/*/revs directory obsoleteEric Wong, Jun 13, 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.