X-Git-Url: http://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=bin%2Fdashtopatch;h=901db5af73906f3ec7ac7f3d950ec98664cc41a5;hp=fb3d4fd4c0b41b20c5e8d8d36b69a8b5aeda1881;hb=cd7ade89b47f9e8fe50e6c5759625b548ed3dbc7;hpb=4243605851773a10d2db6ef4c0b8f228d4e24c07 diff --git a/bin/dashtopatch b/bin/dashtopatch index fb3d4fd..901db5a 100755 --- a/bin/dashtopatch +++ b/bin/dashtopatch @@ -1,34 +1,52 @@ #! /bin/sh set -ex -if [ "$1" = "-f" ];then - force=true +compile=false +if [ "$1" = -c ];then + compile=true shift -elif [ -n "$(/bin/ls *.patch 2>/dev/null|tee /proc/self/fd/2)" ];then - echo >&2 "Some *.patch files exist!" - exit 1 -else - force=false fi -if [ $# != 1 ] || ! echo "$1" | grep -q '-';then +if [ $# != 1 ];then echo >&2 "Syntax: $0 branch-list-delimited-by-dashes" exit 1 fi -base="master" +if [ -f origin ];then + origin="`cat origin`" +else + origin="origin/master" +fi +base=$origin +gerrit=true +if git branch -D gerrit;then + git checkout $origin + git checkout -b gerrit +else + gerrit=false +fi for elem in $(echo "$1"|tr '-' ' ');do - if [ "$base" = "master" ];then + if [ "$base" = $origin ];then next="$elem" else next="$base-$elem" fi git checkout "$next" - git merge "$base" - if $force;then - echo -e '/^--- /,$d\nw'|ed "$next".patch - else - rm -f "$next".patch + git merge --no-edit "$base" + if $compile;then + make + fi + if [ -e "$next".patch ];then + echo -e '/^--- /,$d\nw'|ed "$next".patch || : + fi + git diff "$base" "$next" --|diffdecvs >>"$next".patch + git diff -U9999999 --binary "$base" "$next" -- >"$next".Upatch + if $gerrit;then + cp "$next".patch dashtopatch.patch + echo -e '/^--- /,$d\nw'|ed dashtopatch.patch + git checkout gerrit + patch -p1 <"$next".patch + git commit -a -F dashtopatch.patch + rm -f dashtopatch.patch fi - git diff "$base" "$next"|diffdecvs >>"$next".patch base="$next" done -git checkout master +git checkout "$next" echo OK