Skip to content

Commit 2873a96

Browse files
committed
Merge branch 'rs/rebase-use-strvec-pushf' into maint-2.43
Code clean-up. * rs/rebase-use-strvec-pushf: rebase: use strvec_pushf() for format-patch revisions
2 parents f5fa75a + 45184af commit 2873a96

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
@@ -583,7 +583,6 @@ static int run_am(struct rebase_options *opts)
583583
{
584584
struct child_process am = CHILD_PROCESS_INIT;
585585
struct child_process format_patch = CHILD_PROCESS_INIT;
586-
struct strbuf revisions = STRBUF_INIT;
587586
int status;
588587
char *rebased_patches;
589588

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

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

669-
strbuf_release(&revisions);
670666
return status;
671667
}
672-
strbuf_release(&revisions);
673668

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

0 commit comments

Comments
 (0)