Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 30 lines (22 sloc) 682 Bytes
#!/bin/bash
#
# behavior like mercurial's "out" command
#
shopt -s extglob
curbranch=$(git symbolic-ref -q HEAD)
curbranch=${curbranch#refs/heads/}
if [[ -z $curbranch ]]; then
printf 'error: current branch is unknown!\n' >&2
exit 1
fi
[[ $1 ]] && IFS='/' read -r remote merge <<< "$1"
if [[ -z $remote ]]; then
remote=$(git config "branch.$curbranch.remote" 2>/dev/null || echo "origin")
remote=${remote##*/}
fi
if [[ -z $merge ]]; then
merge=$(git config "branch.$curbranch.merge" 2>/dev/null || echo "$curbranch")
merge=${merge##*/?(+)}
fi
printf 'Comparing with %s/%s\n' "${remote:-origin}" "${merge:-master}"
git cherry -v ${remote:-origin}/${merge:-master}