{"thread":{"id":"42773","subject":"split directories into branches","startedAt":"2016-07-04T16:46:11Z","lastAt":"2016-07-05T09:56:44Z","messageCount":9,"participants":["shawn wilson","Konstantin Khomoutov","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"290796","messageId":"CAH_OBieCcx0_=vuZgoJ8GrZhhReEAhnjrz2pQwbwGgPFww4JmQ@mail.gmail.com","threadId":"42773","inReplyTo":null,"subject":"split directories into branches","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2016-07-04T16:45:39Z","receivedAt":"2016-07-04T16:46:11Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"I've got a chef cookbook repo where everyone started developing\ncookbooks in a single dev branch (not project specific). Minus a few\nedge cases, it should be fairly simple to split this up into feature\nbranches based on /cookbooks/<feature>.\n\nI tried:\n$ git filter-branch --subdirectory-filter cookbooks/<feature>-- <feature>\nAnd\n$ git subtree split --prefix cookbooks/<feature> -b <feature>\n\nWhich both seem to do the same thing (haven't looked at the subtree\nbash - guessing it does exactly the filter-branch). The issue is that\nit removes the directory tree (so obviously merges wouldn't work). I'm\nthinking some type of filter-branch --index-filter with a cherry pick\n(or similar) should work...?\n"},{"id":"290797","messageId":"20160704203946.3ac8d3205c08bfaee9a93a46@domain007.com","threadId":"42773","inReplyTo":"CAH_OBieCcx0_=vuZgoJ8GrZhhReEAhnjrz2pQwbwGgPFww4JmQ@mail.gmail.com","subject":"Re: split directories into branches","fromName":"Konstantin Khomoutov","fromEmail":"kostix+git@007spb.ru","sentAt":"2016-07-04T17:39:46Z","receivedAt":"2016-07-04T17:39:55Z","isPatch":false,"sender":{"key":"kostix+git@007spb.ru","avatar":null},"body":"On Mon, 4 Jul 2016 12:45:39 -0400\nshawn wilson <ag4ve.us@gmail.com> wrote:\n\n> I've got a chef cookbook repo where everyone started developing\n> cookbooks in a single dev branch (not project specific). Minus a few\n> edge cases, it should be fairly simple to split this up into feature\n> branches based on /cookbooks/<feature>.\n> \n> I tried:\n> $ git filter-branch --subdirectory-filter cookbooks/<feature>--\n> <feature> And\n> $ git subtree split --prefix cookbooks/<feature> -b <feature>\n> \n> Which both seem to do the same thing (haven't looked at the subtree\n> bash - guessing it does exactly the filter-branch). The issue is that\n> it removes the directory tree (so obviously merges wouldn't work). I'm\n> thinking some type of filter-branch --index-filter with a cherry pick\n> (or similar) should work...?\n\nTo achieve what you're after I used `git subtree split` followed by\n`git filter-branch --tree-filter ...` which moved all the files under\nthe directory hierarchy `git subtree split` removes.\n\nI'd love if `git subtree split` had an option to preserve the prefix\n(even better would be to have another option to rewrite the prefix)\nbecause that would greatly simplify another use case for `git subtree`:\nmoving \"a directory\" with its full history from one repository into\nanother.  Presently, the user is able to split that directory out from\nthe source repository but when they subtree-merge it back in the new\nrepository, they are puzzled by the fact `git log` invoked on the new\nhistory with the pathname prefix designating the \"inserted\" directory\ndoes not traverse past the merge point which brought that directory in.\n\nI know Git tracks content, not files (and directory) but still many\nfolks have \"stable\" directories for their files, assign certain\nsemantics to them etc.  I've needed such transfers myself, and this\ntopic has been raised more than once by folks over there on the\ngit-users mailing list.\n"},{"id":"290799","messageId":"CAH_OBie4dUB8WXfmKhLaezVKi0=LhnFw=wKJO1c3oUMA7VkYdw@mail.gmail.com","threadId":"42773","inReplyTo":"20160704203946.3ac8d3205c08bfaee9a93a46@domain007.com","subject":"Re: split directories into branches","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2016-07-04T18:15:58Z","receivedAt":"2016-07-04T18:16:33Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Mon, Jul 4, 2016 at 1:39 PM, Konstantin Khomoutov\n<kostix+git@007spb.ru> wrote:\n> On Mon, 4 Jul 2016 12:45:39 -0400\n> shawn wilson <ag4ve.us@gmail.com> wrote:\n>\n\n>\n> To achieve what you're after I used `git subtree split` followed by\n> `git filter-branch --tree-filter ...` which moved all the files under\n> the directory hierarchy `git subtree split` removes.\n>\n\nAh, that looks like it should work - thanks\n\n> I know Git tracks content, not files (and directory) but still many\n> folks have \"stable\" directories for their files, assign certain\n> semantics to them etc.  I've needed such transfers myself, and this\n> topic has been raised more than once by folks over there on the\n> git-users mailing list.\n\nOr just an option for git {rm,mv,cp} that would allow simple rewriting\nof history. Ie:\ngit mv HEAD~3.. -- foo bar\n(obviously not the sanest thing in most cases but would be a shorter\nreach than filter-branch - and if newest isn't head then it'd what?\nmove it back during commits for who knows what - still...)\n\nThanks for pointing out the users list - didn't notice it and sorry\nfor posting a user question on a dev list.\n"},{"id":"290800","messageId":"20160704212926.919a267706a6fa5791c47726@domain007.com","threadId":"42773","inReplyTo":"CAH_OBie4dUB8WXfmKhLaezVKi0=LhnFw=wKJO1c3oUMA7VkYdw@mail.gmail.com","subject":"Re: split directories into branches","fromName":"Konstantin Khomoutov","fromEmail":"kostix+git@007spb.ru","sentAt":"2016-07-04T18:29:26Z","receivedAt":"2016-07-04T18:29:35Z","isPatch":false,"sender":{"key":"kostix+git@007spb.ru","avatar":null},"body":"On Mon, 4 Jul 2016 14:15:58 -0400\nshawn wilson <ag4ve.us@gmail.com> wrote:\n\n[...]\n> > I know Git tracks content, not files (and directory) but still many\n> > folks have \"stable\" directories for their files, assign certain\n> > semantics to them etc.  I've needed such transfers myself, and this\n> > topic has been raised more than once by folks over there on the\n> > git-users mailing list.\n[...]\n> Thanks for pointing out the users list - didn't notice it and sorry\n> for posting a user question on a dev list.\n\nI don't possess the official stance on this topic but AFAIK user-level\nquestions are fine on this list.  The git-users mailing list was\ncreated -- as I understand it -- because of three reasons: 1) it's\neasier to post to; 2) you don't receive all the bug reports and patch\ntraffic irrelevant to mere mortals; 3) you have good chances to get\neven RTFM questions answered (mostly by those who just had RTFM\nrecently), though I'd say stackoverflow is better at this one. ;-)\n"},{"id":"290802","messageId":"CAH_OBieUYZTi+8W-m1TVVDstzF2vg1VuYQsd9Ka_uDoRYRY5rg@mail.gmail.com","threadId":"42773","inReplyTo":"20160704212926.919a267706a6fa5791c47726@domain007.com","subject":"Re: split directories into branches","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2016-07-04T21:03:46Z","receivedAt":"2016-07-04T21:04:12Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Mon, Jul 4, 2016 at 2:29 PM, Konstantin Khomoutov\n<kostix+git@007spb.ru> wrote:\n> On Mon, 4 Jul 2016 14:15:58 -0400\n> shawn wilson <ag4ve.us@gmail.com> wrote:\n>\n\n> I don't possess the official stance on this topic but AFAIK user-level\n> questions are fine on this list.\n\nIn that case :)\n... still having issues w/ filter-branch:\n\n$ git filter-branch --tree-filter \"shopt -s extglob && mkdir -p\ncookbooks/base_sys && mv !(cookbooks) cookbooks/base_sys\"\nRewrite a90fb34230e02d9494934e5549f36bdbdd1b6ce6 (1/6) (0 seconds\npassed, remaining 0 predicted)\n/usr/local/libexec/git-core/git-filter-branch: eval: line 360: syntax\nerror near unexpected token `('\n/usr/local/libexec/git-core/git-filter-branch: eval: line 360: `shopt\n-s extglob && mkdir -p cookbooks/base_sys && mv !(cookbooks)\ncookbooks/base_sys'\n/usr/local/libexec/git-core/git-filter-branch: line 360: warning:\nsyntax errors in . or eval will cause future versions of the shell to\nabort as Posix requires\ntree filter failed: shopt -s extglob && mkdir -p cookbooks/base_sys &&\nmv !(cookbooks) cookbooks/base_sys\n\nI'm guessing it's because of how filter-branch is eval'ing stuff. But\nif I do !\\(cookbooks\\) it interprets the '(' and ')' as text - ideas?\n"},{"id":"290803","messageId":"87eg79qcld.fsf@linux-m68k.org","threadId":"42773","inReplyTo":"CAH_OBieUYZTi+8W-m1TVVDstzF2vg1VuYQsd9Ka_uDoRYRY5rg@mail.gmail.com","subject":"Re: split directories into branches","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2016-07-04T22:10:06Z","receivedAt":"2016-07-04T22:10:15Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"shawn wilson <ag4ve.us@gmail.com> writes:\n\n> $ git filter-branch --tree-filter \"shopt -s extglob && mkdir -p\n> cookbooks/base_sys && mv !(cookbooks) cookbooks/base_sys\"\n\nextglob changes the parser, you need to set that on a separate line.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"290807","messageId":"CAH_OBieNO-fSW-ncsezZ5KG2c80fY-rUU6OPGgw0RJMGcpi+KQ@mail.gmail.com","threadId":"42773","inReplyTo":"87eg79qcld.fsf@linux-m68k.org","subject":"Re: split directories into branches","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2016-07-04T23:30:26Z","receivedAt":"2016-07-04T23:30:51Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Mon, Jul 4, 2016 at 6:10 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> shawn wilson <ag4ve.us@gmail.com> writes:\n>\n>> $ git filter-branch --tree-filter \"shopt -s extglob && mkdir -p\n>> cookbooks/base_sys && mv !(cookbooks) cookbooks/base_sys\"\n>\n> extglob changes the parser, you need to set that on a separate line.\n>\n\nby \"separate line\", I'm guessing you mean outside of the filter-branch\neval? Something like this?\nshopt -s extglob; declare -a f=(!(cookbooks)); git filter-branch\n--tree-filter \"mkdir -p cookbooks/base_sys && mv $f\ncookbooks/base_sys\"\n\n(don't have access to the repo atm and am curious if this is what you mean)\n"},{"id":"290808","messageId":"CAH_OBidRkhGZ2yjAxGkvw=36PLtOACvHFuyKZxFZruTAtDwxiQ@mail.gmail.com","threadId":"42773","inReplyTo":"CAH_OBieNO-fSW-ncsezZ5KG2c80fY-rUU6OPGgw0RJMGcpi+KQ@mail.gmail.com","subject":"Re: split directories into branches","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2016-07-04T23:31:49Z","receivedAt":"2016-07-04T23:32:15Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"correction\n\nOn Mon, Jul 4, 2016 at 7:30 PM, shawn wilson <ag4ve.us@gmail.com> wrote:\n\n> shopt -s extglob; declare -a f=(!(cookbooks)); git filter-branch\n> --tree-filter \"mkdir -p cookbooks/base_sys && mv ${f[@]}\n> cookbooks/base_sys\"\n>\n"},{"id":"290811","messageId":"20160705125621.cfa55e07cedd2853377c4f08@domain007.com","threadId":"42773","inReplyTo":"CAH_OBieUYZTi+8W-m1TVVDstzF2vg1VuYQsd9Ka_uDoRYRY5rg@mail.gmail.com","subject":"Re: split directories into branches","fromName":"Konstantin Khomoutov","fromEmail":"kostix+git@007spb.ru","sentAt":"2016-07-05T09:56:21Z","receivedAt":"2016-07-05T09:56:44Z","isPatch":false,"sender":{"key":"kostix+git@007spb.ru","avatar":null},"body":"On Mon, 4 Jul 2016 17:03:46 -0400\nshawn wilson <ag4ve.us@gmail.com> wrote:\n\n[...]\n> > I don't possess the official stance on this topic but AFAIK\n> > user-level questions are fine on this list.\n> \n> In that case :)\n> ... still having issues w/ filter-branch:\n[...]\n\nI used something along these lines:\n\n  git filter-branch -f --tree-filter \\\n    'test -e my/new/dir || mkdir -p my/new/dir\n      find . -mindepth 1 -maxdepth 1 \\\n      -type d -path ./my -prune -o -print \\\n      | xargs -n 30 mv -t ./my/new/dir' master \n\nMore background on how it works [1] if you want.\n\n1. https://groups.google.com/d/msg/git-users/hxFmfUZpj_k/9IQAQq40BwAJ\n"}]}