From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Michael J Gruber <git@drmicha.warpmail.net>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 1/7] gpg-interface: use child_process.args
Date: Thu, 16 Jun 2016 05:33:29 -0400 [thread overview]
Message-ID: <20160616093328.GA15851@sigill.intra.peff.net> (raw)
In-Reply-To: <20160616093248.GA15130@sigill.intra.peff.net>
Our argv allocations are relatively straightforward, but
this avoids us having to manually keep the count up to date
(or create new to-be-replaced slots in the declaration) when
we add new arguments.
Signed-off-by: Jeff King <peff@peff.net>
---
gpg-interface.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/gpg-interface.c b/gpg-interface.c
index c4b1e8c..0ed9fa7 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -150,17 +150,15 @@ const char *get_signing_key(void)
int sign_buffer(struct strbuf *buffer, struct strbuf *signature, const char *signing_key)
{
struct child_process gpg = CHILD_PROCESS_INIT;
- const char *args[4];
ssize_t len;
size_t i, j, bottom;
- gpg.argv = args;
gpg.in = -1;
gpg.out = -1;
- args[0] = gpg_program;
- args[1] = "-bsau";
- args[2] = signing_key;
- args[3] = NULL;
+ argv_array_pushl(&gpg.args,
+ gpg_program,
+ "-bsau", signing_key,
+ NULL);
if (start_command(&gpg))
return error(_("could not run gpg."));
@@ -210,13 +208,11 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
struct strbuf *gpg_output, struct strbuf *gpg_status)
{
struct child_process gpg = CHILD_PROCESS_INIT;
- const char *args_gpg[] = {NULL, "--status-fd=1", "--verify", "FILE", "-", NULL};
char path[PATH_MAX];
int fd, ret;
struct strbuf buf = STRBUF_INIT;
struct strbuf *pbuf = &buf;
- args_gpg[0] = gpg_program;
fd = git_mkstemp(path, PATH_MAX, ".git_vtag_tmpXXXXXX");
if (fd < 0)
return error_errno(_("could not create temporary file '%s'"), path);
@@ -224,12 +220,15 @@ int verify_signed_buffer(const char *payload, size_t payload_size,
return error_errno(_("failed writing detached signature to '%s'"), path);
close(fd);
- gpg.argv = args_gpg;
+ argv_array_pushl(&gpg.args,
+ gpg_program,
+ "--status-fd=1",
+ "--verify", path, "-",
+ NULL);
gpg.in = -1;
gpg.out = -1;
if (gpg_output)
gpg.err = -1;
- args_gpg[3] = path;
if (start_command(&gpg)) {
unlink(path);
return error(_("could not run gpg."));
--
2.9.0.160.g4984cba
next prev parent reply other threads:[~2016-06-16 9:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-16 9:32 [PATCH 0/7] gpg-interface cleanups Jeff King
2016-06-16 9:33 ` Jeff King [this message]
2016-06-16 9:34 ` [PATCH 2/7] verify_signed_buffer: drop pbuf variable Jeff King
2016-06-16 9:35 ` [PATCH 3/7] verify_signed_buffer: use tempfile object Jeff King
2016-06-16 9:37 ` [PATCH 4/7] run-command: add pipe_command helper Jeff King
2016-06-17 20:03 ` Eric Sunshine
2016-06-17 23:28 ` Jeff King
2016-06-17 23:31 ` Eric Sunshine
2016-06-16 9:38 ` [PATCH 5/7] verify_signed_buffer: use pipe_command Jeff King
2016-06-16 9:39 ` [PATCH 6/7] sign_buffer: " Jeff King
2016-06-16 9:42 ` [PATCH 7/7] gpg-interface: check gpg signature creation status Jeff King
2016-06-16 18:20 ` [PATCH 0/7] gpg-interface cleanups Junio C Hamano
2016-06-17 9:20 ` Michael J Gruber
2016-06-17 9:21 ` Jeff King
2016-06-17 23:38 ` [PATCH v2 " Jeff King
2016-06-17 23:38 ` [PATCH v2 1/7] gpg-interface: use child_process.args Jeff King
2016-06-17 23:38 ` [PATCH v2 2/7] verify_signed_buffer: drop pbuf variable Jeff King
2016-06-17 23:38 ` [PATCH v2 3/7] verify_signed_buffer: use tempfile object Jeff King
2016-06-17 23:38 ` [PATCH v2 4/7] run-command: add pipe_command helper Jeff King
2016-06-17 23:38 ` [PATCH v2 5/7] verify_signed_buffer: use pipe_command Jeff King
2016-06-17 23:38 ` [PATCH v2 6/7] sign_buffer: " Jeff King
2016-06-17 23:38 ` [PATCH v2 7/7] gpg-interface: check gpg signature creation status Jeff King
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=20160616093328.GA15851@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@drmicha.warpmail.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).