Code

git-svn: don't write to the config file from --follow-parent
authorEric Wong <normalperson@yhbt.net>
Thu, 1 Feb 2007 11:30:31 +0000 (03:30 -0800)
committerEric Wong <normalperson@yhbt.net>
Fri, 23 Feb 2007 08:57:11 +0000 (00:57 -0800)
Having 'fetch' entries in the config file created from
--follow-parent is wasteful because it can cause *future* of
invocations to follow revisions we were never interested in
in the first place.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl
t/t9104-git-svn-follow-parent.sh

index 1e3a3c08f11372857c5152d7c20b50df8784a673..a2db73fe00368416fa1b9565f2940f582f00352c 100755 (executable)
@@ -724,7 +724,7 @@ sub find_existing_remote {
 }
 
 sub init_remote_config {
-       my ($self, $url) = @_;
+       my ($self, $url, $no_write) = @_;
        $url =~ s!/+$!!; # strip trailing slash
        my $r = read_all_remotes();
        my $existing = find_existing_remote($url, $r);
@@ -769,19 +769,21 @@ sub init_remote_config {
                die "svn-remote.$xrepo_id.fetch already set to track ",
                    "$xpath:refs/remotes/", $self->refname, "\n";
        }
-       command_noisy('config',
-                     "svn-remote.$self->{repo_id}.url", $url);
-       command_noisy('config', '--add',
-                     "svn-remote.$self->{repo_id}.fetch",
-                     "$self->{path}:".$self->refname);
+       unless ($no_write) {
+               command_noisy('config',
+                             "svn-remote.$self->{repo_id}.url", $url);
+               command_noisy('config', '--add',
+                             "svn-remote.$self->{repo_id}.fetch",
+                             "$self->{path}:".$self->refname);
+       }
        $self->{url} = $url;
 }
 
 sub init {
-       my ($class, $url, $path, $repo_id, $ref_id) = @_;
+       my ($class, $url, $path, $repo_id, $ref_id, $no_write) = @_;
        my $self = _new($class, $repo_id, $ref_id, $path);
        if (defined $url) {
-               $self->init_remote_config($url);
+               $self->init_remote_config($url, $no_write);
        }
        $self;
 }
@@ -1112,7 +1114,7 @@ sub find_parent_branch {
                # just grow a tail if we're not unique enough :x
                $ref_id .= '-' while find_ref($ref_id);
                print STDERR "Initializing parent: $ref_id\n";
-               $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id);
+               $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);
        }
        my ($r0, $parent) = $gs->find_rev_before($r, 1);
        if ($_follow_parent && (!defined $r0 || !defined $parent)) {
index 41b9c19d4568891e1221f0d58abbb986b22a37a0..7c852c1d7f0f2a1f241f6a16024bbe841cefe56f 100755 (executable)
@@ -34,7 +34,7 @@ test_expect_success 'init and fetch --follow-parent a moved directory' "
            = \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" &&
         test \"\`git-cat-file blob refs/remotes/thunk:readme |\
                  sed -n -e '3p'\`\" = goodbye &&
-       test -n \"\`git-config --get svn-remote.git-svn.fetch \
+       test -z \"\`git-config --get svn-remote.git-svn.fetch \
                 '^trunk:refs/remotes/thunk@2$'\`\"
        "