Skip to content

Commit 9cc7100

Browse files
committed
Merge branch 'rs/rebase-use-strvec-pushf'
Code clean-up. * rs/rebase-use-strvec-pushf: rebase: use strvec_pushf() for format-patch revisions
2 parents 72e6a61 + 45184af commit 9cc7100

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

builtin/rebase.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ static int run_am(struct rebase_options *opts)
582582
{
583583
struct child_process am = CHILD_PROCESS_INIT;
584584
struct child_process format_patch = CHILD_PROCESS_INIT;
585-
struct strbuf revisions = STRBUF_INIT;
586585
int status;
587586
char *rebased_patches;
588587

@@ -615,13 +614,6 @@ static int run_am(struct rebase_options *opts)
615614
return run_command(&am);
616615
}
617616

618-
strbuf_addf(&revisions, "%s...%s",
619-
oid_to_hex(opts->root ?
620-
/* this is now equivalent to !opts->upstream */
621-
&opts->onto->object.oid :
622-
&opts->upstream->object.oid),
623-
oid_to_hex(&opts->orig_head->object.oid));
624-
625617
rebased_patches = xstrdup(git_path("rebased-patches"));
626618
format_patch.out = open(rebased_patches,
627619
O_WRONLY | O_CREAT | O_TRUNC, 0666);
@@ -642,7 +634,12 @@ static int run_am(struct rebase_options *opts)
642634
if (opts->git_format_patch_opt.len)
643635
strvec_split(&format_patch.args,
644636
opts->git_format_patch_opt.buf);
645-
strvec_push(&format_patch.args, revisions.buf);
637+
strvec_pushf(&format_patch.args, "%s...%s",
638+
oid_to_hex(opts->root ?
639+
/* this is now equivalent to !opts->upstream */
640+
&opts->onto->object.oid :
641+
&opts->upstream->object.oid),
642+
oid_to_hex(&opts->orig_head->object.oid));
646643
if (opts->restrict_revision)
647644
strvec_pushf(&format_patch.args, "^%s",
648645
oid_to_hex(&opts->restrict_revision->object.oid));
@@ -665,10 +662,8 @@ static int run_am(struct rebase_options *opts)
665662
"As a result, git cannot rebase them."),
666663
opts->revisions);
667664

668-
strbuf_release(&revisions);
669665
return status;
670666
}
671-
strbuf_release(&revisions);
672667

673668
am.in = open(rebased_patches, O_RDONLY);
674669
if (am.in < 0) {

0 commit comments

Comments
 (0)