[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: graphical diff'ing script

From: Ulrich Drepper <drepper_at_redhat.com>
Date: 2002-12-10 06:58:08 CET

Stepping in out of the blue, but I cannot resist seeing such a
potentially important part not being writtencorrectly:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>> dif=${DIFF:-xxdiff}
>>> # default geometry, works for the average X program
>>> geometry="-geometry 1000x400+0+0"
>>> # handle tkdiff not liking geometries
>>> [[ $dif = tkdiff ]] && geometry=""
>
> [[ $dif = meld ]] && geometry=""

Why the [[ ]] variant instead of plain [ ]? You're not using the
special features of this code. Besides, you want to write it like this:

case "${dif##*/}" in
  tkdiff|meld) geometry="" ;;
  *) geometry="-geometry 1000x400+0+0" ;;
esac

Important here is the readability of the exception handling and
comparing with the basename of $dif. The programs might be specified
with an absolute path.

>
>>> ###################################### end configurable stuff
>>>
>>> if [[ ! -d .svn ]]
>>> then
>>> echo ERROR: You are not in a SVN working copy directory.
>>> exit 1
>>> fi
>>> file=$1

Replace the following lines

>>> last=${file}_LasT
>>>
>>> trap "rm -f $last" 2 3 15
>>>
>>> svn cat $file > $last 2>/dev/null
>>> ${DIFF:-xxdiff} $geometry $last $file
>
> $dif $geometry $last $file
>
>>> rm -f $last

with

$dif $geometry <(svn cat $file 2>/dev/null) $file

No need to create a temporary file which has to be destroyed. And
especially no need to create it in the working directory. Just imagine
you want to figure out what changes a coworker of yours changed.

- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE99YJz2ijCOnn/RHQRApVOAJ9we94n1LGKq3bjCyp3eZTX7/Pe6QCfamZs
g+9OI6RlMWDLT4yC/jS4p1Y=
=GvQm
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Dec 10 06:58:37 2002

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.