Skip to content

Commit

Permalink
git-svn: make rebuild respect rewriteRoot option
Browse files Browse the repository at this point in the history
Suppose someone fetches git-svn-ified commits from another repo and then
attempts to use 'git-svn init --rewrite-root=foo bar'. Using git svn rebase
after that will fail badly:

 * For each commit tried by working_head_info, rebuild is called indirectly.
 * rebuild will iterate over all commits and skip all of them because the
   URL does not match. Because of that no rev_map file is generated at all.
 * Thus, rebuild will run once for every commit. This takes ages.
 * In the end there still isn't any rev_map file and thus working_head_info
   fails.

Addressing this behaviour fixes an apparently not too uncommon problem with
providing git-svn mirrors of Subversion repositories. Some repositories are
accessed using different URLs depending on whether the user has push
privileges or not. In the latter case, an anonymous URL is often used that
differs from the push URL. Providing a mirror that is usable in both cases
becomes a lot more possible with this change.

Signed-off-by: Jan Krüger <jk@jk.gs>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
jast authored and gitster committed Jun 24, 2008
1 parent 6ff6af6 commit 74b1e12
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
6 changes: 3 additions & 3 deletions git-svn.perl
Expand Up @@ -2577,8 +2577,8 @@ sub rebuild {
my ($log, $ctx) =
command_output_pipe(qw/rev-list --pretty=raw --no-color --reverse/,
$self->refname, '--');
my $full_url = $self->full_url;
remove_username($full_url);
my $metadata_url = $self->metadata_url;
remove_username($metadata_url);
my $svn_uuid = $self->ra_uuid;
my $c;
while (<$log>) {
Expand All @@ -2596,7 +2596,7 @@ sub rebuild {
# if we merged or otherwise started elsewhere, this is
# how we break out of it
if (($uuid ne $svn_uuid) ||
($full_url && $url && ($url ne $full_url))) {
($metadata_url && $url && ($url ne $metadata_url))) {
next;
}

Expand Down
32 changes: 32 additions & 0 deletions t/t9123-git-svn-rebuild-with-rewriteroot.sh
@@ -0,0 +1,32 @@
#!/bin/sh
#
# Copyright (c) 2008 Jan Krüger
#

test_description='git-svn respects rewriteRoot during rebuild'

. ./lib-git-svn.sh

mkdir import
cd import
touch foo
svn import -m 'import for git-svn' . "$svnrepo" >/dev/null
cd ..
rm -rf import

test_expect_success 'init, fetch and checkout repository' '
git svn init --rewrite-root=http://invalid.invalid/ "$svnrepo" &&
git svn fetch
git checkout -b mybranch remotes/git-svn
'

test_expect_success 'remove rev_map' '
rm "$GIT_SVN_DIR"/.rev_map.*
'

test_expect_success 'rebuild rev_map' '
git svn rebase >/dev/null
'

test_done

0 comments on commit 74b1e12

Please sign in to comment.