diff options
author | Junio C Hamano <gitster@pobox.com> | 2024-01-03 00:51:29 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-01-03 00:51:29 +0300 |
commit | 9cc710098bb9aa3efcefcb5237d001ed09a52e50 (patch) | |
tree | c85eea49a2510e0b66bd1721315aff6dfa67d415 /builtin | |
parent | 72e6a61c403c61bd5b78e0284a4aa3315aeb1f7c (diff) | |
parent | 45184afb4d4a76a01483e086d9f0cf0af10a7286 (diff) |
Merge branch 'rs/rebase-use-strvec-pushf'
Code clean-up.
* rs/rebase-use-strvec-pushf:
rebase: use strvec_pushf() for format-patch revisions
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/rebase.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c index 9f8192e0a5..ddde4cbb87 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -582,7 +582,6 @@ static int run_am(struct rebase_options *opts) { struct child_process am = CHILD_PROCESS_INIT; struct child_process format_patch = CHILD_PROCESS_INIT; - struct strbuf revisions = STRBUF_INIT; int status; char *rebased_patches; @@ -615,13 +614,6 @@ static int run_am(struct rebase_options *opts) return run_command(&am); } - strbuf_addf(&revisions, "%s...%s", - oid_to_hex(opts->root ? - /* this is now equivalent to !opts->upstream */ - &opts->onto->object.oid : - &opts->upstream->object.oid), - oid_to_hex(&opts->orig_head->object.oid)); - rebased_patches = xstrdup(git_path("rebased-patches")); format_patch.out = open(rebased_patches, O_WRONLY | O_CREAT | O_TRUNC, 0666); @@ -642,7 +634,12 @@ static int run_am(struct rebase_options *opts) if (opts->git_format_patch_opt.len) strvec_split(&format_patch.args, opts->git_format_patch_opt.buf); - strvec_push(&format_patch.args, revisions.buf); + strvec_pushf(&format_patch.args, "%s...%s", + oid_to_hex(opts->root ? + /* this is now equivalent to !opts->upstream */ + &opts->onto->object.oid : + &opts->upstream->object.oid), + oid_to_hex(&opts->orig_head->object.oid)); if (opts->restrict_revision) strvec_pushf(&format_patch.args, "^%s", oid_to_hex(&opts->restrict_revision->object.oid)); @@ -665,10 +662,8 @@ static int run_am(struct rebase_options *opts) "As a result, git cannot rebase them."), opts->revisions); - strbuf_release(&revisions); return status; } - strbuf_release(&revisions); am.in = open(rebased_patches, O_RDONLY); if (am.in < 0) { |