#!/bin/sh

if [ -f Makefile ]
then
    _name="$(make show=PKGNAME)"
    _epoch="$(make show=EPOCH)"
    _rev="$(make show=REVISION)"
    _patchname="${_name}${_epoch:+v$_epoch}${_rev:+p$_rev}"
else
    _patchname="unnamed_diff_$(date +%Y%m%d_%H%M%S)"
fi
set -x
if [ -d CVS ]
then
   doas cvs -d sdk@cvs.openbsd.org:/cvs diff -uNp . > /home/sdk/diffs/${_patchname}.diff
else
    doas git diff -U --no-prefix --cached . > /home/sdk/diffs/${_patchname}.diff
fi
set +x
doas chmod 666 /home/sdk/diffs/${_patchname}.diff
