#!/bin/bash
set -e
if [ "$#" -lt "3" ] ; then
  echo "Usage: $0 trunk old branch [args to patch(1)]"
  echo
  echo "Performs \"diff -u old branch | patch trunk\" in a PO-friendly manner."
  echo
  exit
fi
trunk="$1" ; shift
old="$1" ; shift
branch="$1" ; shift
msgmerge --update ${old} ${trunk}
msgmerge --update ${branch} ${trunk}
diff -u ${old} ${branch} | patch ${trunk} $@
