patchfs update
- From: Padraig Brady <padraig antefacto com>
- To: mc-devel gnome org
- Subject: patchfs update
- Date: Thu, 30 May 2002 17:58:11 +0100
Hi I've attached a new
patchfs module which has the following changes:
1. Handles patches than were done on file(s) and not just directories
2. Only (and explicitly) handles unified format patches
3. Only creates the SUMMARY file when required (it was previously FILELIST)
comments appreciated.
cheers,
Padraig.
#! /bin/sh
# Peter Daum <gator cs tu-berlin de> (Jan 1998, mc-4.1.22)
#
# Initial implementation.
#
# Padraig Brady <padraig linux ie> (May 2002, mc-4.5.51)
#
# Added support for unified diffs of files and not just directories,
# i.e. when there is no "diff date file1 file2" line. Note patchfs
# does not support context or "default" format diffs at present,
# only unified format. Also cleaned up, and only displayed the
# special file SUMMARY when required (it wa origonally called FILELIST).
#
# override any locale for dates. But LANG override LC_TIME (at least in glibc)
# unset LC_ALL
# LC_TIME=C
# export LC_TIME
LC_ALL=C
export LC_ALL
filelist=SUMMARY # names for "special" files
patchfs_list ()
{
date=`date +"%b %d %H:%M"`
perm="-r--r--r--"
uid=00000000
gid=00000000
size=00000000
nlink=" 1"
if ! $cat $1 | grep -q '^+++'; then #don't display anything if not unified diff
echo "$perm $nlink $uid $gid $size $date ERROR-NOT-IN-UNIFIED-FORMAT"
exit 1
fi
if $cat $1 | grep -Eq '^\+\+\+ [^ ]+/[^ ]+'; then #files in different dirs, so summarise
echo "$perm $nlink $uid $gid $size $date $filelist"
fi
$cat $1 |
sed -n "s/^+++ \([^ ]*\).*/$perm $nlink $uid $gid $size $date \1/gp"
}
patchfs_copyout ()
{
if [ "$2" = "ERROR-NOT-IN-UNIFIED-FORMAT" ]; then
exit 1
fi
if [ "$2" = "$filelist" ]; then # list of all affected files
$cat $1 |
sed -n "s/^+++ \([^ ]*\).*/\1/gp" > $3
exit 0
fi
fn=`echo $2 | sed 's|/|\\\/|g'` # escape '/' in filename
$cat $1 |
sed -e '/^diff /d' |
sed -ne "/^+++ .*$fn/,/^--- /{
/^--- /d
p
}" > $3
}
patchfs_run ()
{
exit 0
}
type=`file $2`
case $type in
*bzip*) cat="bzip2 -dc" ;;
*gzip*) cat="gzip -dc" ;;
*text*) cat="cat" ;;
*) exit 1
esac
umask 077
case "$1" in
list) patchfs_list $2; exit 0;;
copyout) patchfs_copyout $2 $3 $4; exit 0;;
run) patchfs_run; exit 0;;
esac
exit 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]