{"thread":{"id":"41021","subject":"[PATCH 1/2] git-svn: support for prefixed globs in config","startedAt":"2015-12-16T13:01:07Z","lastAt":"2015-12-17T00:32:09Z","messageCount":6,"participants":["Victor Leschuk","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"274573","messageId":"1450270869-29822-1-git-send-email-vleschuk@accesssoftek.com","threadId":"41021","inReplyTo":null,"subject":"[PATCH 0/2] git-svn: add support for prefixed globs in config","fromName":"Victor Leschuk","fromEmail":"vleschuk@gmail.com","sentAt":"2015-12-16T13:01:07Z","receivedAt":"2015-12-16T13:01:07Z","isPatch":true,"sender":{"key":"vleschuk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1045374?v=4"},"body":"There are existing old SVN repos which use patterns in branch (and tag) names\nto indicate some information. For example: branches/release_01, branches/release_02, etc,\nhowever non-patterned branches co-exist with them (like branches/dev).\n\nIf someone maintains git mirror of such a repo it is reasonable to mirror only\nseveral branches (for example those who match some pattern) and in current situation\nit leads to messy and error-prone git config like:\n\nbranches = branches/{release_20,release_21,release_22,...\n\nIt would be useful to have an opportunity to write\n\nbranches = branches/release_*\n\ninstead of this.\n\nThus I suggest to add support for such 'prefixed' globs into git-svn.\n\nVictor Leschuk (2):\n  Introduce prefixed globs for branches and tags in git-svn.\n  Add test for git-svn prefixed globs.\n\n Documentation/git-svn.txt        |   5 ++\n perl/Git/SVN/GlobSpec.pm         |   9 ++-\n t/t9168-git-svn-prefixed-glob.sh | 136 +++++++++++++++++++++++++++++++++++++++\n 3 files changed, 145 insertions(+), 5 deletions(-)\n create mode 100755 t/t9168-git-svn-prefixed-glob.sh\n\n-- \n2.7.0.rc0.21.gb793f61\n"},{"id":"274572","messageId":"1450270869-29822-2-git-send-email-vleschuk@accesssoftek.com","threadId":"41021","inReplyTo":"1450270869-29822-1-git-send-email-vleschuk@accesssoftek.com","subject":"[PATCH 1/2] git-svn: support for prefixed globs in config","fromName":"Victor Leschuk","fromEmail":"vleschuk@gmail.com","sentAt":"2015-12-16T13:01:08Z","receivedAt":"2015-12-16T13:01:08Z","isPatch":true,"sender":{"key":"vleschuk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1045374?v=4"},"body":"Introduce prefixed globs for branches and tags in git-svn.\n\nSigned-off-by: Victor Leschuk <vleschuk@accesssoftek.com>\n---\n Documentation/git-svn.txt | 5 +++++\n perl/Git/SVN/GlobSpec.pm  | 9 ++++-----\n 2 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex 0c0f60b..529cffe 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -1034,6 +1034,7 @@ listed below are allowed:\n \turl = http://server.org/svn\n \tfetch = trunk/project-a:refs/remotes/project-a/trunk\n \tbranches = branches/*/project-a:refs/remotes/project-a/branches/*\n+\tbranches = branches/release_*:refs/remotes/project-a/branches/release_*\n \ttags = tags/*/project-a:refs/remotes/project-a/tags/*\n ------------------------------------------------------------------------\n \n@@ -1044,6 +1045,10 @@ independent path component (surrounded by '/' or EOL).   This\n type of configuration is not automatically created by 'init' and\n should be manually entered with a text-editor or using 'git config'.\n \n+Also note that prefixed globs (e.g. 'release_*') match everything after prefix\n+but do not match exact prefix. For example:\n+'release_*' will match 'release_1' or 'release_v1' but will not match 'release_'.\n+\n It is also possible to fetch a subset of branches or tags by using a\n comma-separated list of names within braces. For example:\n \ndiff --git a/perl/Git/SVN/GlobSpec.pm b/perl/Git/SVN/GlobSpec.pm\nindex c95f5d7..a136090 100644\n--- a/perl/Git/SVN/GlobSpec.pm\n+++ b/perl/Git/SVN/GlobSpec.pm\n@@ -11,16 +11,15 @@ sub new {\n \tmy $die_msg = \"Only one set of wildcard directories \" .\n \t\t\t\t\"(e.g. '*' or '*/*/*') is supported: '$glob'\\n\";\n \tfor my $part (split(m|/|, $glob)) {\n-\t\tif ($part =~ /\\*/ && $part ne \"*\") {\n-\t\t\tdie \"Invalid pattern in '$glob': $part\\n\";\n-\t\t} elsif ($pattern_ok && $part =~ /[{}]/ &&\n+\t\tif ($pattern_ok && $part =~ /[{}]/ &&\n \t\t\t $part !~ /^\\{[^{}]+\\}/) {\n \t\t\tdie \"Invalid pattern in '$glob': $part\\n\";\n \t\t}\n-\t\tif ($part eq \"*\") {\n+\t\tif ($part =~ /(\\w*)\\*/) {\n \t\t\tdie $die_msg if $state eq \"right\";\n \t\t\t$state = \"pattern\";\n-\t\t\tpush(@patterns, \"[^/]*\");\n+\t\t\tmy $pat = $1 ? \"${1}[^/]+\" : \"[^/]*\";\n+\t\t\tpush(@patterns, $pat);\n \t\t} elsif ($pattern_ok && $part =~ /^\\{(.*)\\}$/) {\n \t\t\tdie $die_msg if $state eq \"right\";\n \t\t\t$state = \"pattern\";\n-- \n2.7.0.rc0.21.gb793f61\n"},{"id":"274574","messageId":"1450270869-29822-3-git-send-email-vleschuk@accesssoftek.com","threadId":"41021","inReplyTo":"1450270869-29822-1-git-send-email-vleschuk@accesssoftek.com","subject":"[PATCH 2/2] git-svn: test for git-svn prefixed globs","fromName":"Victor Leschuk","fromEmail":"vleschuk@gmail.com","sentAt":"2015-12-16T13:01:09Z","receivedAt":"2015-12-16T13:01:09Z","isPatch":true,"sender":{"key":"vleschuk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1045374?v=4"},"body":"Add test for git-svn prefixed globs.\n\nSigned-off-by: Victor Leschuk <vleschuk@accesssoftek.com>\n---\n t/t9168-git-svn-prefixed-glob.sh | 136 +++++++++++++++++++++++++++++++++++++++\n 1 file changed, 136 insertions(+)\n create mode 100755 t/t9168-git-svn-prefixed-glob.sh\n\ndiff --git a/t/t9168-git-svn-prefixed-glob.sh b/t/t9168-git-svn-prefixed-glob.sh\nnew file mode 100755\nindex 0000000..979ecd9\n--- /dev/null\n+++ b/t/t9168-git-svn-prefixed-glob.sh\n@@ -0,0 +1,136 @@\n+#!/bin/sh\n+test_description='git svn globbing refspecs with prefixed globs'\n+. ./lib-git-svn.sh\n+\n+cat > expect.end <<EOF\n+the end\n+hi\n+start a new branch\n+initial\n+EOF\n+\n+test_expect_success 'test refspec prefixed globbing' '\n+\tmkdir -p trunk/src/a trunk/src/b trunk/doc &&\n+\techo \"hello world\" > trunk/src/a/readme &&\n+\techo \"goodbye world\" > trunk/src/b/readme &&\n+\tsvn_cmd import -m \"initial\" trunk \"$svnrepo\"/trunk &&\n+\tsvn_cmd co \"$svnrepo\" tmp &&\n+\t(\n+\t\tcd tmp &&\n+\t\tmkdir branches tags &&\n+\t\tsvn_cmd add branches tags &&\n+\t\tsvn_cmd cp trunk branches/b_start &&\n+\t\tsvn_cmd commit -m \"start a new branch\" &&\n+\t\tsvn_cmd up &&\n+\t\techo \"hi\" >> branches/b_start/src/b/readme &&\n+\t\tpoke branches/b_start/src/b/readme &&\n+\t\techo \"hey\" >> branches/b_start/src/a/readme &&\n+\t\tpoke branches/b_start/src/a/readme &&\n+\t\tsvn_cmd commit -m \"hi\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd cp branches/b_start tags/t_end &&\n+\t\techo \"bye\" >> tags/t_end/src/b/readme &&\n+\t\tpoke tags/t_end/src/b/readme &&\n+\t\techo \"aye\" >> tags/t_end/src/a/readme &&\n+\t\tpoke tags/t_end/src/a/readme &&\n+\t\tsvn_cmd commit -m \"the end\" &&\n+\t\techo \"byebye\" >> tags/t_end/src/b/readme &&\n+\t\tpoke tags/t_end/src/b/readme &&\n+\t\tsvn_cmd commit -m \"nothing to see here\"\n+\t) &&\n+\tgit config --add svn-remote.svn.url \"$svnrepo\" &&\n+\tgit config --add svn-remote.svn.fetch \\\n+\t                 \"trunk/src/a:refs/remotes/trunk\" &&\n+\tgit config --add svn-remote.svn.branches \\\n+\t                 \"branches/b_*/src/a:refs/remotes/branches/b_*\" &&\n+\tgit config --add svn-remote.svn.tags\\\n+\t                 \"tags/t_*/src/a:refs/remotes/tags/t_*\" &&\n+\tgit svn multi-fetch &&\n+\tgit log --pretty=oneline refs/remotes/tags/t_end | \\\n+\t    sed -e \"s/^.\\{41\\}//\" > output.end &&\n+\ttest_cmp expect.end output.end &&\n+\ttest \"`git rev-parse refs/remotes/tags/t_end~1`\" = \\\n+\t\t\"`git rev-parse refs/remotes/branches/b_start`\" &&\n+\ttest \"`git rev-parse refs/remotes/branches/b_start~2`\" = \\\n+\t\t\"`git rev-parse refs/remotes/trunk`\" &&\n+\ttest_must_fail git rev-parse refs/remotes/tags/t_end@3\n+\t'\n+\n+echo try to try > expect.two\n+echo nothing to see here >> expect.two\n+cat expect.end >> expect.two\n+\n+test_expect_success 'test left-hand-side only prefixed globbing' '\n+\tgit config --add svn-remote.two.url \"$svnrepo\" &&\n+\tgit config --add svn-remote.two.fetch trunk:refs/remotes/two/trunk &&\n+\tgit config --add svn-remote.two.branches \\\n+\t                 \"branches/b_*:refs/remotes/two/branches/*\" &&\n+\tgit config --add svn-remote.two.tags \\\n+\t                 \"tags/t_*:refs/remotes/two/tags/*\" &&\n+\t(\n+\t\tcd tmp &&\n+\t\techo \"try try\" >> tags/t_end/src/b/readme &&\n+\t\tpoke tags/t_end/src/b/readme &&\n+\t\tsvn_cmd commit -m \"try to try\"\n+\t) &&\n+\tgit svn fetch two &&\n+\ttest `git rev-list refs/remotes/two/tags/t_end | wc -l` -eq 6 &&\n+\ttest `git rev-list refs/remotes/two/branches/b_start | wc -l` -eq 3 &&\n+\ttest `git rev-parse refs/remotes/two/branches/b_start~2` = \\\n+\t     `git rev-parse refs/remotes/two/trunk` &&\n+\ttest `git rev-parse refs/remotes/two/tags/t_end~3` = \\\n+\t     `git rev-parse refs/remotes/two/branches/b_start` &&\n+\tgit log --pretty=oneline refs/remotes/two/tags/t_end | \\\n+\t    sed -e \"s/^.\\{41\\}//\" > output.two &&\n+\ttest_cmp expect.two output.two\n+\t'\n+\n+test_expect_success 'test prefixed globs do not match just prefix' '\n+\tgit config --add svn-remote.three.url \"$svnrepo\" &&\n+\tgit config --add svn-remote.three.fetch \\\n+\t                 trunk:refs/remotes/three/trunk &&\n+\tgit config --add svn-remote.three.branches \\\n+\t                 \"branches/b_*:refs/remotes/three/branches/*\" &&\n+\tgit config --add svn-remote.three.tags \\\n+\t                 \"tags/t_*:refs/remotes/three/tags/*\" &&\n+\t(\n+\t\tcd tmp &&\n+\t\tsvn_cmd cp trunk branches/b_ &&\n+\t\techo \"You should never see me\" >> branches/b_/src/a/readme &&\n+\t\tpoke branches/b_/src/a/readme &&\n+\t\tsvn_cmd commit -m \"Never seen branch commit\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd cp branches/b_ tags/t_ &&\n+\t\techo \"You should never see mee too\" >> tags/t_/src/a/readme &&\n+\t\tpoke tags/t_/src/a/readme &&\n+\t\tsvn_cmd commit -m \"Never seen tag commit\" &&\n+\t\tsvn_cmd up\n+\t) &&\n+\tgit svn fetch three &&\n+\ttest_path_is_missing refs/remotes/three/branches/b_ &&\n+\ttest_path_is_missing refs/remotes/three/tags/t_\n+\t'\n+\n+echo \"Only one set of wildcard directories\" \\\n+     \"(e.g. '*' or '*/*/*') is supported: 'branches/b_*/t/*'\" > expect.four\n+echo \"\" >> expect.four\n+\n+test_expect_success 'test disallow prefixed multi-globs' '\n+\tgit config --add svn-remote.four.url \"$svnrepo\" &&\n+\tgit config --add svn-remote.four.fetch \\\n+\t                 trunk:refs/remotes/four/trunk &&\n+\tgit config --add svn-remote.four.branches \\\n+\t                 \"branches/b_*/t/*:refs/remotes/four/branches/*\" &&\n+\tgit config --add svn-remote.four.tags \\\n+\t                 \"tags/t_*/*:refs/remotes/four/tags/*\" &&\n+\t(\n+\t\tcd tmp &&\n+\t\techo \"try try\" >> tags/t_end/src/b/readme &&\n+\t\tpoke tags/t_end/src/b/readme &&\n+\t\tsvn_cmd commit -m \"try to try\"\n+\t) &&\n+\ttest_must_fail git svn fetch four 2> stderr.four &&\n+\ttest_cmp expect.four stderr.four\n+\t'\n+\n+test_done\n-- \n2.7.0.rc0.21.gb793f61\n"},{"id":"274607","messageId":"20151216212811.GA19884@dcvr.yhbt.net","threadId":"41021","inReplyTo":"1450270869-29822-3-git-send-email-vleschuk@accesssoftek.com","subject":"Re: [PATCH 2/2] git-svn: test for git-svn prefixed globs","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2015-12-16T21:28:11Z","receivedAt":"2015-12-16T21:28:11Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Thanks for this work.  Most things look fine with 1/2, comments\non 2/2 below...\n\nVictor Leschuk <vleschuk@gmail.com> wrote:\n> Add test for git-svn prefixed globs.\n\nWhy a separate patch?  Unless there's some documentation purpose\nfor a regression, usually tests and a feature should be added\natomically in the same commit.\n\n> --- /dev/null\n> +++ b/t/t9168-git-svn-prefixed-glob.sh\n> @@ -0,0 +1,136 @@\n> +#!/bin/sh\n> +test_description='git svn globbing refspecs with prefixed globs'\n> +. ./lib-git-svn.sh\n> +\n> +cat > expect.end <<EOF\n\nWe prefer redirects in new code to be in the form of \">foo\" (no space)\n(or \">>foo\" for append).\n\nIt wasn't in the old tests, either, but Documentation/CodingGuidelines\nfavors this for new code.\n\n> +the end\n> +hi\n> +start a new branch\n> +initial\n> +EOF\n\nAll the setup code be checked for errors with '&&' as well.\n\n> +\ttest \"`git rev-parse refs/remotes/tags/t_end~1`\" = \\\n> +\t\t\"`git rev-parse refs/remotes/branches/b_start`\" &&\n> +\ttest \"`git rev-parse refs/remotes/branches/b_start~2`\" = \\\n> +\t\t\"`git rev-parse refs/remotes/trunk`\" &&\n\nAnd we prefer $(command) instead of `command` for nestability\nas Documentation/CodingGuidelines suggests.\n\n(yeah, most of the old tests don't follow the guidelines, but the\n guidelines also warn against fixup patches for them).\n\nThanks again.\n"},{"id":"274608","messageId":"5671D82B.8020107@gmail.com","threadId":"41021","inReplyTo":"20151216212811.GA19884@dcvr.yhbt.net","subject":"Re: [PATCH 2/2] git-svn: test for git-svn prefixed globs","fromName":"Victor Leschuk","fromEmail":"vleschuk@gmail.com","sentAt":"2015-12-16T21:31:23Z","receivedAt":"2015-12-16T21:31:23Z","isPatch":true,"sender":{"key":"vleschuk@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1045374?v=4"},"body":"Hello Eric, sorry, I just copy pasted your old t9108-git-svn-glob.sh, \nchanged branch names to be prefixed and added test for \"exact\" prefix \nmatch. If it is necessary I can rewrite it according to current guidelines.\n\nOn 12/17/2015 12:28 AM, Eric Wong wrote:\n> Thanks for this work.  Most things look fine with 1/2, comments\n> on 2/2 below...\n>\n> Victor Leschuk <vleschuk@gmail.com> wrote:\n>> Add test for git-svn prefixed globs.\n> Why a separate patch?  Unless there's some documentation purpose\n> for a regression, usually tests and a feature should be added\n> atomically in the same commit.\n>\n>> --- /dev/null\n>> +++ b/t/t9168-git-svn-prefixed-glob.sh\n>> @@ -0,0 +1,136 @@\n>> +#!/bin/sh\n>> +test_description='git svn globbing refspecs with prefixed globs'\n>> +. ./lib-git-svn.sh\n>> +\n>> +cat > expect.end <<EOF\n> We prefer redirects in new code to be in the form of \">foo\" (no space)\n> (or \">>foo\" for append).\n>\n> It wasn't in the old tests, either, but Documentation/CodingGuidelines\n> favors this for new code.\n>\n>> +the end\n>> +hi\n>> +start a new branch\n>> +initial\n>> +EOF\n> All the setup code be checked for errors with '&&' as well.\n>\n>> +\ttest \"`git rev-parse refs/remotes/tags/t_end~1`\" = \\\n>> +\t\t\"`git rev-parse refs/remotes/branches/b_start`\" &&\n>> +\ttest \"`git rev-parse refs/remotes/branches/b_start~2`\" = \\\n>> +\t\t\"`git rev-parse refs/remotes/trunk`\" &&\n> And we prefer $(command) instead of `command` for nestability\n> as Documentation/CodingGuidelines suggests.\n>\n> (yeah, most of the old tests don't follow the guidelines, but the\n>   guidelines also warn against fixup patches for them).\n>\n> Thanks again.\n"},{"id":"274643","messageId":"20151217003209.GA32491@dcvr.yhbt.net","threadId":"41021","inReplyTo":"5671D82B.8020107@gmail.com","subject":"Re: [PATCH 2/2] git-svn: test for git-svn prefixed globs","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2015-12-17T00:32:09Z","receivedAt":"2015-12-17T00:32:09Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Victor Leschuk <vleschuk@gmail.com> wrote:\n> Hello Eric, sorry, I just copy pasted your old\n> t9108-git-svn-glob.sh, changed branch names to be prefixed and added\n> test for \"exact\" prefix match. If it is necessary I can rewrite it\n> according to current guidelines.\n\nYes, please do if you can.  I can do it if you're willing to wait a bit.\n"}]}