#!/bin/sh REPO_PATH="$1" LOCAL_BRANCH="$2" REMOTE="$3" REMOTE_BRANCH="$4" LOCAL_BRANCH=${LOCAL_BRANCH:="master"} REMOTE=${REMOTE:="origin"} REMOTE_BRANCH=${REMOTE_BRANCH:=$LOCAL_BRANCH} usage() { echo "git_check.sh repo [local_branch [remote [remote_branch]]]" > /dev/stderr echo " repo: repository path" > /dev/stderr echo " local_branch: name of local branch" > /dev/stderr echo " remote: name of remote" > /dev/stderr echo " remote_branch: name of remote branch" > /dev/stderr } check_vars() { if [ -z "$REPO_PATH" ] then echo "Missing repo path" > /dev/stderr usage exit 1 fi if [ ! -d $REPO_PATH ] then echo "$REPO_PATH should be a directory" > /dev/stderr usage exit 2 fi } check_vars git -C "$REPO_PATH" fetch "$REMOTE" git -C "$REPO_PATH" log "$LOCAL_BRANCH..${REMOTE}/${REMOTE_BRANCH}"