#!/bin/sh
set -e

usage () {
    cat <<'EOF'
usage: git contains <branch> <branch>

Returns whether the first branch contains the second.
Will return with an exit code of 0 or 1.
EOF
}

if [ $# -eq 2 ]; then
    first=$1
    second=$2
else
    usage >&2
    exit 2
fi

second_sha=$(git sha "$second")
ancestor_sha=$(git merge-base "$first" "$second")
[ "$ancestor_sha" = "$second_sha" ]
