#! /bin/sh set -ex if [ $# != 1 ] || ! echo "$1" | grep -q '-';then echo >&2 "Syntax: $0 branch-list-delimited-by-dashes" exit 1 fi base="master" for elem in $(echo "$1"|tr '-' ' ');do if [ "$base" = "master" ];then next="$elem" else next="$base-$elem" fi git checkout "$next" git merge "$base" if [ -e "$next".patch ];then echo -e '/^--- /,$d\nw'|ed "$next".patch fi git diff "$base" "$next"|diffdecvs >>"$next".patch base="$next" done echo OK