Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 78eb418249
Fetching contributors…

Cannot retrieve contributors at this time

executable file 92 lines (76 sloc) 1.719 kB
#!/bin/sh
CURRENT=`git branch | grep "\*" | cut -d' ' -f2`
# default settings
explain=false
verbose=true
run=true
printUsage() {
echo "usage: $0 [options]"
echo
echo " -h --help Show this message"
echo " -v --verbose Show all commands before running them (default: on)"
echo " -q --quiet Don't display commands before running them (default: off)"
echo " -e --explain --dry-run Don't actually run commands (default: off)"
echo
}
for arg in "$@"; do
case $arg
in
-e | --explain | --dry-run)
explain=true
verbose=true
run=false
;;
-v | --verbose)
verbose=true
;;
-q | --quiet)
verbose=false
;;
-h | --help)
printUsage
exit
;;
*)
echo "$0: unrecognized parameter '$arg'"
printUsage
exit 1
;;
esac
done
GIT=`which git`
git() {
test "$verbose" = true && echo "+ git $@"
test "$run" = true && eval "$GIT $@"
}
if [[ "$explain" == true ]]; then
echo "These are the commands that would be run:"
fi
REMOTE=`$GIT config branch.$CURRENT.remote`
if [[ -z "$REMOTE" ]]; then
REMOTE=origin
fi
TRACK=`$GIT config branch.$CURRENT.merge`
if [[ -z "$TRACK" ]]; then
TRACK=refs/heads/master
fi
TRACK_BRANCH=${TRACK/refs\/heads\//}
if [[ "$CURRENT" != "$TRACK_BRANCH" ]]; then
git checkout $TRACK_BRANCH
fi
$GIT svn info >/dev/null 2>/dev/null
if [[ $? == 0 ]]; then
TYPE="git-svn"
else
TYPE="git"
fi
if [[ "$TYPE" == "git-svn" ]]; then
git svn rebase
else
git fetch $REMOTE
git rebase $REMOTE/$TRACK_BRANCH
fi
if [[ "$CURRENT" != "$TRACK_BRANCH" ]]; then
git checkout $CURRENT
git rebase $TRACK_BRANCH
fi
Jump to Line
Something went wrong with that request. Please try again.