You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

33 lines
740 B

#!/bin/sh
cd "$(dirname "$0")"
branch="$(git branch | sed -n 's/^* \(.*\)$/\1/p;')"
[ -n "$branch" ] || exit
remote=$(git config --get "branch.$branch.remote")
rbranch=$(git config --get "branch.$branch.merge" | sed -e 's|^refs/heads/||')
rurl=$(git config --get "remote.$remote.url")
[ -n "$remote" -a -n "$rbranch" -a -n "$rurl" ] || exit
echo "# $PWD ($branch <- $rurl:$rbranch)"
hash0=$(git rev-parse "$remote/$rbranch")
git fetch "$remote"
hash1=$(git rev-parse "$remote/$rbranch")
[ -n "$hash0" -a -n "$hash1" -a "$hash0" != "$hash1" ] || exit
if [ "$(git ls-files -md)" ]; then
stashed=true
git stash -q
else
stashed=false
fi
git rebase "$remote/$rbranch"
if $stashed; then
git stash pop -q
fi
[ $# -eq 0 ] || exec "$@"