{"thread":{"id":"25400","subject":"git-svn.perl: Fix glob matching on svn paths","startedAt":"2010-10-09T09:07:15Z","lastAt":"2010-10-14T09:34:59Z","messageCount":4,"participants":["Tomáš Ebenlendr","Jonathan Nieder","ebik"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"153050","messageId":"1286615236-29732-1-git-send-email-ebik@ucw.cz","threadId":"25400","inReplyTo":null,"subject":"git-svn.perl: Fix glob matching on svn paths","fromName":"Tomáš Ebenlendr","fromEmail":"ebik@ucw.cz","sentAt":"2010-10-09T09:07:15Z","receivedAt":"2010-10-09T09:07:15Z","isPatch":false,"sender":{"key":"ebik@ucw.cz","avatar":"https://gravatar.com/avatar/69fda1fa3a10584a90df75a718af91fe98c2391076ec3e8594707c8d2bda6435?d=mp&s=160"},"body":"Hello,\n\nI tried to convert our repositories to git. Our repositories have only\nbranches (no tags, and no branch is so special to be called trunk).\nThe directory of each individual branch live in the root of the\nrepository (i.e., not in directory 'branches' as in standard layout).\n\nI init the repository by: git svn init path_to_repo -b *\nThis triggers first bogus match in match_globs(): the pattern matches an\nempty string - the place before first slash in any path.\n\nWe have created some branch names just by adding some suffix to another\nbranch name. Imagine branch \"devel\" and \"devel2\". Then there is bogus\nmatch on path '/devel2' as it outputs 'devel'.\n\nPatch in the next email fixes both these problems.\n"},{"id":"153051","messageId":"1286615236-29732-2-git-send-email-ebik@ucw.cz","threadId":"25400","inReplyTo":"1286615236-29732-1-git-send-email-ebik@ucw.cz","subject":"[PATCH] git-svn.perl: Fix glob matching on svn paths","fromName":"Tomáš Ebenlendr","fromEmail":"ebik@ucw.cz","sentAt":"2010-10-09T09:07:16Z","receivedAt":"2010-10-09T09:07:16Z","isPatch":true,"sender":{"key":"ebik@ucw.cz","avatar":"https://gravatar.com/avatar/69fda1fa3a10584a90df75a718af91fe98c2391076ec3e8594707c8d2bda6435?d=mp&s=160"},"body":"* Git::SVN::GlobSPec::new():\n  - Directories or files with empty name are not allowed: The star pattern\n    has to match at least one character.\n  - The main pattern has to start with full path, i.e. \"^/\" is prepended.\n    Also it has to end with directory boundary, i.e. \"(/|$)\" is appended.\n---\n git-svn.perl |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 18cfb24..01ae6a1 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -6132,7 +6132,7 @@ sub new {\n \t\tif ($part eq \"*\") {\n \t\t\tdie $die_msg if $state eq \"right\";\n \t\t\t$state = \"pattern\";\n-\t\t\tpush(@patterns, \"[^/]*\");\n+\t\t\tpush(@patterns, \"[^/]+\");\n \t\t} elsif ($pattern_ok && $part =~ /^\\{(.*)\\}$/) {\n \t\t\tdie $die_msg if $state eq \"right\";\n \t\t\t$state = \"pattern\";\n@@ -6155,8 +6155,8 @@ sub new {\n \tmy $left = join('/', @left);\n \tmy $right = join('/', @right);\n \t$re = join('/', @patterns);\n-\t$re = join('\\/',\n-\t\t   grep(length, quotemeta($left), \"($re)\", quotemeta($right)));\n+\t$re = '^\\/'.join('\\/',\n+\t\t   grep(length, quotemeta($left), \"($re)\", quotemeta($right))).'(?:\\/|$)';\n \tmy $left_re = qr/^\\/\\Q$left\\E(\\/|$)/;\n \tbless { left => $left, right => $right, left_regex => $left_re,\n \t        regex => qr/$re/, glob => $glob, depth => $depth }, $class;\n-- \n1.7.1\n"},{"id":"153118","messageId":"20101010061534.GB23100@burratino","threadId":"25400","inReplyTo":"1286615236-29732-2-git-send-email-ebik@ucw.cz","subject":"Re: [PATCH] git-svn.perl: Fix glob matching on svn paths","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-10T06:15:35Z","receivedAt":"2010-10-10T06:15:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Tomáš,\n\nTomáš Ebenlendr wrote:\n\n> I tried to convert our repositories to git. Our repositories have only\n> branches (no tags, and no branch is so special to be called trunk).\n> The directory of each individual branch live in the root of the\n> repository (i.e., not in directory 'branches' as in standard layout).\n\nOkay, so I am imagining:\n\n\t1.0.x/\n\t1.1.x/\n\t1.2.x/\n\t2.0.x/\n\t...\n\n> I init the repository by: git svn init path_to_repo -b *\n> This triggers first bogus match in match_globs(): the pattern matches an\n> empty string - the place before first slash in any path.\n\nA branches refspec of\n\n\t*:refs/remotes/*\n\nresults in\n\n\t$self{left} = ''\n\t$self{glob} = '*'\n\t$self{left_regex} = qr'^/(/|$)'\n\t$self{regex} = qr'([^/]*)'.\n\nDoes get_dir_globbed cope correctly?  Will get_dir cope correctly with\nthe spurious / (from $left/$de) inserted at the beginning of paths?\n\nThe regex always matches, even for empty $p, but it is not immediately\nobvious to me how that pans out.  Could you describe the symptoms?\n\n> We have created some branch names just by adding some suffix to another\n> branch name. Imagine branch \"devel\" and \"devel2\". Then there is bogus\n> match on path '/devel2' as it outputs 'devel'.\n\nIs this problem reproducible without the other change?  If so, would\nit makes sense to split off this fix as a separate patch?\n\nAlso, if Eric likes your patches, can he forge your sign-off?  See\nDocumentation/SubmittingPatches for what this means.\n\nThanks,\nJonathan\n"},{"id":"153503","messageId":"20101014113459.47bfa959@Chewbacca.cub","threadId":"25400","inReplyTo":"20101010061534.GB23100@burratino","subject":"Re: [PATCH] git-svn.perl: Fix glob matching on svn paths","fromName":"ebik","fromEmail":"ebik@ucw.cz","sentAt":"2010-10-14T09:34:59Z","receivedAt":"2010-10-14T09:34:59Z","isPatch":true,"sender":{"key":"ebik@ucw.cz","avatar":"https://gravatar.com/avatar/69fda1fa3a10584a90df75a718af91fe98c2391076ec3e8594707c8d2bda6435?d=mp&s=160"},"body":"(once again and \"reply-to-all\" this time)\n\nOn Sun, 10 Oct 2010 01:15:35 -0500\nJonathan Nieder <jrnieder@gmail.com> wrote:\n\n> Hi Tomáš,\n> \n> Tomáš Ebenlendr wrote:\n> \n> > I tried to convert our repositories to git. Our repositories have\n> > only branches (no tags, and no branch is so special to be called\n> > trunk). The directory of each individual branch live in the root of\n> > the repository (i.e., not in directory 'branches' as in standard\n> > layout).\n> \n> Okay, so I am imagining:\n> \n> \t1.0.x/\n> \t1.1.x/\n> \t1.2.x/\n> \t2.0.x/\n> \t...\n> \n> > I init the repository by: git svn init path_to_repo -b *\n> > This triggers first bogus match in match_globs(): the pattern\n> > matches an empty string - the place before first slash in any path.\n> \n> A branches refspec of\n> \n> \t*:refs/remotes/*\n> \n> results in\n> \n> \t$self{left} = ''\n> \t$self{glob} = '*'\n> \t$self{left_regex} = qr'^/(/|$)'\n> \t$self{regex} = qr'([^/]*)'.\n> \n> Does get_dir_globbed cope correctly?  Will get_dir cope correctly with\n> the spurious / (from $left/$de) inserted at the beginning of paths?\n> \n\nHmm, I don't know. The code is undocummented, thus I don't know what is\nany function supposed to return. I just guess. With the patch my\n\"git svn clone\" works, taking 48 hours to convert the repository.\nThe only problem is that many merges are probably mis-recognized\nas cherrypicking, but we can live with that.\n\nBoth parts of the patch individually fix the error triggered by\n'*:refs/remotes/*', but both parts are about what I think there should\nbe. The second part also fixes the bug with not recognised branches.\n\n> The regex always matches, even for empty $p, but it is not immediately\n> obvious to me how that pans out.  Could you describe the symptoms?\n> \nThe symptom of '*:refs/remotes/*' bug is following: 'clone' or 'fetch'\nfails with following message:\n\n  ref: 'refs/remotes/' ends with a trailing slash, this is not\n  permitted by git nor Subversion\n\nThis is die() in Git::SVN::refname(). Here is the backtrace for\nfetch. $VAR1 being the only argument passed to refname().\nNote that the line numbers my be off by small number, as I added\ntwo lines for the backtrace to happen.\n\n$VAR1 = bless( {\n                 'index' => '.git/svn/refs/remotes//index',\n                 'map_root' => '.git/svn/refs/remotes//.rev_map',\n                 'repo_id' => 'svn',\n                 'config' => '.git/svn/config',\n                 'path' => '',\n                 'dir' => '.git/svn/refs/remotes/',\n                 'ref_id' => 'refs/remotes/'\n               }, 'Git::SVN' );\n at ../git-svn.perl line 2075\n        Git::SVN::refname('Git::SVN=HASH(0x93df4b4)') called\nat ../git-svn.perl line 1954\nGit::SVN::init_remote_config('Git::SVN=HASH(0x93df4b4)',\n'file:///afs/ms/u/t/tebe7122/devel/pokussvn', 1) called\nat ../git-svn.perl line 2023 Git::SVN::init('Git::SVN',\n'file:///afs/ms/u/t/tebe7122/devel/pokussvn', '', 'undef',\n'refs/remotes/', 1) called at ../git-svn.perl line 5365\nGit::SVN::Ra::match_globs('Git::SVN::Ra=HASH(0x9673f54)',\n'HASH(0x910ec7c)', 'HASH(0x9674608)', 'ARRAY(0x8f845c4)', 1) called\nat ../git-svn.perl line 5257\nGit::SVN::Ra::gs_fetch_loop_common('Git::SVN::Ra=HASH(0x9673f54)', 0,\n2, 'ARRAY(0x8f845ac)', 'ARRAY(0x8f845c4)') called at ../git-svn.perl\nline 1809 Git::SVN::fetch_all('svn', 'HASH(0x92998f4)') called\nat ../git-svn.perl line 992 main::cmd_multi_fetch() called\nat ../git-svn.perl line 442 main::cmd_fetch() called at ../git-svn.perl\nline 314 eval {...} called at ../git-svn.perl line 312\n\n> > We have created some branch names just by adding some suffix to\n> > another branch name. Imagine branch \"devel\" and \"devel2\". Then\n> > there is bogus match on path '/devel2' as it outputs 'devel'.\n> \n> Is this problem reproducible without the other change?  If so, would\n> it makes sense to split off this fix as a separate patch?\n\nI cannot reproduce the second bug without '*:/refs/remotes/*',\nthus I'm not sure if I'm fixing the origin of the problem.\n\n> \n> Also, if Eric likes your patches, can he forge your sign-off?  See\n> Documentation/SubmittingPatches for what this means.\n> \n\nYes I'm fine with it. Although I'm not yet sure that I fix the problems\nat their origin, and I have no time to read the whole source now.\nI'll resubmit the patch(es) in any suggested shape, after someone\nconfirms, that it cannot break other things.\n\n> Thanks,\n> Jonathan\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n\n-- \n                                 Tomáš 'ebík' Ebenlendr\n                                 PF 2010.78487731481\n\n"}]}