#!/usr/bin/env sh
#
# git-continue - run git rebase --continue/git cherry-pick --continue based on context
#
# source: https://github.com/christoomey/dotfiles/blob/master/bin/git-continue

git_dir=$(git rev-parse --git-dir)
status=$?

if [ "${status}" -ne 0 ]; then
  exit "${status}"
fi

if [ -d "${git_dir}/rebase-merge" ]; then
  exec git rebase --continue
elif [ -d "${git_dir}/rebase-apply" ]; then
  exec git rebase --continue
elif [ -f "${git_dir}/MERGE_HEAD" ]; then
  exec git merge --continue
elif [ -f "${git_dir}/CHERRY_PICK_HEAD" ]; then
  exec git cherry-pick --continue
elif [ -f "${git_dir}/REVERT_HEAD" ]; then
  exec git revert --continue
else
  echo "error: No operation to --continue"
  exit 1
fi
