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

git-svn and branches

From
Steven Walter <stevenrwalter@gmail.com>
Date
Sep 27, 2007, 02:12 UTC
Message-ID
<20070927021252.GA23777@dervierte>

I'm using git-svn to track a rather large subversion repository with a non-standard layout. In the past, I've only cared about trunk, but now I need to occasionally use branches, too. By adding a second git-svn remote with the branch URL, I can fetch the branch, and git-svn is even intelligent enough to notice that the branch was copied off of trunk.

However, git-svn also does a complete checkout for the first revision of the branch. By this, I mean it goes through shows "A file" for every file in the repository. This takes quite a while, and seems rather unnecessary given that git-svn already noticed that the branch shares a history with trunk, which is already fetched.

Knowing just enough of what git-svn is doing to be dangerous, I whipped up a short little patch. This patch seems to work for the common case, and avoids fetching every file from subversion. It does break sometimes, however, and I don't understand why.

Maybe someone with a better grasps of the code can see what I did wrong, or suggest a better means to my end?

diff --git a/git-svn.perl b/git-svn.perl
index 484b057..1bc92b6 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1848,9 +1848,10 @@ sub find_parent_branch {
                                              $self->full_url, $ed)
                          or die "SVN connection failed somewhere...\n";
                } else {
+                       $self->assert_index_clean($parent);
                        print STDERR "Following parent with do_update\n";
                        $ed = SVN::Git::Fetcher->new($self);
-                       $self->ra->gs_do_update($rev, $rev, $self, $ed)
+                       $self->ra->gs_do_update($rev, $r0, $self, $ed)
                          or die "SVN connection failed somewhere...\n";
                }
                print STDERR "Successfully followed parent\n";
-- 
-Steven Walter <stevenrwalter@gmail.com>
"A human being should be able to change a diaper, plan an invasion,
butcher a hog, conn a ship, design a building, write a sonnet, balance
accounts, build a wall, set a bone, comfort the dying, take orders,
give orders, cooperate, act alone, solve equations, analyze a new
problem, pitch manure, program a computer, cook a tasty meal, fight
efficiently, die gallantly. Specialization is for insects."
   -Robert Heinlein
Next: Sam Vilain
Message 1 of 4 in “git-svn and branches”
  1. Steven WalterSep 27, 2007
  2. Sam VilainSep 27, 2007
  3. Eric WongSep 27, 2007
  4. Steven WalterSep 28, 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.