From: Paolo Bonzini <bonzini@gnu.org>
To: Sergio Callegari <sergio.callegari@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: Management of opendocument (openoffice.org) files in git
Date: Tue, 16 Sep 2008 10:12:44 +0200 [thread overview]
Message-ID: <48CF6A7C.4020604@gnu.org> (raw)
In-Reply-To: <48CF5ABC.5060507@gmail.com>
> With regards to
>
>> And maybe -b,-qq,-X and -q,-r respectively could be added by default?
>>
>>
> I would prefer not to do so: if you do you get something that is
> somehow "specialised", otherwise you have a totally generic "rezipper"
> that might also find other applications (who knows).
Yeah, but regarding -b/-X, their effect can/should be undone with zip
command line options (-l, -ll, -X). And for zip's -r option, a rezipper
that by default only rezips the top directory does not seem very useful. :-)
You're right about letting the user specify -qq/-q. Or maybe you can
have a -q/--quiet option to rezip that adds both -qq to unzip, and -q to
zip. This way you can use the openoffice profile both in quiet mode
(for git) and in non-quiet mode (for manual use).
Putting all of this together, it would make the filter look like this:
[filter "opendocument"]
clean = "rezip --quiet --zip-opts -D,-0"
smudge = "rezip --quiet --zip-opts -D,-6"
or similarly with profiles:
[filter "opendocument"]
clean = "rezip --quiet -p ODF_UNCOMPRESS"
smudge = "rezip --quiet -p ODF_COMPRESS"
After my signature you can find my attempt at making rezip more useful
as a general program. It supports --quiet, multiple input files, and -
for stdin. (And I learnt from you that >&$foo works).
> BTW, that is why I added the profiles, so that there was no need to type
> repetitive stuff.
Understood.
Paolo
-----8<-----------------------
#! /bin/sh
#
# (c) 2008 Sergio Callegari
#
# Rewrites a zip archive, possibly changing the compression level
USAGE='Usage: rezip OPTIONS FILE...
with options:
-h, --help Gives help
--unzip-opts OPTIONS Pass options to unzip helper to read zip file
--zip-opts OPTIONS Pass options to zip helper to write zip file
-p, --profile PROFILE Get options for helpers from profile
-q, --quiet Make unzip and zip quiet
Rewrites a zip archive, possibily changing the compression level.
If the archive name is unspecified or "-", then the command operates
like a filter, reading from standard input and writing to standard
output. Options (either space- or comma-separated) can be manually
provided to the unzip process doing the read and to the zip process
doing the write. Alternatively a profile can be used to set options
automatically.'
PROFILES="ODF_UNCOMPRESS ODF_COMPRESS"
PROFILE_UNZIP_ODF_UNCOMPRESS=
PROFILE_ZIP_ODF_UNCOMPRESS=-D,-0
PROFILE_UNZIP_ODF_COMPRESS=
PROFILE_ZIP_ODF_COMPRESS=-D,-6
die()
{
echo "$3$USAGE
Available profiles: ${PROFILES}" >&$1
exit $2
}
UNZIP_OPTS=""
ZIP_OPTS=""
while true ; do
case "$1" in
-h | --help)
die 1 0 ;;
# TODO: handle -p*, --profile=* and similarly for other options
-p | --profile)
eval UNZIP_OPTS=\$PROFILE_UNZIP_$2
eval ZIP_OPTS=\$PROFILE_ZIP_$2
shift ;;
--unzip-opts)
UNZIP_OPTS="${UNZIP_OPTS} $2"
shift ;;
--zip-opts)
ZIP_OPTS="${ZIP_OPTS} $2"
shift ;;
-q | --quiet)
UNZIP_QUIET=-qq
ZIP_QUIET=-q ;;
-*)
die 2 1 "Invalid option: $1
" ;;
*)
break ;;
esac
shift
done
UNZIP_OPTS="$UNZIP_QUIET -b -X `echo $UNZIP_OPTS | sed 'y/,/ /'`"
ZIP_OPTS="$ZIP_QUIET -r `echo $ZIP_OPTS | sed 'y/,/ /'`"
if [ $# = 0 ] ; then
set fnord -
shift
fi
redir=1
for filename
do
if [ "$filename" = - ]; then
redir=2
break
fi
done
for filename
do
workdir=`mktemp -d -t rezip.workdir.XXXXXX`
if [ "$filename" = - ]; then
tmpcopy=:
filename=`mktemp rezip.zip.XXXXXX`
cat > $filename
else
tmpcopy=false
fi
(case $filename in
/*) ;;
*) filename=`pwd`/$filename ;;
esac
cd "$workdir"
unzip $UNZIP_OPTS "$filename" >&$redir
zip $ZIP_OPTS "$filename" . >&$redir)
rm -fr "$workdir"
if $tmpcopy ; then
cat "$filename"
rm "$filename"
fi
done
--------8<------------------------
next prev parent reply other threads:[~2008-09-16 8:13 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-16 6:24 Management of opendocument (openoffice.org) files in git Paolo Bonzini
2008-09-16 7:05 ` Sergio Callegari
2008-09-16 8:12 ` Paolo Bonzini [this message]
2008-10-02 12:52 ` Michael J Gruber
2008-10-10 8:12 ` Peter Krefting
-- strict thread matches above, loose matches on Subject: below --
2008-09-15 22:40 Sergio Callegari
2008-09-16 6:45 ` Matthieu Moy
2008-09-16 7:41 ` Sergio Callegari
2008-09-16 7:09 ` Johannes Sixt
2008-09-16 7:41 ` Sergio Callegari
2008-09-16 7:52 ` Johannes Sixt
2008-09-16 16:04 ` Avery Pennarun
2008-09-16 19:28 ` Stephen R. van den Berg
2008-09-16 21:13 ` Robin Rosenberg
2008-09-23 11:08 ` Peter Krefting
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=48CF6A7C.4020604@gnu.org \
--to=bonzini@gnu.org \
--cc=git@vger.kernel.org \
--cc=sergio.callegari@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).