{"thread":{"id":"31576","subject":"[PATCH] Allow fancy globs in git-svn init branches","startedAt":"2012-09-17T23:46:38Z","lastAt":"2012-09-19T01:52:38Z","messageCount":4,"participants":["Ammon Riley","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"199307","messageId":"1347925598-23907-1-git-send-email-ammon.riley@gmail.com","threadId":"31576","inReplyTo":null,"subject":"[PATCH] Allow fancy globs in git-svn init branches","fromName":"Ammon Riley","fromEmail":"ammon.riley@gmail.com","sentAt":"2012-09-17T23:46:38Z","receivedAt":"2012-09-17T23:46:38Z","isPatch":true,"sender":{"key":"ammon.riley@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1801261?v=4"},"body":"Branches passed to 'git-svn init' via the -b/--branches flag\nautomatically had a /* appended to them.  When the branch contained\na fancy glob with a {} pattern, this is incorrect behaviour, and\nleads to odd branches being created in the git repository.\n\nSigned-off-by: Ammon Riley <ammon.riley@gmail.com>\n---\n git-svn.perl                         |  2 +-\n t/t9141-git-svn-multiple-branches.sh | 12 ++++++++++++\n 2 files changed, 13 insertions(+), 1 deletion(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 0d77ffb..f8e8558 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1678,7 +1678,7 @@ sub complete_url_ls_init {\n \tmy $remote_path = join_paths( $gs->path, $repo_path );\n \t$remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;\n \t$remote_path =~ s#^/##g;\n-\t$remote_path .= \"/*\" if $remote_path !~ /\\*/;\n+\t$remote_path .= \"/*\" if $remote_path !~ m#\\*|\\{[^/]+\\}#;\n \tmy ($n) = ($switch =~ /^--(\\w+)/);\n \tif (length $pfx && $pfx !~ m#/$#) {\n \t\tdie \"--prefix='$pfx' must have a trailing slash '/'\\n\";\ndiff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh\nindex 3cd0671..1b872a9 100755\n--- a/t/t9141-git-svn-multiple-branches.sh\n+++ b/t/t9141-git-svn-multiple-branches.sh\n@@ -119,4 +119,16 @@ test_expect_success 'create new branches and tags' '\n \t\tsvn_cmd up && test -e tags_B/Tag2/a.file )\n '\n \n+test_expect_success 'clone multiple branch paths using fancy glob' '\n+\tgit svn clone -T trunk \\\n+\t\t      -b b_one/{first} --branches b_two \\\n+\t\t      \"$svnrepo/project\" git_project2 &&\n+\t( cd git_project2 &&\n+\t\tgit rev-parse refs/remotes/first &&\n+\t\ttest_must_fail git rev-parse refs/remotes/second &&\n+\t\tgit rev-parse refs/remotes/1 &&\n+\t\tgit rev-parse refs/remotes/2\n+\t)\n+'\n+\n test_done\n-- \n1.7.12.465.gb319926\n"},{"id":"199408","messageId":"20120918204654.GA22856@dcvr.yhbt.net","threadId":"31576","inReplyTo":"1347925598-23907-1-git-send-email-ammon.riley@gmail.com","subject":"Re: [PATCH] Allow fancy globs in git-svn init branches","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2012-09-18T20:46:54Z","receivedAt":"2012-09-18T20:46:54Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Ammon Riley <ammon.riley@gmail.com> wrote:\n> Branches passed to 'git-svn init' via the -b/--branches flag\n> automatically had a /* appended to them.  When the branch contained\n> a fancy glob with a {} pattern, this is incorrect behaviour, and\n> leads to odd branches being created in the git repository.\n> \n> Signed-off-by: Ammon Riley <ammon.riley@gmail.com>\n> ---\n>  git-svn.perl                         |  2 +-\n>  t/t9141-git-svn-multiple-branches.sh | 12 ++++++++++++\n>  2 files changed, 13 insertions(+), 1 deletion(-)\n> \n> diff --git a/git-svn.perl b/git-svn.perl\n> index 0d77ffb..f8e8558 100755\n> --- a/git-svn.perl\n> +++ b/git-svn.perl\n> @@ -1678,7 +1678,7 @@ sub complete_url_ls_init {\n>  \tmy $remote_path = join_paths( $gs->path, $repo_path );\n>  \t$remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;\n>  \t$remote_path =~ s#^/##g;\n> -\t$remote_path .= \"/*\" if $remote_path !~ /\\*/;\n> +\t$remote_path .= \"/*\" if $remote_path !~ m#\\*|\\{[^/]+\\}#;\n>  \tmy ($n) = ($switch =~ /^--(\\w+)/);\n>  \tif (length $pfx && $pfx !~ m#/$#) {\n>  \t\tdie \"--prefix='$pfx' must have a trailing slash '/'\\n\";\n> diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh\n> index 3cd0671..1b872a9 100755\n> --- a/t/t9141-git-svn-multiple-branches.sh\n> +++ b/t/t9141-git-svn-multiple-branches.sh\n> @@ -119,4 +119,16 @@ test_expect_success 'create new branches and tags' '\n>  \t\tsvn_cmd up && test -e tags_B/Tag2/a.file )\n>  '\n>  \n> +test_expect_success 'clone multiple branch paths using fancy glob' '\n> +\tgit svn clone -T trunk \\\n> +\t\t      -b b_one/{first} --branches b_two \\\n\nI'm concerned encouraging this can cause confusion on the command-line\nfor bash users.\n\nIn bash, \"b_one/{first}\" will be passed as-is (and hardly anybody\nwill have a repo with '{word}' in the path)\n\nHowever, unless quoted on the command-line, a likely case of:\n\"b_one/{first,second}\" will expand to: \"b_one/first\" \"b_one/second\"\n\n...which causes \"b_one/second\" to be interpreted as the destination\ndirectory.   A knowledgeable bash user can avoid this by using:\n-b=b_one/{first,second} to avoid this situation.\n\nBut with the above invocation, no explicit support is needed\nfor command-line parsing in git-svn.\n"},{"id":"199421","messageId":"CAMvPOPuCW-oCfV8pyN3OMU3barFsSX2pHgr4K4Og7GOnFiU-7Q@mail.gmail.com","threadId":"31576","inReplyTo":"20120918204654.GA22856@dcvr.yhbt.net","subject":"Re: [PATCH] Allow fancy globs in git-svn init branches","fromName":"Ammon Riley","fromEmail":"ammon.riley@gmail.com","sentAt":"2012-09-18T22:56:10Z","receivedAt":"2012-09-18T22:56:10Z","isPatch":true,"sender":{"key":"ammon.riley@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1801261?v=4"},"body":"On Tue, Sep 18, 2012 at 1:46 PM, Eric Wong <normalperson@yhbt.net> wrote:\n> Ammon Riley <ammon.riley@gmail.com> wrote:\n>> Branches passed to 'git-svn init' via the -b/--branches flag\n>> automatically had a /* appended to them.  When the branch contained\n>> a fancy glob with a {} pattern, this is incorrect behaviour, and\n>> leads to odd branches being created in the git repository.\n>>\n>> Signed-off-by: Ammon Riley <ammon.riley@gmail.com>\n>> ---\n>>  git-svn.perl                         |  2 +-\n>>  t/t9141-git-svn-multiple-branches.sh | 12 ++++++++++++\n>>  2 files changed, 13 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/git-svn.perl b/git-svn.perl\n>> index 0d77ffb..f8e8558 100755\n>> --- a/git-svn.perl\n>> +++ b/git-svn.perl\n>> @@ -1678,7 +1678,7 @@ sub complete_url_ls_init {\n>>       my $remote_path = join_paths( $gs->path, $repo_path );\n>>       $remote_path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;\n>>       $remote_path =~ s#^/##g;\n>> -     $remote_path .= \"/*\" if $remote_path !~ /\\*/;\n>> +     $remote_path .= \"/*\" if $remote_path !~ m#\\*|\\{[^/]+\\}#;\n>>       my ($n) = ($switch =~ /^--(\\w+)/);\n>>       if (length $pfx && $pfx !~ m#/$#) {\n>>               die \"--prefix='$pfx' must have a trailing slash '/'\\n\";\n>> diff --git a/t/t9141-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh\n>> index 3cd0671..1b872a9 100755\n>> --- a/t/t9141-git-svn-multiple-branches.sh\n>> +++ b/t/t9141-git-svn-multiple-branches.sh\n>> @@ -119,4 +119,16 @@ test_expect_success 'create new branches and tags' '\n>>               svn_cmd up && test -e tags_B/Tag2/a.file )\n>>  '\n>>\n>> +test_expect_success 'clone multiple branch paths using fancy glob' '\n>> +     git svn clone -T trunk \\\n>> +                   -b b_one/{first} --branches b_two \\\n>\n> I'm concerned encouraging this can cause confusion on the command-line\n> for bash users.\n>\n> In bash, \"b_one/{first}\" will be passed as-is (and hardly anybody\n> will have a repo with '{word}' in the path)\n>\n> However, unless quoted on the command-line, a likely case of:\n> \"b_one/{first,second}\" will expand to: \"b_one/first\" \"b_one/second\"\n>\n> ...which causes \"b_one/second\" to be interpreted as the destination\n> directory.   A knowledgeable bash user can avoid this by using:\n> -b=b_one/{first,second} to avoid this situation.\n>\n> But with the above invocation, no explicit support is needed\n> for command-line parsing in git-svn.\n\nI confess that I'd completely forgot about the {} expansion in bash.\nPerhaps a note in the CAVEATS section of the documentation would\nbe sufficient?\n\nAs a bit of background on the reason for this patch, the branches\nin our repository are set up under svnroot as:\n\n    <project>/releases/<branchName>/<branchName>/\n\nI have no idea why.  So I end up with an init line like so:\n\n    git svn init -T trunk -b 'releases/release_7_0/{release_7_0}' \\\n                          -b 'releases/release_7_1/{release_7_1}' \\\n                          http://server/svnroot/myProj\n\nThis, unfortunately, prevents me from using the shorter {A,B}\nnotation, so I didn't test that.\n"},{"id":"199436","messageId":"20120919015238.GA32008@dcvr.yhbt.net","threadId":"31576","inReplyTo":"CAMvPOPuCW-oCfV8pyN3OMU3barFsSX2pHgr4K4Og7GOnFiU-7Q@mail.gmail.com","subject":"Re: [PATCH] Allow fancy globs in git-svn init branches","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2012-09-19T01:52:38Z","receivedAt":"2012-09-19T01:52:38Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Ammon Riley <ammon.riley@gmail.com> wrote:\n> I confess that I'd completely forgot about the {} expansion in bash.\n> Perhaps a note in the CAVEATS section of the documentation would\n> be sufficient?\n\nI think so, yes.  Can you send a patch for that instead?  Thanks.\n"}]}