+++ /dev/null
-#!/bin/sh
-
-while read oldrev newrev refname ; do
- if expr "$oldrev" : '0*$' >/dev/null ; then
- exit 0
- fi
-
- # If they are introducing non-merge commits /and/ merge commits, it could
- # look like one of two ways. This way:
- #
- # * --- B --- * --- oldrev
- # \ \
- # new --- new --- newrev
- #
- # They basically had an un-shared local dev branch (probably by making a
- # merge) and instead should have done a rebase. Also, if they did:
- #
- # * --- B --- * --- oldrev
- # \ \
- # new --- new --- new -- newrev
- #
- # We should try and catch them--where the merge happened previously to
- # them doing more work in the newrev commit.
- #
- # But if it looks like:
- #
- # * --- B --- * --- oldrev
- # \ \
- # old --- new --- newrev
- #
- # Then they had a pre-shared branch that cannot be rebased and so they
- # were correct in doing a merge to tie "old" and "oldrev" together.
- #
- # Also, we obviously have to be okay with:
- #
- # * --- * --- * --- oldrev --- new --- new --- newrev
-
- git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $oldrev..$newrev | while read commit ; do
- number_of_parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | wc -l)
- if [[ $number_of_parents > 1 ]] ; then
- # Find the original branch point (B)
- parents=$(git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit)
- baserev=$(git merge-base $parents)
-
- # For each parent
- git rev-list -n 1 --parents $commit | sed 's/ /\n/g' | grep -v $commit | while read parent ; do
- all_commits=$(git rev-list $baserev..$parent | wc -l)
- new_commits=$(git rev-parse --not --branches | git rev-list --stdin $baserev..$parent | wc -l)
- if [[ $all_commits -eq $new_commits ]] ; then
- echo "----------------------------------------------------"
- echo
- echo "It looks like you should rebase instead of merging $commit"
- echo
- echo "----------------------------------------------------"
- exit 1
- fi
- done
- if [ $? -ne 0 ] ; then
- exit 1
- fi
- fi
- done
- if [ $? -ne 0 ] ; then
- exit 1
- fi
-done
-