Thread (17 messages) flat view 17 messages, 4 authors, 2016-06-15
STALE3734d

[PATCH v2 07/10] sequencer: use argv_array_pushf

From: Jeff King <hidden>
Date: 2016-06-15 23:01:42
Subsystem: the rest · Maintainer: Linus Torvalds

This avoids a manual allocation calculation, and is shorter
to boot.

Signed-off-by: Jeff King <redacted>
---
 sequencer.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 0a80c58..2fea824 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -396,18 +396,13 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
 {
 	struct argv_array array;
 	int rc;
-	char *gpg_sign;
 
 	argv_array_init(&array);
 	argv_array_push(&array, "commit");
 	argv_array_push(&array, "-n");
 
-	if (opts->gpg_sign) {
-		gpg_sign = xmalloc(3 + strlen(opts->gpg_sign));
-		sprintf(gpg_sign, "-S%s", opts->gpg_sign);
-		argv_array_push(&array, gpg_sign);
-		free(gpg_sign);
-	}
+	if (opts->gpg_sign)
+		argv_array_pushf(&array, "-S%s", opts->gpg_sign);
 	if (opts->signoff)
 		argv_array_push(&array, "-s");
 	if (!opts->edit) {
-- 
2.0.0.566.gfe3e6b2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help