Skip to content

Commit e3fa246

Browse files
committed
Merge git://git.bogomips.org/git-svn
* 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
2 parents 2dbae5a + f5549af commit e3fa246

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

Documentation/git-svn.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,16 @@ svn-remote.<name>.rewriteUUID::
648648
where the original UUID is not available via either useSvmProps
649649
or useSvnsyncProps.
650650

651+
svn-remote.<name>.pushurl::
652+
653+
Similar to git's 'remote.<name>.pushurl', this key is designed
654+
to be used in cases where 'url' points to an SVN repository
655+
via a read-only transport, to provide an alternate read/write
656+
transport. It is assumed that both keys point to the same
657+
repository. Unlike 'commiturl', 'pushurl' is a base path. If
658+
either 'commiturl' or 'pushurl' could be used, 'commiturl'
659+
takes precedence.
660+
651661
svn.brokenSymlinkWorkaround::
652662
This disables potentially expensive checks to workaround
653663
broken symlinks checked into SVN by broken clients. Set this

git-svn.perl

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ sub _req_svn {
5959
use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
6060
use IPC::Open3;
6161
use Git;
62+
use Memoize; # core since 5.8.0, Jul 2002
6263

6364
BEGIN {
6465
# import functions from Git into our packages, en masse
@@ -72,6 +73,8 @@ BEGIN
7273
*{"${package}::$_"} = \&{"Git::$_"};
7374
}
7475
}
76+
Memoize::memoize 'Git::config';
77+
Memoize::memoize 'Git::config_bool';
7578
}
7679

7780
my ($SVN);
@@ -528,7 +531,7 @@ sub cmd_dcommit {
528531
$url = eval { command_oneline('config', '--get',
529532
"svn-remote.$gs->{repo_id}.commiturl") };
530533
if (!$url) {
531-
$url = $gs->full_url
534+
$url = $gs->full_pushurl
532535
}
533536
}
534537

@@ -676,7 +679,7 @@ sub cmd_branch {
676679
$head ||= 'HEAD';
677680

678681
my (undef, $rev, undef, $gs) = working_head_info($head);
679-
my $src = $gs->full_url;
682+
my $src = $gs->full_pushurl;
680683

681684
my $remote = Git::SVN::read_all_remotes()->{$gs->{repo_id}};
682685
my $allglobs = $remote->{ $_tag ? 'tags' : 'branches' };
@@ -727,7 +730,7 @@ sub cmd_branch {
727730
$url = eval { command_oneline('config', '--get',
728731
"svn-remote.$gs->{repo_id}.commiturl") };
729732
if (!$url) {
730-
$url = $remote->{url};
733+
$url = $remote->{pushurl} || $remote->{url};
731734
}
732735
}
733736
my $dst = join '/', $url, $lft, $branch_name, ($rgt || ());
@@ -1831,6 +1834,8 @@ sub read_all_remotes {
18311834
$r->{$1}->{svm} = {};
18321835
} elsif (m!^(.+)\.url=\s*(.*)\s*$!) {
18331836
$r->{$1}->{url} = $2;
1837+
} elsif (m!^(.+)\.pushurl=\s*(.*)\s*$!) {
1838+
$r->{$1}->{pushurl} = $2;
18341839
} elsif (m!^(.+)\.(branches|tags)=$svn_refspec$!) {
18351840
my ($remote, $t, $local_ref, $remote_ref) =
18361841
($1, $2, $3, $4);
@@ -2068,6 +2073,8 @@ sub new {
20682073
$self->{url} = command_oneline('config', '--get',
20692074
"svn-remote.$repo_id.url") or
20702075
die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
2076+
$self->{pushurl} = eval { command_oneline('config', '--get',
2077+
"svn-remote.$repo_id.pushurl") };
20712078
$self->rebuild;
20722079
$self;
20732080
}
@@ -2545,6 +2552,15 @@ sub full_url {
25452552
$self->{url} . (length $self->{path} ? '/' . $self->{path} : '');
25462553
}
25472554

2555+
sub full_pushurl {
2556+
my ($self) = @_;
2557+
if ($self->{pushurl}) {
2558+
return $self->{pushurl} . (length $self->{path} ? '/' .
2559+
$self->{path} : '');
2560+
} else {
2561+
return $self->full_url;
2562+
}
2563+
}
25482564

25492565
sub set_commit_header_env {
25502566
my ($log_entry) = @_;
@@ -3197,6 +3213,8 @@ sub has_no_changes {
31973213
Memoize::unmemoize 'check_cherry_pick';
31983214
Memoize::unmemoize 'has_no_changes';
31993215
}
3216+
3217+
Memoize::memoize 'Git::SVN::repos_root';
32003218
}
32013219

32023220
END {

0 commit comments

Comments
 (0)