forget_one()
{
- if cmp -s "$1" "$1~current~" && cmp -s "$1" "$1~orig~"
+ if true # || cmp -s "$1" "$1~current~" && cmp -s "$1" "$1~orig~"
then
rm -f "$1~current~" "$1~orig~"
chmod -w "$1"
{
>> .patches/files
while read file
- do eval $1 $file
+ do eval $1 $file $2
done < .patches/files
}
else
echo
echo "diff ./$1~current~ ./$1"
- diff -N --show-c-function -u ./$1~current~ ./$1
+ if [ " $2" = " -R" ]
+ then
+ diff -N --show-c-function -u ./$1 ./$1~current~
+ else
+ diff -N --show-c-function -u ./$1~current~ ./$1
+ fi
fi
}
mv "$1.tmp" "$1~current~"
}
-CERT='Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>'
+CERT='Signed-off-by: Neil Brown <neilb@suse.de>'
make_diff()
{
{
else echo "$CERT"
fi
echo
- all_files diff_one > .patches/tmp
+ all_files diff_one $1 > .patches/tmp
echo "### Diffstat output"
diffstat -p0 2> /dev/null < .patches/tmp
cat .patches/tmp
new=${new#1}
mv .patches/patch $dir/$new$name
}
-
+
find_prefix()
{
# set "prefix" to number for -pn by looking at first file in given patch.
awk '
BEGIN { head= 1; blanks=0 ; }
head == 1 && ( $1 == "Status:" || $0 == "" ) {
- next;
+ next;
}
{ head = 0; }
$0 == "" { blanks++; next; }
if [ ! -f "$pfile" ]
then echo >&2 "Cannot find unique patch '$1' - found: $pfile"; exit 1;
fi
- ${PAGER-less} $pfile;
+ if grep -s '^+.*[ ]$' $pfile > /dev/null
+ then
+ ${PAGER-less -p '^\+.*[ ]$'} $pfile
+ else
+ ${PAGER-less} $pfile
+ fi
;;
-
+
all )
all_files diff_one_orig
;;
status | name )
case $# in
- 1 )
+ 1 )
get_meta
if [ $cmd = name ] ; then
if [ -n "$name" ]; then
if [ -s .patches/patch ]
then :
else echo >&2 No patch to $cmd ; exit 1
+ fi
+ if grep -s '^+.*[ ]$' .patches/patch > /dev/null
+ then
+ echo >&2 remove trailing spaces/tabs first !!
+# exit 1
fi
if [ -s .patches/to-resolv ]
then echo "Please resolve outstanding conflicts first with 'p resolve'"
make_diff
get_meta
if [ -s .patches/patch ]
- then
+ then
echo >&2 Patch $name already open - please commit; exit 1;
fi
if [ $# -eq 0 ]
*/* ) echo >&2 "Only local patches can have been included"; exit 1 ;;
*) pfile=`echo .patches/removed/*$1*`
esac
- if [ ! -f "$pfile" ]
+ if [ ! -f "$pfile" ]
then echo >&2 "Cannot find unique patch '$1' - found $pfile"; exit 1
fi
echo "Using $pfile..."
save_patch included $name
echo "Moved to $new$name"
;;
+ review )
+ # there are some patches in .removed that may be included in the current source
+ # we try to backout each one. If it backs out successfully, we move it to
+ # .reviewed and conitnue, else we abort
+ # Once this has been done often enough, 'reviewed' should be run to
+ # move stuff to 'included' and to revert those patches
+ force=
+ if [ " $1" = " -f" ] ; then
+ force=yes; shift
+ fi
+ make_diff; get_meta
+ if [ -s .patches/path ]
+ then
+ echo >&2 Patch $name already open, please deal with it; exit 1;
+ fi
+ if [ $# -eq 0 ]
+ then
+ echo "Pending patches are:"
+ ls .patches/removed
+ exit 0;
+ fi
+ if [ $# -ne 1 ]
+ then
+ echo >&2 "Usage: p review patchname"; exit 1
+ fi
+ case $1 in
+ */* ) echo >&2 "Only local patches can have been included"; exit 1 ;;
+ *) pfile=`echo .patches/removed/*$1*`
+ esac
+ if [ ! -f "$pfile" ]
+ then echo >&2 "Cannot find unique patch '$1' - found $pfile"; exit 1
+ fi
+ echo "Starting from $pfile..."
+ found=
+ for fl in .patches/removed/*
+ do
+ if [ " $fl" = " $pfile" ]; then found=yes ; fi
+ if [ -n "$found" ]; then
+ echo Checking $fl
+ find_prefix "$fl"
+ lsdiff --strip=$prefix "$fl" | grep -v 'file.*changed' | while read a b
+ do check_out $a
+ done
+ if patch -s --fuzz=0 --dry-run -f -p$prefix -R < "$fl"
+ then echo Looks good..
+ elif [ -n "$force" ]
+ then echo "It doesn't backout cleanly, but you asked for it..."
+ cp $fl .patches/last-backed
+ else echo "Patch won't back out, sorry"
+ exit 1
+ fi
+ patch --fuzz=0 -f -p$prefix -R < "$fl" | tee .patches/tmp
+ sed -n -e '2q' -e 's/^Status: *//p' $fl > .patches/status
+ base=${fl##*/}
+ base=${base##[0-9][0-9][0-9]}
+ base=${base##patch-?-}
+ [ -s .patches/name ] || echo $base > .patches/name
+ extract_notes $fl >> .patches/notes
+ rm -f .patches/wiggled
+ sed -n -e 's/.*saving rejects to file \(.*\).rej/\1/p' .patches/tmp |
+ while read file
+ do echo Wiggling $file.rej into place
+ rm -f $file.porig
+ > .patches/wiggled
+ wiggle --replace --merge $file $file.rej ||
+ echo $file >> .patches/to-resolve
+ done
+
+ mv $fl .patches/patch
+ save_patch reviewed $base
+ if [ -f .patches/wiggled ]
+ then echo 'Some wiggling was needed. Please review and commit'
+ exit 0
+ fi
+ p commit || exit 1
+ fi
+ done
+ ;;
+
+ reviewed )
+ # all the currently applied patches are patches that have been
+ # reviewed as included.
+ # rip them out and stick them (reversed) into included.
+ while p open last
+ do
+ make_diff -R
+ get_meta
+ save_patch included "$name"
+ echo Saved as "$new$name"
+ all_files discard_one
+ rm -f .patches/name .patches/status .patches/notes
+ done
+ ;;
list )
echo "Applied patches are:"
ls .patches/applied
then echo >&2 "Cannot find unique patch '$1' - found: $pfile"; exit 1
fi
find_prefix "$pfile"
- lsdiff --strip=$prefix "$pfile" | grep -v 'file.*changed' | while read a b
+ lsdiff --strip=$prefix "$pfile" | grep -v 'file.*changed' | while read a b
do check_out $a
done
# lets see if it applies cleanly
if [ -f .patches/get-version ] ;
then ./.patches/get-version > $target/version
fi
- [ -f .config ] && cp .config $target
+ [ -f .config ] && cp .config $target
cp .patches/applied/* $target
mkdir $target/misc
cp 2> /dev/null .patches/removed/* $target/misc || rmdir $target/misc
make_diff
get_meta
if [ -s .patches/patch ]
- then
+ then
echo >&2 Patch $name already open - please commit; exit 1;
fi
p openall && p clean &&
if [ $cnt -gt 1 ]
then
{
- cat .patches/owner
+ if [ -s .patches/owner.$1 ] ; then
+ cat .patches/owner.$1
+ else
+ cat .patches/owner
+ fi
echo "To: `cat .patches/maintainer`"
if [ -s .patches/cc ] ; then
while read word prefix addr
do if [ " $word" = " $1" ] ; then
- echo "Cc: $addr"
- sprefix="$prefix "
+ echo "Cc: $addr"
+ sprefix="$prefix: "
fi
done < .patches/cc
fi
if [ $cnt = 1 ]
then
- echo "Subject: [PATCH] $sprefix Intro"
+ echo "Subject: [PATCH] ${sprefix}Intro"
else
- echo "Subject: [PATCH ${sprefix}0 of $cnt] Introduction"
+ echo "Subject: [PATCH 000 of $cnt] ${sprefix}Introduction"
fi
echo "Message-ID: $messid"
echo
if [ -n "$3" ] && [ $3 -lt $n ] ; then continue; fi
{
sprefix=
- cat .patches/owner
+ if [ -s .patches/owner.$1 ] ; then
+ cat .patches/owner.$1
+ else
+ cat .patches/owner
+ fi
echo "To: `cat .patches/maintainer`"
if [ -s .patches/cc ] ; then
while read word prefix addr
do if [ " $word" = " $1" ] ; then
- echo "Cc: $addr"
- sprefix="$prefix "
+ echo "Cc: $addr"
+ sprefix="$prefix: "
fi
done < .patches/cc
fi
head=`sed -e '/^Status/d' -e '/^$/d' -e q $patch`
+ zerothis=$(expr $this + 1000)
if [ $cnt = 1 ]
then
- echo "Subject: [PATCH $sprefix] $head"
+ echo "Subject: [PATCH] $sprefix$head"
else
- echo "Subject: [PATCH $sprefix$this of $cnt] $head"
+ echo "Subject: [PATCH ${zerothis#1} of $cnt] $sprefix$head"
fi
echo "References: $messid"
echo
} > .patches/mail/${patch#.patches/applied/}
this=$(expr $this + 1)
done
+ if [ -f .patches/mail/000Intro ]; then cat .patches/mail/* | sed -n -e 's/^Subject://p' >> .patches/mail/000Intro ; fi
ls .patches/mail
;;
;;
email )
- PATH=/usr/lib:/usr/sbin:$PATH
+ PATH=$HOME/bin:/usr/lib:/usr/sbin:$PATH
for i in .patches/mail/*
do
if [ -f "$i" ]