From: Thomas Rast Date: Thu, 01 Dec 2011 15:50:51 GMT Subject: Re: Anyone have a commit hook for forbidding old branches from being merged in? Message-ID: <201112011650.51547.trast@student.ethz.ch> In-Reply-To: Ævar Arnfjörð Bjarmason wrote: > > So before I write a hook to do this, is there anything that implements > a hook that: > > * Checks if you're pushing a merge commit > * If so, is that merge based off and old version of $MAINBRANCH I think it suffices to check whether any boundary commit in the updated range is older than what you allow, e.g. while read old new rev; do # omitted: check it's an update, i.e., neither old nor new is 0..0 git rev-list --boundary $old..$new | sed -n 's/^-//p' | xargs git rev-list --no-walk --before='cutoff limit' >bad test -s bad || exit 1 done (Not tested much; in particular I'm not sure you can get away without limiting the number of args to rev-list to 1. A simple test seems to indicate so, however.) -- Thomas Rast trast@{inf,student}.ethz.ch