Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 9134a46

Browse files
committed
Merge git://git.bogomips.org/git-svn
* git://git.bogomips.org/git-svn: git-svn: introduce --parents parameter for commands branch and tag git-svn: clarify explanation of --destination argument git-svn: multiple fetch/branches/tags keys are supported
2 parents 5dbe064 + f4f4c7f commit 9134a46

File tree

3 files changed

+97
-6
lines changed

3 files changed

+97
-6
lines changed

Documentation/git-svn.txt

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,15 @@ first have already been pushed into SVN.
271271
Create a tag by using the tags_subdir instead of the branches_subdir
272272
specified during git svn init.
273273

274-
-d;;
275-
--destination;;
274+
-d<path>;;
275+
--destination=<path>;;
276+
276277
If more than one --branches (or --tags) option was given to the 'init'
277278
or 'clone' command, you must provide the location of the branch (or
278-
tag) you wish to create in the SVN repository. The value of this
279-
option must match one of the paths specified by a --branches (or
280-
--tags) option. You can see these paths with the commands
279+
tag) you wish to create in the SVN repository. <path> specifies which
280+
path to use to create the branch or tag and should match the pattern
281+
on the left-hand side of one of the configured branches or tags
282+
refspecs. You can see these refspecs with the commands
281283
+
282284
git config --get-all svn-remote.<name>.branches
283285
git config --get-all svn-remote.<name>.tags
@@ -298,6 +300,11 @@ where <name> is the name of the SVN repository as specified by the -R option to
298300
git config --get-all svn-remote.<name>.commiturl
299301
+
300302

303+
--parents;;
304+
Create parent folders. This parameter is equivalent to the parameter
305+
--parents on svn cp commands and is useful for non-standard repository
306+
layouts.
307+
301308
'tag'::
302309
Create a tag in the SVN repository. This is a shorthand for
303310
'branch -t'.
@@ -1032,6 +1039,25 @@ comma-separated list of names within braces. For example:
10321039
tags = tags/{1.0,2.0}/src:refs/remotes/tags/*
10331040
------------------------------------------------------------------------
10341041

1042+
Multiple fetch, branches, and tags keys are supported:
1043+
1044+
------------------------------------------------------------------------
1045+
[svn-remote "messy-repo"]
1046+
url = http://server.org/svn
1047+
fetch = trunk/project-a:refs/remotes/project-a/trunk
1048+
fetch = branches/demos/june-project-a-demo:refs/remotes/project-a/demos/june-demo
1049+
branches = branches/server/*:refs/remotes/project-a/branches/*
1050+
branches = branches/demos/2011/*:refs/remotes/project-a/2011-demos/*
1051+
tags = tags/server/*:refs/remotes/project-a/tags/*
1052+
------------------------------------------------------------------------
1053+
1054+
Creating a branch in such a configuration requires disambiguating which
1055+
location to use using the -d or --destination flag:
1056+
1057+
------------------------------------------------------------------------
1058+
$ git svn branch -d branches/server release-2-3-0
1059+
------------------------------------------------------------------------
1060+
10351061
Note that git-svn keeps track of the highest revision in which a branch
10361062
or tag has appeared. If the subset of branches or tags is changed after
10371063
fetching, then .git/svn/.metadata must be manually edited to remove (or

git-svn.perl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ sub _req_svn {
113113
$_template, $_shared,
114114
$_version, $_fetch_all, $_no_rebase, $_fetch_parent,
115115
$_before, $_after,
116-
$_merge, $_strategy, $_preserve_merges, $_dry_run, $_local,
116+
$_merge, $_strategy, $_preserve_merges, $_dry_run, $_parents, $_local,
117117
$_prefix, $_no_checkout, $_url, $_verbose,
118118
$_commit_url, $_tag, $_merge_info, $_interactive);
119119

@@ -203,6 +203,7 @@ sub _req_svn {
203203
{ 'message|m=s' => \$_message,
204204
'destination|d=s' => \$_branch_dest,
205205
'dry-run|n' => \$_dry_run,
206+
'parents' => \$_parents,
206207
'tag|t' => \$_tag,
207208
'username=s' => \$Git::SVN::Prompt::_username,
208209
'commit-url=s' => \$_commit_url } ],
@@ -211,6 +212,7 @@ sub _req_svn {
211212
{ 'message|m=s' => \$_message,
212213
'destination|d=s' => \$_branch_dest,
213214
'dry-run|n' => \$_dry_run,
215+
'parents' => \$_parents,
214216
'username=s' => \$Git::SVN::Prompt::_username,
215217
'commit-url=s' => \$_commit_url } ],
216218
'set-tree' => [ \&cmd_set_tree,
@@ -1172,13 +1174,28 @@ sub cmd_branch {
11721174
$ctx->ls($dst, 'HEAD', 0);
11731175
} and die "branch ${branch_name} already exists\n";
11741176

1177+
if ($_parents) {
1178+
mk_parent_dirs($ctx, $dst);
1179+
}
1180+
11751181
print "Copying ${src} at r${rev} to ${dst}...\n";
11761182
$ctx->copy($src, $rev, $dst)
11771183
unless $_dry_run;
11781184

11791185
$gs->fetch_all;
11801186
}
11811187

1188+
sub mk_parent_dirs {
1189+
my ($ctx, $parent) = @_;
1190+
$parent =~ s{/[^/]*$}{};
1191+
1192+
if (!eval{$ctx->ls($parent, 'HEAD', 0)}) {
1193+
mk_parent_dirs($ctx, $parent);
1194+
print "Creating parent folder ${parent} ...\n";
1195+
$ctx->mkdir($parent) unless $_dry_run;
1196+
}
1197+
}
1198+
11821199
sub cmd_find_rev {
11831200
my $revision_or_hash = shift or die "SVN or git revision required ",
11841201
"as a command-line argument\n";
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2013 Tobias Schulte
4+
#
5+
6+
test_description='git svn branch for subproject clones'
7+
. ./lib-git-svn.sh
8+
9+
test_expect_success 'initialize svnrepo' '
10+
mkdir import &&
11+
(
12+
cd import &&
13+
mkdir -p trunk/project branches tags &&
14+
(
15+
cd trunk/project &&
16+
echo foo > foo
17+
) &&
18+
svn_cmd import -m "import for git-svn" . "$svnrepo" >/dev/null
19+
) &&
20+
rm -rf import &&
21+
svn_cmd co "$svnrepo"/trunk/project trunk/project &&
22+
(
23+
cd trunk/project &&
24+
echo bar >> foo &&
25+
svn_cmd ci -m "updated trunk"
26+
) &&
27+
rm -rf trunk
28+
'
29+
30+
test_expect_success 'import into git' '
31+
git svn init --trunk=trunk/project --branches=branches/*/project \
32+
--tags=tags/*/project "$svnrepo" &&
33+
git svn fetch &&
34+
git checkout remotes/trunk
35+
'
36+
37+
test_expect_success 'git svn branch tests' '
38+
test_must_fail git svn branch a &&
39+
git svn branch --parents a &&
40+
test_must_fail git svn branch -t tag1 &&
41+
git svn branch --parents -t tag1 &&
42+
test_must_fail git svn branch --tag tag2 &&
43+
git svn branch --parents --tag tag2 &&
44+
test_must_fail git svn tag tag3 &&
45+
git svn tag --parents tag3
46+
'
47+
48+
test_done

0 commit comments

Comments
 (0)