# Settings appropriate for patchsyncs of distributed patches of rsync function was_patching_inexact { exec 3>&2 code=0 [ -n "$(find $1/ '(' -name '*.rej' -or -name '*.orig' ')' -printf 'Existence of file %P in branch indicates inexact patching\n' 2>&1 | tee /dev/fd/3)" ] && code=1 [ "$code" == 1 ] && cat 1>&2 <&- return $code } function do_patch { # Warn the user of inexactness, but it isn't an error yet exitoneok patch --backup-if-mismatch -d $2/ -p1 <$1 && ( was_patching_inexact $2 || true ) } function do_diff { # Use the same format as verify-patches. # Use sed to carry over the portion of the old patch before the first `--- old/foo'. was_patching_inexact $2 && sed -e '/^--- /,$d' patch >$3 && ln -nfs $1 old && ln -nfs $2 new && LC_COLLATE=C exitoneok diff -duprN old new | \ sed -re 's/^(\+\+\+|---) ([^\t]+).*$/\1 \2/' | \ exitoneok grep -v '^diff' | \ tee --append $3 | \ sed -nre 's/^(Binary files .* differ)$/\1; this is an error because the patch cannot represent this difference/p' >&2 && rm -f old new }