* [PATCH] Allow fancy globs in git-svn init branches
@ 2012-09-17 23:46 Ammon Riley
2012-09-18 20:46 ` Eric Wong
0 siblings, 1 reply; 4+ messages in thread
From: Ammon Riley @ 2012-09-17 23:46 UTC (permalink / raw)
To: git; +Cc: normalperson, marcin, schwern, Ammon Riley
Branches passed to 'git-svn init' via the -b/--branches flag
automatically had a /* appended to them. When the branch contained
a fancy glob with a {} pattern, this is incorrect behaviour, and
leads to odd branches being created in the git repository.
Signed-off-by: Ammon Riley <ammon.riley@gmail.com>
---
git-svn.perl | 2 +-
t/t9141-git-svn-multiple-branches.sh | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/git-svn.perl b/git-svn.perl
index 0d77ffb..f8e8558 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1678,7 +1678,7 @@ sub complete_url_ls_init {
my $remote_path = join_paths( $gs->path, $repo_path );
$remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;
$remote_path =~ s#^/##g;
- $remote_path .= "/*" if $remote_path !~ /\*/;
+ $remote_path .= "/*" if $remote_path !~ m#\*|\{[^/]+\}#;
my ($n) = ($switch =~ /^--(\w+)/);
if (length $pfx && $pfx !~ m#/$#) {
die "--prefix='$pfx' must have a trailing slash '/'\n";
diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh
index 3cd0671..1b872a9 100755
--- a/t/t9141-git-svn-multiple-branches.sh
+++ b/t/t9141-git-svn-multiple-branches.sh
@@ -119,4 +119,16 @@ test_expect_success 'create new branches and tags' '
svn_cmd up && test -e tags_B/Tag2/a.file )
'
+test_expect_success 'clone multiple branch paths using fancy glob' '
+ git svn clone -T trunk \
+ -b b_one/{first} --branches b_two \
+ "$svnrepo/project" git_project2 &&
+ ( cd git_project2 &&
+ git rev-parse refs/remotes/first &&
+ test_must_fail git rev-parse refs/remotes/second &&
+ git rev-parse refs/remotes/1 &&
+ git rev-parse refs/remotes/2
+ )
+'
+
test_done
--
1.7.12.465.gb319926
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow fancy globs in git-svn init branches
2012-09-17 23:46 [PATCH] Allow fancy globs in git-svn init branches Ammon Riley
@ 2012-09-18 20:46 ` Eric Wong
2012-09-18 22:56 ` Ammon Riley
0 siblings, 1 reply; 4+ messages in thread
From: Eric Wong @ 2012-09-18 20:46 UTC (permalink / raw)
To: Ammon Riley; +Cc: git, marcin, schwern
Ammon Riley <ammon.riley@gmail.com> wrote:
> Branches passed to 'git-svn init' via the -b/--branches flag
> automatically had a /* appended to them. When the branch contained
> a fancy glob with a {} pattern, this is incorrect behaviour, and
> leads to odd branches being created in the git repository.
>
> Signed-off-by: Ammon Riley <ammon.riley@gmail.com>
> ---
> git-svn.perl | 2 +-
> t/t9141-git-svn-multiple-branches.sh | 12 ++++++++++++
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/git-svn.perl b/git-svn.perl
> index 0d77ffb..f8e8558 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -1678,7 +1678,7 @@ sub complete_url_ls_init {
> my $remote_path = join_paths( $gs->path, $repo_path );
> $remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;
> $remote_path =~ s#^/##g;
> - $remote_path .= "/*" if $remote_path !~ /\*/;
> + $remote_path .= "/*" if $remote_path !~ m#\*|\{[^/]+\}#;
> my ($n) = ($switch =~ /^--(\w+)/);
> if (length $pfx && $pfx !~ m#/$#) {
> die "--prefix='$pfx' must have a trailing slash '/'\n";
> diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh
> index 3cd0671..1b872a9 100755
> --- a/t/t9141-git-svn-multiple-branches.sh
> +++ b/t/t9141-git-svn-multiple-branches.sh
> @@ -119,4 +119,16 @@ test_expect_success 'create new branches and tags' '
> svn_cmd up && test -e tags_B/Tag2/a.file )
> '
>
> +test_expect_success 'clone multiple branch paths using fancy glob' '
> + git svn clone -T trunk \
> + -b b_one/{first} --branches b_two \
I'm concerned encouraging this can cause confusion on the command-line
for bash users.
In bash, "b_one/{first}" will be passed as-is (and hardly anybody
will have a repo with '{word}' in the path)
However, unless quoted on the command-line, a likely case of:
"b_one/{first,second}" will expand to: "b_one/first" "b_one/second"
...which causes "b_one/second" to be interpreted as the destination
directory. A knowledgeable bash user can avoid this by using:
-b=b_one/{first,second} to avoid this situation.
But with the above invocation, no explicit support is needed
for command-line parsing in git-svn.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow fancy globs in git-svn init branches
2012-09-18 20:46 ` Eric Wong
@ 2012-09-18 22:56 ` Ammon Riley
2012-09-19 1:52 ` Eric Wong
0 siblings, 1 reply; 4+ messages in thread
From: Ammon Riley @ 2012-09-18 22:56 UTC (permalink / raw)
To: Eric Wong; +Cc: git, marcin, schwern
On Tue, Sep 18, 2012 at 1:46 PM, Eric Wong <normalperson@yhbt.net> wrote:
> Ammon Riley <ammon.riley@gmail.com> wrote:
>> Branches passed to 'git-svn init' via the -b/--branches flag
>> automatically had a /* appended to them. When the branch contained
>> a fancy glob with a {} pattern, this is incorrect behaviour, and
>> leads to odd branches being created in the git repository.
>>
>> Signed-off-by: Ammon Riley <ammon.riley@gmail.com>
>> ---
>> git-svn.perl | 2 +-
>> t/t9141-git-svn-multiple-branches.sh | 12 ++++++++++++
>> 2 files changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/git-svn.perl b/git-svn.perl
>> index 0d77ffb..f8e8558 100755
>> --- a/git-svn.perl
>> +++ b/git-svn.perl
>> @@ -1678,7 +1678,7 @@ sub complete_url_ls_init {
>> my $remote_path = join_paths( $gs->path, $repo_path );
>> $remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;
>> $remote_path =~ s#^/##g;
>> - $remote_path .= "/*" if $remote_path !~ /\*/;
>> + $remote_path .= "/*" if $remote_path !~ m#\*|\{[^/]+\}#;
>> my ($n) = ($switch =~ /^--(\w+)/);
>> if (length $pfx && $pfx !~ m#/$#) {
>> die "--prefix='$pfx' must have a trailing slash '/'\n";
>> diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh
>> index 3cd0671..1b872a9 100755
>> --- a/t/t9141-git-svn-multiple-branches.sh
>> +++ b/t/t9141-git-svn-multiple-branches.sh
>> @@ -119,4 +119,16 @@ test_expect_success 'create new branches and tags' '
>> svn_cmd up && test -e tags_B/Tag2/a.file )
>> '
>>
>> +test_expect_success 'clone multiple branch paths using fancy glob' '
>> + git svn clone -T trunk \
>> + -b b_one/{first} --branches b_two \
>
> I'm concerned encouraging this can cause confusion on the command-line
> for bash users.
>
> In bash, "b_one/{first}" will be passed as-is (and hardly anybody
> will have a repo with '{word}' in the path)
>
> However, unless quoted on the command-line, a likely case of:
> "b_one/{first,second}" will expand to: "b_one/first" "b_one/second"
>
> ...which causes "b_one/second" to be interpreted as the destination
> directory. A knowledgeable bash user can avoid this by using:
> -b=b_one/{first,second} to avoid this situation.
>
> But with the above invocation, no explicit support is needed
> for command-line parsing in git-svn.
I confess that I'd completely forgot about the {} expansion in bash.
Perhaps a note in the CAVEATS section of the documentation would
be sufficient?
As a bit of background on the reason for this patch, the branches
in our repository are set up under svnroot as:
<project>/releases/<branchName>/<branchName>/
I have no idea why. So I end up with an init line like so:
git svn init -T trunk -b 'releases/release_7_0/{release_7_0}' \
-b 'releases/release_7_1/{release_7_1}' \
http://server/svnroot/myProj
This, unfortunately, prevents me from using the shorter {A,B}
notation, so I didn't test that.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Allow fancy globs in git-svn init branches
2012-09-18 22:56 ` Ammon Riley
@ 2012-09-19 1:52 ` Eric Wong
0 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2012-09-19 1:52 UTC (permalink / raw)
To: Ammon Riley; +Cc: git, marcin, schwern
Ammon Riley <ammon.riley@gmail.com> wrote:
> I confess that I'd completely forgot about the {} expansion in bash.
> Perhaps a note in the CAVEATS section of the documentation would
> be sufficient?
I think so, yes. Can you send a patch for that instead? Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-19 1:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-17 23:46 [PATCH] Allow fancy globs in git-svn init branches Ammon Riley
2012-09-18 20:46 ` Eric Wong
2012-09-18 22:56 ` Ammon Riley
2012-09-19 1:52 ` Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).