rb_one() {
local b=$1
+ shift
- printf "### ${b}"
+ printf "${BRACKET}### ${GREEN}${b}${NORMAL}"
if ! git config --local "branch.${b}.merge" >/dev/null; then
echo " -> skipping due to missing merge branch"
else
echo
git checkout -q "${b}" || return
- if ! git rebase ; then
+ git rebase "${opts[@]}" | sed -e '/^Fast-forwarded/d' -e "s:^:${BAD}:" -e "s:$:${NORMAL}:"
+ if [[ ${PIPESTATUS[0]} -ne 0 ]] ; then
git rebase --abort
fi
fi
usage() {
cat <<EOF
-Usage: rb-all
+Usage: rb-all [-q]
EOF
exit 1
}
main() {
- if [[ $# -ne 0 ]] ; then
- usage
- fi
+ local opts=(-q)
+ while [[ $# -ne 0 ]] ; do
+ case $1 in
+ -q|-v|-n|--no-stat|--stat) opts+=( "$1" );;
+ *) usage ;;
+ esac
+ shift
+ done
+
+ [[ -z ${GOOD} ]] && eval "$(bash-colors --env)"
# Switch to the top dir in case the working dir doesn't exist in every branch.
cd "$(git rev-parse --show-toplevel)" || return
+ # Skip if rebase is in progress.
+ if [[ -e .git/rebase-merge/interactive ]] ; then
+ printf "${BAD}skipping due to active rebase${NORMAL}\n"
+ exit 1
+ fi
+
local orig b branches
orig=$(git rev-parse --abbrev-ref HEAD) || return
- branches=( $(git ls-remote --heads . | sed 's:.*refs/heads/::') )
+ branches=( $(git for-each-ref --format='%(refname:short)' 'refs/heads/*') )
for b in "${branches[@]}" ; do
- rb_one "${b}"
+ rb_one "${b}" "${opts[@]}"
done
git checkout -q "${orig}"