pkgsrc/pkgtools/pkgdiff/files/pkgdiff
seb a47d96ceb9 Update to version 0.118: pkgdiff fix and tuning.
Fix the automagic tuning of the number of unified diff context
lines.  It was broken since previous commit to files/pkgdiff.

Also arguments '-u' and '-U NUM' to GNU diffutils 2.8.1, as seen
in NetBSD 2.0_STABLE and current, are not intended to be used
together. Hence only '-U NUM' is now specified. I did not reverted
to the '-u -NUM' form used before as it seems undesirable.

Please note that if PKGDIFF_FMT is specified in the environment,
for testing or debugging purposes, we skip the automagic tuning of
the number of unified diff context lines.  The user probably wants
to try another diff format, as suggested in the commit log of
revision 1.12 of files/pkgdiff. So there is no point in adding '-U
NUM' to PKGDIFF_FMT: it may just not work. See:

$ diff -c -U 1 /dev/null /dev/null
diff: conflicting output style options
diff: Try `diff --help' for more information.

While here save a few basename(1) runs.
2005-08-02 12:16:19 +00:00

65 lines
1.5 KiB
Text
Executable file

#!@SH@
#
# $NetBSD: pkgdiff,v 1.16 2005/08/02 12:16:19 seb Exp $
#
# Usage: pkgdiff newfile
# pkgdiff oldfile newfile
#
# Will output a patch ready for the NetBSD Pkgs Collection (unified
# diff, plus no RCS IDs if possible). If only newfile is given,
# oldfile is assumed as newfile.orig.
#
# Copyright (c) 2000 by Hubert Feyrer <hubertf@netbsd.org>
# All Rights Reserved. Absolutely no warranty.
#
if [ $# -le 1 ]
then
if [ -f "$1.orig" ]; then
old="$1.orig"
new="$1"
else
echo $0: need at least one argument >&2
exit 1;
fi
else
old="$1"
new="$2"
fi
basename_new="`basename $new`"
dodiff() {
case x"$basename_new" in
xconfigure)
@DIFF@ -I '\(echo .*as_me:[0-9][0-9]*:\|echo .*configure:[0-9][0-9]*:\|line [0-9][0-9]* "configure\)' $*
;;
*)
@DIFF@ $*
esac
}
case x"$PKGDIFF_FMT" in x)
lines=3
PKGDIFF_FMT="-p"
while [ `dodiff "$PKGDIFF_FMT" -U $lines "$old" "$new" | egrep -c '\\$(NetBSD|Author|Date|Header|Id|Locker|Log|Name|RCSfile|Revision|Source|State)(:.*)?\\$'` != 0 ]
do
lines=`expr $lines - 1`
if [ $lines = 0 ]; then
echo "Cannot strip away RCS IDs, please handle manually!" >&2
exit 1
fi
done
PKGDIFF_FMT="${PKGDIFF_FMT} -U $lines"
;;
esac # PKGDIFF_FMT unset or null
if dodiff -q "$PKGDIFF_FMT" "$old" "$new" > /dev/null
then
:
else
echo '$'NetBSD'$'
echo ''
# Strip out the date on the +++ line to reduce needless
# differences in regenerated patches
dodiff "$PKGDIFF_FMT" "$old" "$new" | sed -e 's:^\(+++ [^ ]*\) .*:\1:'
fi