{"thread":{"id":"31239","subject":"git svn clone, a non-standard layout question","startedAt":"2012-08-13T03:23:16Z","lastAt":"2012-08-13T17:27:05Z","messageCount":5,"participants":["Christopher Marshall","Peter Baumann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"196893","messageId":"CANW+GuQ=egge=NcdSakChYXXZkW=MsG9f3i9yNvoutXXVFcPzQ@mail.gmail.com","threadId":"31239","inReplyTo":null,"subject":"git svn clone, a non-standard layout question","fromName":"Christopher Marshall","fromEmail":"christopherlmarshall@gmail.com","sentAt":"2012-08-13T03:23:16Z","receivedAt":"2012-08-13T03:23:16Z","isPatch":false,"sender":{"key":"christopherlmarshall@gmail.com","avatar":null},"body":"I would like to use git svn to clone an svn repo with a non-standard\nbranches layout roughly like this:\ntrunk/\ntags/\nbranches/\n   b1\n   b2\n   ...\n   bdir/\n      b3\n      b4\n      ...\n\nThat is, every directory under branches is a branch except bdir, and\nevery directory under bdir is a branch.\n\nOne thing I have attempted is this:\n   git svn clone \\\n                      --trunk=trunk \\\n                      --branches=branches/bdir \\\n                      --branches=branches \\\n                      --tags=tags \\\n                      --prefix=svn/ $SVN_REPO \\\n                      git.svn\n\nThat properly creates the remote tracking branches b1,b2,b3,b4 but\nalso creates the remote tracking branch bdir, which I am trying to\nexclude.  If I were to settle for this, the bdir branch would have\nenormous trees committed to it (when I ran against the real svn repo I\nam targetting).\n\nI get can exactly the branch mapping I want by editing .git/config like this:\n[svn-remote \"svn\"]\n        url = file:///home/chris/programs/svn/repo\n        fetch = trunk:refs/remotes/svn/trunk\n        tags = tags/*:refs/remotes/svn/tags/*\n        branches = branches/{b1,b2}:refs/remotes/svn/*\n        branches = branches/bdir/{b3,b4}:refs/remotes/svn/*\n\nbut then I would have to manually add branches before every git svn\nfetch, or risk not importing new branches that other developers have\ncreated since I last fetched.\n\nChris Marshall\n\np.s.  Here is the bash script I am using to experiment with this type\nof svn layout.  It creates a svn repo with the structure described\nabove, then applies my second (non-wildcard) solution.  The \"bash\"\nline right before the cleanup lines at the end is to allow you to look\naround before everything disappears.\n\n#!/bin/bash\n# file_summary: svn non-standard layout.  this works, and excludes\nbdir, but by not using wild cards it requires that branches be\nadded manually before a fetch.\n\nexport SVN_EDITOR=vi\nCWD=$(pwd)\nexport URL=file://$(pwd)/repo\n\nsvnadmin create repo\n\n# create top level directories.\nsvn checkout $URL proj\ncd proj\nsvn mkdir branches tags trunk\nsvn commit -m \"created top level dirs\"\nsvn mkdir branches/bdir\nsvn commit -m \"created non-standard branches dir\"\ncd $CWD\n\n# trunk\nsvn checkout ${URL}/trunk proj-t\ncd proj-t\necho -e \"1\\n2\\n3\" > f1\nsvn add f1\nsvn commit -m \"added f1: 1,2,3\"\ncd $CWD\n\n# create branches b1,b2,b3,b4\nsvn copy ${URL}/trunk ${URL}/branches/b1 -m \"created branch b1\"\nsvn copy ${URL}/trunk ${URL}/branches/b2 -m \"created branch b2\"\nsvn copy ${URL}/trunk ${URL}/branches/bdir/b3 -m \"created branch b3\"\nsvn copy ${URL}/trunk ${URL}/branches/bdir/b4 -m \"created branch b4\"\ncd $CWD\n\n# create a b1 commit\nsvn checkout ${URL}/branches/b1 proj-b1\ncd proj-b1\necho -e \"b1\" >> f1; svn commit -m \"b1 line\"\ncd $CWD\n\n# create a b2 commit\nsvn checkout ${URL}/branches/b2 proj-b2\ncd proj-b2\necho -e \"b2\" >> f1; svn commit -m \"b2 line\"\ncd $CWD\n\n# create a b3 commit\nsvn checkout ${URL}/branches/bdir/b3 proj-b3\ncd proj-b3\necho -e \"b3\" >> f1; svn commit -m \"b3 line\"\ncd $CWD\n\n# create a b4 commit\nsvn checkout ${URL}/branches/bdir/b4 proj-b4\ncd proj-b4\necho -e \"b4\" >> f1; svn commit -m \"b4 line\"\ncd $CWD\n\ngit svn clone --trunk=trunk --branches=branches --tags=tags\n--prefix=svn/ $URL -r 1:1 git.svn\ncd git.svn\ngrep -v branches .git/config > .git/config2\nmv .git/config2 .git/config\necho \"branches = branches/{b1,b2}:refs/remotes/svn/*\" >> .git/config\necho \"branches = branches/bdir/{b3,b4}:refs/remotes/svn/*\" >> .git/config\nrm .git/svn/.metadata\ngit svn fetch\n\nbash\ncd $CWD\nrm -rf repo proj proj-{t,b{1,2,3,4}} git.svn\n"},{"id":"196900","messageId":"20120813063132.GD10899@m62s10.vlinux.de","threadId":"31239","inReplyTo":"CANW+GuQ=egge=NcdSakChYXXZkW=MsG9f3i9yNvoutXXVFcPzQ@mail.gmail.com","subject":"Re: git svn clone, a non-standard layout question","fromName":"Peter Baumann","fromEmail":"waste.manager@gmx.de","sentAt":"2012-08-13T06:31:32Z","receivedAt":"2012-08-13T06:31:32Z","isPatch":false,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"On Sun, Aug 12, 2012 at 11:23:16PM -0400, Christopher Marshall wrote:\n> I would like to use git svn to clone an svn repo with a non-standard\n> branches layout roughly like this:\n> trunk/\n> tags/\n> branches/\n>    b1\n>    b2\n>    ...\n>    bdir/\n>       b3\n>       b4\n>       ...\n> \n> That is, every directory under branches is a branch except bdir, and\n> every directory under bdir is a branch.\n> \n> One thing I have attempted is this:\n>    git svn clone \\\n>                       --trunk=trunk \\\n>                       --branches=branches/bdir \\\n>                       --branches=branches \\\n>                       --tags=tags \\\n>                       --prefix=svn/ $SVN_REPO \\\n>                       git.svn\n> \n> That properly creates the remote tracking branches b1,b2,b3,b4 but\n> also creates the remote tracking branch bdir, which I am trying to\n> exclude.  If I were to settle for this, the bdir branch would have\n> enormous trees committed to it (when I ran against the real svn repo I\n> am targetting).\n> \n> I get can exactly the branch mapping I want by editing .git/config like this:\n> [svn-remote \"svn\"]\n>         url = file:///home/chris/programs/svn/repo\n>         fetch = trunk:refs/remotes/svn/trunk\n>         tags = tags/*:refs/remotes/svn/tags/*\n>         branches = branches/{b1,b2}:refs/remotes/svn/*\n>         branches = branches/bdir/{b3,b4}:refs/remotes/svn/*\n> \n> but then I would have to manually add branches before every git svn\n> fetch, or risk not importing new branches that other developers have\n> created since I last fetched.\n> \n\nI had a similar problem, but I solved it using \"ignore-paths\" and \"ignore-refs\".\nIf I remember correctly, you need to set both to ignore bdir directly without\nignoring b3, b4,...\n\nFor ignore-refs, pls see cdb51a13c3cf4830d499d1138160eacdd2b8aa46, as it is currently\nundocumented.\n\nSo I would try experimenting with the following settings:\n\n[svn-remote \"svn\"]\n\turl = file:///home/chris/programs/svn/repo\n\tfetch = trunk:refs/remotes/svn/trunk\n\ttags = tags/*:refs/remotes/svn/tags/*\n\tbranches = branches/{b1,b2}:refs/remotes/svn/*\n\tbranches = branches/bdir/{b3,b4}:refs/remotes/svn/*\n\n\t# Operates on the imported git branches\n\tignore-refs  = ^refs/remotes/bdir$\n\n\t# Operates on the SVN branches; you might try it first without this statement\n\tignore-paths = ^branches/bdir$\n"},{"id":"196908","messageId":"CANW+GuRoQJtZW6ZCwDQEj9OQD4C3BqxqX--2JV+=jkddagQgig@mail.gmail.com","threadId":"31239","inReplyTo":"20120813063132.GD10899@m62s10.vlinux.de","subject":"Re: git svn clone, a non-standard layout question","fromName":"Christopher Marshall","fromEmail":"christopherlmarshall@gmail.com","sentAt":"2012-08-13T13:29:53Z","receivedAt":"2012-08-13T13:29:53Z","isPatch":false,"sender":{"key":"christopherlmarshall@gmail.com","avatar":null},"body":">\n> I had a similar problem, but I solved it using \"ignore-paths\" and \"ignore-refs\".\n> If I remember correctly, you need to set both to ignore bdir directly without\n> ignoring b3, b4,...\n>\n> For ignore-refs, pls see cdb51a13c3cf4830d499d1138160eacdd2b8aa46, as it is currently\n> undocumented.\n>\n> So I would try experimenting with the following settings:\n>\n> [svn-remote \"svn\"]\n>         url = file:///home/chris/programs/svn/repo\n>         fetch = trunk:refs/remotes/svn/trunk\n>         tags = tags/*:refs/remotes/svn/tags/*\n>         branches = branches/{b1,b2}:refs/remotes/svn/*\n>         branches = branches/bdir/{b3,b4}:refs/remotes/svn/*\n>\n>         # Operates on the imported git branches\n>         ignore-refs  = ^refs/remotes/bdir$\n>\n>         # Operates on the SVN branches; you might try it first without this statement\n>         ignore-paths = ^branches/bdir$\n> --\n\nPeter:\n\nThanks for the advice.  I tried this:\n\n[svn-remote \"svn\"]\n        url = file:///home/chris/programs/svn/repo\n        fetch = trunk:refs/remotes/svn/trunk\n        branches = branches/*:refs/remotes/svn/*\n        tags = tags/*:refs/remotes/svn/tags/*\n        branches = branches/bdir/*:refs/remotes/svn/bdir2/*\n        ignore-paths  = ^branches/bdir$\n        ignore-refs  = ^refs/remotes/bdir$\n\nIt doesn't seem to change anything.\n\nChris\n"},{"id":"196909","messageId":"20120813133847.GE10899@m62s10.vlinux.de","threadId":"31239","inReplyTo":"CANW+GuRoQJtZW6ZCwDQEj9OQD4C3BqxqX--2JV+=jkddagQgig@mail.gmail.com","subject":"Re: git svn clone, a non-standard layout question","fromName":"Peter Baumann","fromEmail":"waste.manager@gmx.de","sentAt":"2012-08-13T13:38:47Z","receivedAt":"2012-08-13T13:38:47Z","isPatch":false,"sender":{"key":"waste.manager@gmx.de","avatar":null},"body":"On Mon, Aug 13, 2012 at 09:29:53AM -0400, Christopher Marshall wrote:\n> >\n> > I had a similar problem, but I solved it using \"ignore-paths\" and \"ignore-refs\".\n> > If I remember correctly, you need to set both to ignore bdir directly without\n> > ignoring b3, b4,...\n> >\n> > For ignore-refs, pls see cdb51a13c3cf4830d499d1138160eacdd2b8aa46, as it is currently\n> > undocumented.\n> >\n> > So I would try experimenting with the following settings:\n> >\n> > [svn-remote \"svn\"]\n> >         url = file:///home/chris/programs/svn/repo\n> >         fetch = trunk:refs/remotes/svn/trunk\n> >         tags = tags/*:refs/remotes/svn/tags/*\n> >         branches = branches/{b1,b2}:refs/remotes/svn/*\n> >         branches = branches/bdir/{b3,b4}:refs/remotes/svn/*\n> >\n> >         # Operates on the imported git branches\n> >         ignore-refs  = ^refs/remotes/bdir$\n> >\n> >         # Operates on the SVN branches; you might try it first without this statement\n> >         ignore-paths = ^branches/bdir$\n> > --\n> \n> Peter:\n> \n> Thanks for the advice.  I tried this:\n> \n> [svn-remote \"svn\"]\n>         url = file:///home/chris/programs/svn/repo\n>         fetch = trunk:refs/remotes/svn/trunk\n>         branches = branches/*:refs/remotes/svn/*\n>         tags = tags/*:refs/remotes/svn/tags/*\n>         branches = branches/bdir/*:refs/remotes/svn/bdir2/*\n>         ignore-paths  = ^branches/bdir$\n>         ignore-refs  = ^refs/remotes/bdir$\n> \n> It doesn't seem to change anything.\n> \n\nYou need a git version new enough to include cdb51a13c3cf4830d499d1138160eacdd2b8aa46, otherwise\nit won't have any effect and will be silently ignored.\n\n> Chris\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"},{"id":"196920","messageId":"CANW+GuQ4ZkOySSXN38ot7f=BR1SbXs8d7UvGVmuMDcPSUUzxGQ@mail.gmail.com","threadId":"31239","inReplyTo":"20120813133847.GE10899@m62s10.vlinux.de","subject":"Re: git svn clone, a non-standard layout question","fromName":"Christopher Marshall","fromEmail":"christopherlmarshall@gmail.com","sentAt":"2012-08-13T17:27:05Z","receivedAt":"2012-08-13T17:27:05Z","isPatch":false,"sender":{"key":"christopherlmarshall@gmail.com","avatar":null},"body":">> [svn-remote \"svn\"]\n>>         url = file:///home/chris/programs/svn/repo\n>>         fetch = trunk:refs/remotes/svn/trunk\n>>         branches = branches/*:refs/remotes/svn/*\n>>         tags = tags/*:refs/remotes/svn/tags/*\n>>         branches = branches/bdir/*:refs/remotes/svn/bdir2/*\n>>         ignore-paths  = ^branches/bdir$\n>>         ignore-refs  = ^refs/remotes/bdir$\n>>\n>> It doesn't seem to change anything.\n>>\n>\n> You need a git version new enough to include cdb51a13c3cf4830d499d1138160eacdd2b8aa46, otherwise\n> it won't have any effect and will be silently ignored.\n>\n>> Chris\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\nPeter:\n\nI see what you mean.  I will download a version of git that includes\nthat commit and try again.\n\nThanks for all your help,\n\nChris\n"}]}