@matheusbsbs / matheus-bagliano / commits / d8115c5104
Fork 0

git-svn: don't write to the config file from --follow-parent

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>

Eric Wong committed Feb 1, 2007 at 03:30 UTC d8115c5104dbee29433a7f33a3e0d3e1738a581e
2 files changed +12 -10
git-svn.perl
+11 -9
@@ -724,7 +724,7 @@ sub find_existing_remote {
724 }
725
726 sub init_remote_config {
727 - my ($self, $url) = @_;
727 + my ($self, $url, $no_write) = @_;
728 $url =~ s!/+$!!; # strip trailing slash
729 my $r = read_all_remotes();
730 my $existing = find_existing_remote($url, $r);
@@ -769,19 +769,21 @@ sub init_remote_config {
769 die "svn-remote.$xrepo_id.fetch already set to track ",
770 "$xpath:refs/remotes/", $self->refname, "\n";
771 }
772 - command_noisy('config',
773 - "svn-remote.$self->{repo_id}.url", $url);
774 - command_noisy('config', '--add',
775 - "svn-remote.$self->{repo_id}.fetch",
776 - "$self->{path}:".$self->refname);
772 + unless ($no_write) {
773 + command_noisy('config',
774 + "svn-remote.$self->{repo_id}.url", $url);
775 + command_noisy('config', '--add',
776 + "svn-remote.$self->{repo_id}.fetch",
777 + "$self->{path}:".$self->refname);
778 + }
779 $self->{url} = $url;
780 }
781
782 sub init {
781 - my ($class, $url, $path, $repo_id, $ref_id) = @_;
783 + my ($class, $url, $path, $repo_id, $ref_id, $no_write) = @_;
784 my $self = _new($class, $repo_id, $ref_id, $path);
785 if (defined $url) {
784 - $self->init_remote_config($url);
786 + $self->init_remote_config($url, $no_write);
787 }
788 $self;
789 }
@@ -1112,7 +1114,7 @@ sub find_parent_branch {
1114 # just grow a tail if we're not unique enough :x
1115 $ref_id .= '-' while find_ref($ref_id);
1116 print STDERR "Initializing parent: $ref_id\n";
1115 - $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id);
1117 + $gs = Git::SVN->init($new_url, '', $ref_id, $ref_id, 1);
1118 }
1119 my ($r0, $parent) = $gs->find_rev_before($r, 1);
1120 if ($_follow_parent && (!defined $r0 || !defined $parent)) {
t/t9104-git-svn-follow-parent.sh
+1 -1
@@ -34,7 +34,7 @@ test_expect_success 'init and fetch --follow-parent a moved directory' "
34 = \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" &&
35 test \"\`git-cat-file blob refs/remotes/thunk:readme |\
36 sed -n -e '3p'\`\" = goodbye &&
37 - test -n \"\`git-config --get svn-remote.git-svn.fetch \
37 + test -z \"\`git-config --get svn-remote.git-svn.fetch \
38 '^trunk:refs/remotes/thunk@2$'\`\"
39 "
40