{"thread":{"id":"28301","subject":"[ANNOUNCE] cj-git-splitrepo & removing 'empty' merge commits with filter-branch","startedAt":"2011-09-05T02:34:24Z","lastAt":"2011-09-05T02:34:24Z","messageCount":1,"participants":["Christian Jaeger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"174841","messageId":"CAEjYwfXDV=3M0O1oNX31kxdi-R4ZhG=6-qLYnkBmL2gm9UWi_Q@mail.gmail.com","threadId":"28301","inReplyTo":null,"subject":"[ANNOUNCE] cj-git-splitrepo & removing 'empty' merge commits with filter-branch","fromName":"Christian Jaeger","fromEmail":"chrjae@gmail.com","sentAt":"2011-09-05T02:34:24Z","receivedAt":"2011-09-05T02:34:24Z","isPatch":false,"sender":{"key":"chrjae@gmail.com","avatar":null},"body":"Hello\n\nI've needed a program to split a repository into multiple\nrepositories, each with part of the history according to file path\nrules. I already wrote a wrapper around git filter-branch that took\ncare of the path filtering, but this time I finally wanted to take\ncare of merge commits that \"do nothing\", i.e. that have one parent\ncommit with the same tree as the merge commit and another parent\nthat's part of the history of the other parent. (Similar rule for\noctopus merges if I happen to ever run across one of these.)\ngit-filter-branch doesn't have functionality to remove these by\nitself, thus a custom commit filter is needed.\n\nThis turned out to be a bit of an adventure because arrays are really\nwell suited for this, but I've rarely used them in shell scripts, so I\ntracked down the necessary syntactical vodoo for writing my code in\nbash, only to find out that git filter-branch is actually calling my\ncode in sh, not bash (hence no arrays). After realizing this, and\ncoping with it by moving my code inside a bash invocation (and making\na copy of the library code from git-filter-branch--why isn't this in a\nseparate file, btw, then I could just include it from there?), I\nthought I should perhaps send you all a notice about it, in case\nanyone else wanted to split repositories cleanly, too. Or in case\nsomeone wanted to point out that I'm doing this in a stupid way or a\nnice solution exists elsewhere already: please tell me about it!\n\nSo, here's my wrapper around git-filter-branch that is able to remove\npaths (including whole directories) and removes 'empty' merges:\nhttps://github.com/pflanze/chj-bin/blob/master/cj-git-filter-branch\n\nAnd a wrapper around cj-git-filter-branch that makes creating a\npartial copy of a repository easy:\nhttps://github.com/pflanze/chj-bin/blob/master/cj-git-splitrepo\n\nIf you want to actually run these, you need some of my libraries:\n\n   # cd /opt; mkdir chj; cd chj\n   # git clone https://github.com/pflanze/chj-perllib.git perllib\n   # git clone https://github.com/pflanze/chj-bin.git bin\n   # git clone https://github.com/pflanze/Class-Array.git\n   # mkdir /usr/local/lib/site_perl/ # if it doesn't exist already\n   # ln -s /opt/chj/perllib/Chj /usr/local/lib/site_perl/\n   # ln -s /opt/chj/Class-Array /usr/local/lib/site_perl/Class\n\n  and add /opt/chj/bin to your PATH (through your .bash_profile or\n  similar)\n\n(or you could supposedly use the PERL5LIB env var instead of symlinks).\n\nChristian.\n"}]}