[Pkg-gnupg-commit] [gnupg2] 182/241: tools/gpgtar: Add '--dry-run'.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Dec 9 20:32:14 UTC 2015
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 676b2d7081291f7e47a66755ab07af259fea130b
Author: Justus Winter <justus at g10code.com>
Date: Thu Nov 26 17:05:12 2015 +0100
tools/gpgtar: Add '--dry-run'.
* tools/gpgtar-extract.c (extract_{regular,directory}): Honor
'--dry-run'.
* tools/gpgtar.c (enum cmd_and_opt_values): New value.
(opts): Add '--dry-run'.
(parse_arguments): Handle '--dry-run'.
* tools/gpgtar.h (opt): Add field 'dry_run'.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tools/gpgtar-extract.c | 7 +++++--
tools/gpgtar.c | 8 ++++++++
tools/gpgtar.h | 1 +
3 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/gpgtar-extract.c b/tools/gpgtar-extract.c
index 3b73c85..728737d 100644
--- a/tools/gpgtar-extract.c
+++ b/tools/gpgtar-extract.c
@@ -53,7 +53,10 @@ extract_regular (estream_t stream, const char *dirname,
else
err = 0;
- outfp = es_fopen (fname, "wb");
+ if (opt.dry_run)
+ outfp = es_fopenmem (0, "wb");
+ else
+ outfp = es_fopen (fname, "wb");
if (!outfp)
{
err = gpg_error_from_syserror ();
@@ -120,7 +123,7 @@ extract_directory (const char *dirname, tar_header_t hdr)
/* Note that we don't need to care about EEXIST because we always
extract into a new hierarchy. */
- if (gnupg_mkdir (fname, "-rwx------"))
+ if (! opt.dry_run && gnupg_mkdir (fname, "-rwx------"))
{
err = gpg_error_from_syserror ();
if (gpg_err_code (err) == GPG_ERR_ENOENT)
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index 90fee05..a46a339 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -77,6 +77,9 @@ enum cmd_and_opt_values
/* Compatibility with gpg-zip. */
oGpgArgs,
oTarArgs,
+
+ /* Debugging. */
+ oDryRun,
};
@@ -100,6 +103,7 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_n (oQuiet, "quiet", N_("be somewhat more quiet")),
ARGPARSE_s_s (oGpgProgram, "gpg", "@"),
ARGPARSE_s_n (oSkipCrypto, "skip-crypto", N_("skip the crypto processing")),
+ ARGPARSE_s_n (oDryRun, "dry-run", N_("do not make any changes")),
ARGPARSE_s_s (oSetFilename, "set-filename", "@"),
ARGPARSE_s_n (oOpenPGP, "openpgp", "@"),
ARGPARSE_s_n (oCMS, "cms", "@"),
@@ -377,6 +381,10 @@ parse_arguments (ARGPARSE_ARGS *pargs, ARGPARSE_OPTS *popts)
}
break;
+ case oDryRun:
+ opt.dry_run = 1;
+ break;
+
default: pargs->err = 2; break;
}
}
diff --git a/tools/gpgtar.h b/tools/gpgtar.h
index f130c94..eadbcac 100644
--- a/tools/gpgtar.h
+++ b/tools/gpgtar.h
@@ -29,6 +29,7 @@ struct
int verbose;
unsigned int debug_level;
int quiet;
+ int dry_run;
const char *gpg_program;
strlist_t gpg_arguments;
const char *outfile;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list