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

[PATCH] Don't checkout the full tree if avoidable

From
Steven Walter <stevenrwalter@gmail.com>
Date
Sep 28, 2007, 17:24 UTC
Message-ID
<1191000259190-git-send-email-stevenrwalter@gmail.com>

In most cases of branching, the tree is copied unmodified from the trunk to the branch. When that is done, we can simply start with the parent's index and apply the changes on the branch as usual.

Signed-off-by: Steven Walter <stevenrwalter@gmail.com>
---
 git-svn.perl |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 484b057..2ca2042 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1847,6 +1847,13 @@ sub find_parent_branch {
 			$gs->ra->gs_do_switch($r0, $rev, $gs,
 					      $self->full_url, $ed)
 			  or die "SVN connection failed somewhere...\n";
+		} elsif ($self->trees_match($new_url, $r0,
+			                    $self->full_url, $rev)) {
+			$self->tmp_index_do(sub {
+			    command_noisy('read-tree', $parent);
+			});
+			$self->{last_commit} = $parent;
+			# Assume copy with no changes
 		} else {
 			print STDERR "Following parent with do_update\n";
 			$ed = SVN::Git::Fetcher->new($self);
@@ -1859,6 +1866,17 @@ sub find_parent_branch {
 	return undef;
 }
 
+sub trees_match {
+    my ($self, $url1, $rev1, $url2, $rev2) = @_;
+    
+    my $ret=1;
+    open(my $fh, "svn diff $url1\@$rev1 $url2\@$rev2 |");
+    $ret=0 if (<$fh>);
+    close($fh);
+
+    return $ret;
+}
+
 sub do_fetch {
 	my ($self, $paths, $rev) = @_;
 	my $ed;
-- 
1.5.3.1
Next: Junio C Hamano
Message 1 of 5 in “Don't checkout the full tree if avoidable”
  1. Don't checkout the full tree if avoidableSteven Walter, Sep 28, 2007
  2. Junio C HamanoOct 1, 2007
  3. Eric WongOct 1, 2007
  4. Steven WalterOct 1, 2007
  5. Eric WongOct 3, 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.