Skip to content
This repository
tree: ab13dc326c
Fetching contributors…

Cannot retrieve contributors at this time

executable file 38 lines (34 sloc) 0.893 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#!/bin/sh

# --- Command line
refname="$1"
oldrev="$2"
newrev="$3"

# --- Safety check
if [ -z "$GIT_DIR" ]; then
    echo "Don't run this script from the command line." >&2
    echo " (if you want, you could supply GIT_DIR then run" >&2
    echo " $0 <ref> <oldrev> <newrev>)" >&2
    exit 1
fi

if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
    echo "Usage: $0 <ref> <oldrev> <newrev>" >&2
    exit 1
fi

# Don't allow merge commits on master
if [ "$refname" = "refs/heads/master" ]
then
    for rev in $(git rev-list $newrev --not $oldrev)
    do
        echo -n "Checking: $rev"
        if git rev-parse --verify --quiet $rev^2 > /dev/null
        then
            echo " (merge!)"
            echo
echo "Merges not allowed on master. Rebase your changes instead."
            echo
exit 1
        else
            echo " (ok)"
        fi
    done
fi
Something went wrong with that request. Please try again.