@matheusbsbs / matheus-bagliano / commits / 4a1bb4c3f8
Fork 0

git-svn: don't attempt to minimize URLs by default

For tracking branches and tags, git-svn prefers to connect to the root of the repository or at least the level that houses branches and tags as well as trunk. However, users that are accustomed to tracking a single directory have no use for this feature. As pointed out by Junio, users may not have permissions to connect to connect to a higher-level path in the repository. While the current minimize_url() function detects lack of permissions to certain paths _after_ successful logins, it cannot effectively determine if it is trying to access a login-only portion of a repo when the user expects to connect to a part where anonymous access is allowed. For people used to the git-svnimport switches of --trunk, --tags, --branches, they'll already pass the repository root (or root+subdirectory), so minimize URL isn't of too much use to them, either. For people *not* used to git-svnimport, git-svn also supports: git svn init --minimize-url \ --trunk http://repository-root/foo/trunk \ --branches http://repository-root/foo/branches \ --tags http://repository-root/foo/tags And this is where the new --minimize-url command-line switch comes in to allow for this behavior to continue working.

Eric Wong committed May 13, 2007 at 09:58 UTC 4a1bb4c3f87f355dd52fcd0babcbd005d59d7ed6
6 files changed +19 -16
git-svn.perl
+3 -2
@@ -80,6 +80,7 @@ my %icv;
80 my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared,
81 'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags,
82 'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix,
83 + 'minimize-url|m' => \$Git::SVN::_minimize_url,
84 'no-metadata' => sub { $icv{noMetadata} = 1 },
85 'use-svm-props' => sub { $icv{useSvmProps} = 1 },
86 'use-svnsync-props' => sub { $icv{useSvnsyncProps} = 1 },
@@ -820,7 +821,7 @@ use strict;
821 use warnings;
822 use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent
823 $_repack $_repack_flags $_use_svm_props $_head
823 - $_use_svnsync_props $no_reuse_existing/;
824 + $_use_svnsync_props $no_reuse_existing $_minimize_url/;
825 use Carp qw/croak/;
826 use File::Path qw/mkpath/;
827 use File::Copy qw/copy/;
@@ -1037,7 +1038,7 @@ sub init_remote_config {
1038 "[svn-remote \"$existing\"]\n";
1039 }
1040 $self->{repo_id} = $existing;
1040 - } else {
1041 + } elsif ($_minimize_url) {
1042 my $min_url = Git::SVN::Ra->new($url)->minimize_url;
1043 $existing = find_existing_remote($min_url, $r);
1044 if ($existing) {
t/t9100-git-svn-basic.sh
+1 -1
@@ -229,7 +229,7 @@ test_expect_failure 'exit if init-ing a would clobber a URL' "
229
230 test_expect_success \
231 'init allows us to connect to another directory in the same repo' "
232 - git-svn init -i bar $svnrepo/bar &&
232 + git-svn init --minimize-url -i bar $svnrepo/bar &&
233 git config --get svn-remote.svn.fetch \
234 '^bar:refs/remotes/bar$' &&
235 git config --get svn-remote.svn.fetch \
t/t9104-git-svn-follow-parent.sh
+7 -6
@@ -28,7 +28,7 @@ test_expect_success 'initialize repo' "
28 "
29
30 test_expect_success 'init and fetch a moved directory' "
31 - git-svn init -i thunk $svnrepo/thunk &&
31 + git-svn init --minimize-url -i thunk $svnrepo/thunk &&
32 git-svn fetch -i thunk &&
33 test \"\`git-rev-parse --verify refs/remotes/thunk@2\`\" \
34 = \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" &&
@@ -68,7 +68,8 @@ test_expect_success 'follow larger parent' "
68 echo hi > import/trunk/thunk/bump/thud/file &&
69 svn import -m 'import a larger parent' import $svnrepo/larger-parent &&
70 svn cp -m 'hi' $svnrepo/larger-parent $svnrepo/another-larger &&
71 - git-svn init -i larger $svnrepo/another-larger/trunk/thunk/bump/thud &&
71 + git-svn init --minimize-url -i larger \
72 + $svnrepo/another-larger/trunk/thunk/bump/thud &&
73 git-svn fetch -i larger &&
74 git-rev-parse --verify refs/remotes/larger &&
75 git-rev-parse --verify \
@@ -90,14 +91,14 @@ test_expect_success 'follow higher-level parent' "
91 cd ..
92 svn mkdir -m 'new glob at top level' $svnrepo/glob &&
93 svn mv -m 'move blob down a level' $svnrepo/blob $svnrepo/glob/blob &&
93 - git-svn init -i blob $svnrepo/glob/blob &&
94 + git-svn init --minimize-url -i blob $svnrepo/glob/blob &&
95 git-svn fetch -i blob
96 "
97
98 test_expect_success 'follow deleted directory' "
99 svn mv -m 'bye!' $svnrepo/glob/blob/hi $svnrepo/glob/blob/bye &&
100 svn rm -m 'remove glob' $svnrepo/glob &&
100 - git-svn init -i glob $svnrepo/glob &&
101 + git-svn init --minimize-url -i glob $svnrepo/glob &&
102 git-svn fetch -i glob &&
103 test \"\`git cat-file blob refs/remotes/glob:blob/bye\`\" = hi &&
104 test \"\`git ls-tree refs/remotes/glob | wc -l \`\" -eq 1
@@ -127,7 +128,7 @@ test_expect_success 'follow-parent avoids deleting relevant info' "
128 poke native/t/c.t &&
129 svn commit -m 'reorg test' &&
130 cd .. &&
130 - git-svn init -i r9270-t \
131 + git-svn init --minimize-url -i r9270-t \
132 $svnrepo/r9270/trunk/subversion/bindings/swig/perl/native/t &&
133 git-svn fetch -i r9270-t &&
134 test \`git rev-list r9270-t | wc -l\` -eq 2 &&
@@ -137,7 +138,7 @@ test_expect_success 'follow-parent avoids deleting relevant info' "
138
139 test_expect_success "track initial change if it was only made to parent" "
140 svn cp -m 'wheee!' $svnrepo/r9270/trunk $svnrepo/r9270/drunk &&
140 - git-svn init -i r9270-d \
141 + git-svn init --minimize-url -i r9270-d \
142 $svnrepo/r9270/drunk/subversion/bindings/swig/perl/native/t &&
143 git-svn fetch -i r9270-d &&
144 test \`git rev-list r9270-d | wc -l\` -eq 3 &&
t/t9105-git-svn-commit-diff.sh
+1 -1
@@ -33,7 +33,7 @@ test_expect_success 'test the commit-diff command' "
33
34 test_expect_success 'commit-diff to a sub-directory (with git-svn config)' "
35 svn import -m 'sub-directory' import $svnrepo/subdir &&
36 - git-svn init $svnrepo/subdir &&
36 + git-svn init --minimize-url $svnrepo/subdir &&
37 git-svn fetch &&
38 git-svn commit-diff -r3 '$prev' '$head' &&
39 svn cat $svnrepo/subdir/readme > readme.2 &&
t/t9110-git-svn-use-svm-props.sh
+4 -3
@@ -9,9 +9,10 @@ test_description='git-svn useSvmProps test'
9
10 test_expect_success 'load svm repo' "
11 svnadmin load -q $rawsvnrepo < ../t9110/svm.dump &&
12 - git-svn init -R arr -i bar $svnrepo/mirror/arr &&
13 - git-svn init -R argh -i dir $svnrepo/mirror/argh &&
14 - git-svn init -R argh -i e $svnrepo/mirror/argh/a/b/c/d/e &&
12 + git-svn init --minimize-url -R arr -i bar $svnrepo/mirror/arr &&
13 + git-svn init --minimize-url -R argh -i dir $svnrepo/mirror/argh &&
14 + git-svn init --minimize-url -R argh -i e \
15 + $svnrepo/mirror/argh/a/b/c/d/e &&
16 git-config svn.useSvmProps true &&
17 git-svn fetch --all
18 "
t/t9111-git-svn-use-svnsync-props.sh
+3 -3
@@ -9,9 +9,9 @@ test_description='git-svn useSvnsyncProps test'
9
10 test_expect_success 'load svnsync repo' "
11 svnadmin load -q $rawsvnrepo < ../t9111/svnsync.dump &&
12 - git-svn init -R arr -i bar $svnrepo/bar &&
13 - git-svn init -R argh -i dir $svnrepo/dir &&
14 - git-svn init -R argh -i e $svnrepo/dir/a/b/c/d/e &&
12 + git-svn init --minimize-url -R arr -i bar $svnrepo/bar &&
13 + git-svn init --minimize-url -R argh -i dir $svnrepo/dir &&
14 + git-svn init --minimize-url -R argh -i e $svnrepo/dir/a/b/c/d/e &&
15 git-config svn.useSvnsyncProps true &&
16 git-svn fetch --all
17 "