[ANNOUNCE] cj-git-splitrepo & removing 'empty' merge commits with filter-branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello

I've needed a program to split a repository into multiple
repositories, each with part of the history according to file path
rules. I already wrote a wrapper around git filter-branch that took
care of the path filtering, but this time I finally wanted to take
care of merge commits that "do nothing", i.e. that have one parent
commit with the same tree as the merge commit and another parent
that's part of the history of the other parent. (Similar rule for
octopus merges if I happen to ever run across one of these.)
git-filter-branch doesn't have functionality to remove these by
itself, thus a custom commit filter is needed.

This turned out to be a bit of an adventure because arrays are really
well suited for this, but I've rarely used them in shell scripts, so I
tracked down the necessary syntactical vodoo for writing my code in
bash, only to find out that git filter-branch is actually calling my
code in sh, not bash (hence no arrays). After realizing this, and
coping with it by moving my code inside a bash invocation (and making
a copy of the library code from git-filter-branch--why isn't this in a
separate file, btw, then I could just include it from there?), I
thought I should perhaps send you all a notice about it, in case
anyone else wanted to split repositories cleanly, too. Or in case
someone wanted to point out that I'm doing this in a stupid way or a
nice solution exists elsewhere already: please tell me about it!

So, here's my wrapper around git-filter-branch that is able to remove
paths (including whole directories) and removes 'empty' merges:
https://github.com/pflanze/chj-bin/blob/master/cj-git-filter-branch

And a wrapper around cj-git-filter-branch that makes creating a
partial copy of a repository easy:
https://github.com/pflanze/chj-bin/blob/master/cj-git-splitrepo

If you want to actually run these, you need some of my libraries:

   # cd /opt; mkdir chj; cd chj
   # git clone https://github.com/pflanze/chj-perllib.git perllib
   # git clone https://github.com/pflanze/chj-bin.git bin
   # git clone https://github.com/pflanze/Class-Array.git
   # mkdir /usr/local/lib/site_perl/ # if it doesn't exist already
   # ln -s /opt/chj/perllib/Chj /usr/local/lib/site_perl/
   # ln -s /opt/chj/Class-Array /usr/local/lib/site_perl/Class

  and add /opt/chj/bin to your PATH (through your .bash_profile or
  similar)

(or you could supposedly use the PERL5LIB env var instead of symlinks).

Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]