aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2024-02-08 16:22:09 -0800
committerJunio C Hamano <gitster@pobox.com>2024-02-08 16:22:09 -0800
commit2873a9686cf59ecbf851cea8c41e6ee545195423 (patch)
tree183afc678c81cc937cbcb67868ebe950452076d7
parentf5fa75af531ed2a0da396030ae0d0c651aeca62b (diff)
parent45184afb4d4a76a01483e086d9f0cf0af10a7286 (diff)
downloadgit-2873a9686cf59ecbf851cea8c41e6ee545195423.tar.gz
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
-rw-r--r--builtin/rebase.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 043c65dccd..44a9a3418e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -583,7 +583,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;
@@ -616,13 +615,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);
@@ -643,7 +635,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));
@@ -666,10 +663,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) {