From: "K.R. Foley" <kr@cybsft.com>
To: randy_dunlap <rdunlap@xenotime.net>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: [announce] 'patchview' script
Date: Tue, 19 Jul 2005 16:36:32 -0500 [thread overview]
Message-ID: <42DD7260.1060905@cybsft.com> (raw)
In-Reply-To: <20050719115103.3e10ce0a.rdunlap@xenotime.net>
[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]
randy_dunlap wrote:
> Hi,
>
> Someone asked me about a tool like this and I didn't know of one,
> so I made this little script.
>
> 'patchview' merges a patch file and a source tree to a set of
> temporary modified files. This enables better patch (re)viewing
> and more viewable context. (hopefully)
>
> Are there already other tools that do something similar to this?
> (other than SCMs)
>
>
> The patchview script is here:
> http://www.xenotime.net/linux/scripts/patchview
>
> usage: patchview [-f] patchfile srctree
> -f : force tkdiff even if 'patch' has errors
>
>
> It uses (requires) lsdiff (from patchutils) and tkdiff.
>
> patchutils: http://cyberelk.net/tim/patchutils/
> tkdiff: http://sourceforge.net/projects/tkdiff/
>
> ---
> ~Randy
Randy,
As Nick already pointed out, mktemp fails if the parent dir doesn't
exist. The attached patch tries to create the parent if it doesn't
exist. It also accepts a [-s] argument to bring up a single viewer at a
time. Otherwise, if there are many different files being touched by the
patch it dies a horrible death on my machine. Nice utility, btw.
--
kr
[-- Attachment #2: patchview.patch01 --]
[-- Type: text/plain, Size: 2042 bytes --]
--- patchview.orig 2005-07-19 16:08:21.000000000 -0500
+++ patchview 2005-07-19 16:30:07.000000000 -0500
@@ -3,7 +3,6 @@
# License: GPL v2.
#
# uses patchutils (lsdiff) and tkdiff
-
# returns 'base'
function strip_filename()
{
@@ -25,20 +24,55 @@
}
force=0
-patchfile=$1
-srctree=$2
+single=0
VIEWER="tkdiff"
# or maybe "sh -c colordiff" would work
-if [ "$patchfile" == "-f" ]; then
- force=1
- patchfile=$2
- srctree=$3
-fi
+while [ -n "$1" ]
+do
+ case $1 in
+ -f)
+ force=1
+ ;;
+
+ -s)
+ single=1
+ ;;
+ -*)
+ if [ "${1#-}" = '?' ]
+ then
+ echo "usage: patchview [-f] [-s] patchfile srctree"
+ echo " -f : force tkdiff even if 'patch' has errors"
+ echo " -s : single tkdiff even if 'patch' contains multiple files"
+ exit 0
+ fi
+ ;;
+
+ *)
+ # Accept filename or report a warning
+ if [ -z "${patchfile}" ]
+ then
+ patchfile=$1
+ srctree=$2
+ break
+ else
+ echo "usage: patchview [-f] [-s] patchfile srctree"
+ echo " -f : force tkdiff even if 'patch' has errors"
+ echo " -s : single tkdiff even if 'patch' contains multiple files"
+ exit 0
+ fi
+ ;;
+ esac
+
+ # Shift argument 2 into argument 1's slot. Loop to check the argument.
+ shift
+done
+
if [ "$patchfile" = "" -o "$srctree" = "" ]; then
echo "usage: patchview [-f] patchfile srctree"
echo " -f : force tkdiff even if 'patch' has errors"
+ echo " -s : single tkdiff even if 'patch' contains multiple files"
exit 1
fi
@@ -48,6 +82,10 @@
else
TMPDIR=/tmp
fi
+if [ ! -d ${TMPDIR}/XXXXXX ];then
+ mkdir ${TMPDIR}/XXXXXX || echo "failed mktemp for patch files dir."
+fi
+
WORKDIR=`mktemp -d -p ${TMPDIR}/XXXXXX` || echo "failed mktemp for patch files dir."
pfiles=`lsdiff --strip 1 $patchfile`
@@ -73,8 +111,13 @@
for pf in $pfiles ; do
$VIEWER $WORKDIR/$pf.orig $WORKDIR/$pf &
+ if [ ${single} -eq 1 ];then
+ wait # for viewer to exit
+ fi
done
-wait # for all viewers to exit
+if [ ${single} -eq 0 ];then
+ wait # for all viewers to exit
+fi
rm -rf $WORKDIR
prev parent reply other threads:[~2005-07-19 21:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-19 18:51 [announce] 'patchview' script randy_dunlap
2005-07-19 20:11 ` Nick Wilson
2005-07-19 20:20 ` Jan Engelhardt
2005-07-19 21:36 ` K.R. Foley [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=42DD7260.1060905@cybsft.com \
--to=kr@cybsft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@xenotime.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.