#!/bin/sh -e
#
# git-contains - show git branches and tags that contains given SHA

usage() {
  cat <<-EOF

Show the branches and tags that contains the given SHA

Usage: git contains [-h] SHA

Options:
  -h          Display this help
EOF
}

# reset in case getopts has been used previously in the shell
OPTIND=1

# initialize our own variables:
# output_file=""
# verbose=0

# shellcheck disable=SC2249
while getopts ":h" opt; do
  case ${opt} in
    h | \?)
      usage
      exit 0
      ;;
  esac
done

if [ -z "$1" ]; then
  echo "You must provide a SHA"
  exit 1
fi

printf '%s\n' "Branches that contain SHA $1"
git branch --contains "$1"

printf '%s\n' "Tags that contain SHA $1"
git tag --contains "$1"
