Skip to content

Commit 3bdd552

Browse files
peffgitster
authored andcommitted
sequencer: use argv_array_pushf
This avoids a manual allocation calculation, and is shorter to boot. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a0279e1 commit 3bdd552

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

sequencer.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,18 +396,13 @@ static int run_git_commit(const char *defmsg, struct replay_opts *opts,
396396
{
397397
struct argv_array array;
398398
int rc;
399-
char *gpg_sign;
400399

401400
argv_array_init(&array);
402401
argv_array_push(&array, "commit");
403402
argv_array_push(&array, "-n");
404403

405-
if (opts->gpg_sign) {
406-
gpg_sign = xmalloc(3 + strlen(opts->gpg_sign));
407-
sprintf(gpg_sign, "-S%s", opts->gpg_sign);
408-
argv_array_push(&array, gpg_sign);
409-
free(gpg_sign);
410-
}
404+
if (opts->gpg_sign)
405+
argv_array_pushf(&array, "-S%s", opts->gpg_sign);
411406
if (opts->signoff)
412407
argv_array_push(&array, "-s");
413408
if (!opts->edit) {

0 commit comments

Comments
 (0)