Skip to content

Commit

Permalink
Merge git://git.bogomips.org/git-svn
Browse files Browse the repository at this point in the history
* git://git.bogomips.org/git-svn:
  git-svn: Cache results of running the executable "git config"
  git-svn: Add a svn-remote.<name>.pushurl config key
  • Loading branch information
Junio C Hamano committed Apr 11, 2011
2 parents 2dbae5a + f5549af commit e3fa246
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,16 @@ svn-remote.<name>.rewriteUUID::
where the original UUID is not available via either useSvmProps
or useSvnsyncProps.

svn-remote.<name>.pushurl::

Similar to git's 'remote.<name>.pushurl', this key is designed
to be used in cases where 'url' points to an SVN repository
via a read-only transport, to provide an alternate read/write
transport. It is assumed that both keys point to the same
repository. Unlike 'commiturl', 'pushurl' is a base path. If
either 'commiturl' or 'pushurl' could be used, 'commiturl'
takes precedence.

svn.brokenSymlinkWorkaround::
This disables potentially expensive checks to workaround
broken symlinks checked into SVN by broken clients. Set this
Expand Down
24 changes: 21 additions & 3 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ sub _req_svn {
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
use IPC::Open3;
use Git;
use Memoize; # core since 5.8.0, Jul 2002

BEGIN {
# import functions from Git into our packages, en masse
Expand All @@ -72,6 +73,8 @@ BEGIN
*{"${package}::$_"} = \&{"Git::$_"};
}
}
Memoize::memoize 'Git::config';
Memoize::memoize 'Git::config_bool';
}

my ($SVN);
Expand Down Expand Up @@ -528,7 +531,7 @@ sub cmd_dcommit {
$url = eval { command_oneline('config', '--get',
"svn-remote.$gs->{repo_id}.commiturl") };
if (!$url) {
$url = $gs->full_url
$url = $gs->full_pushurl
}
}

Expand Down Expand Up @@ -676,7 +679,7 @@ sub cmd_branch {
$head ||= 'HEAD';

my (undef, $rev, undef, $gs) = working_head_info($head);
my $src = $gs->full_url;
my $src = $gs->full_pushurl;

my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' };
Expand Down Expand Up @@ -727,7 +730,7 @@ sub cmd_branch {
$url = eval { command_oneline('config', '--get',
"svn-remote.$gs->{repo_id}.commiturl") };
if (!$url) {
$url = $remote->{url};
$url = $remote->{pushurl} || $remote->{url};
}
}
my $dst = join '/', $url, $lft, $branch_name, ($rgt || ());
Expand Down Expand Up @@ -1831,6 +1834,8 @@ sub read_all_remotes {
$r->{$1}->{svm} = {};
} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
$r->{$1}->{url} = $2;
} elsif (m!^(.+)\.pushurl=\s*(.*)\s*$!) {
$r->{$1}->{pushurl} = $2;
} elsif (m!^(.+)\.(branches|tags)=$svn_refspec$!) {
my ($remote, $t, $local_ref, $remote_ref) =
($1, $2, $3, $4);
Expand Down Expand Up @@ -2068,6 +2073,8 @@ sub new {
$self->{url} = command_oneline('config', '--get',
"svn-remote.$repo_id.url") or
die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
$self->{pushurl} = eval { command_oneline('config', '--get',
"svn-remote.$repo_id.pushurl") };
$self->rebuild;
$self;
}
Expand Down Expand Up @@ -2545,6 +2552,15 @@ sub full_url {
$self->{url} . (length $self->{path} ? '/' . $self->{path} : '');
}

sub full_pushurl {
my ($self) = @_;
if ($self->{pushurl}) {
return $self->{pushurl} . (length $self->{path} ? '/' .
$self->{path} : '');
} else {
return $self->full_url;
}
}

sub set_commit_header_env {
my ($log_entry) = @_;
Expand Down Expand Up @@ -3197,6 +3213,8 @@ sub has_no_changes {
Memoize::unmemoize 'check_cherry_pick';
Memoize::unmemoize 'has_no_changes';
}

Memoize::memoize 'Git::SVN::repos_root';
}

END {
Expand Down

0 comments on commit e3fa246

Please sign in to comment.