]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: use rebase_path_message()
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Wed, 6 Sep 2023 15:22:47 +0000 (15:22 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Sep 2023 17:29:43 +0000 (10:29 -0700)
Rather than constructing the path in a struct strbuf use the ready
made function to get the path name instead. This was the last
remaining use of the strbuf so remove it as well.

As with the previous patch we now use a hard coded string rather than
git_dir() when constructing the path. This is safe for the same
reason (make_patch() is only called when rebasing) and is protected by
the assertion added in the previous patch.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c

index 61c12d4f2bc35ece91f6e47475d931e660595bbd..cf45597d4fe21a3d77aa5d6465f29de0dd3f8450 100644 (file)
@@ -3484,7 +3484,6 @@ static int make_patch(struct repository *r,
                      struct commit *commit,
                      struct replay_opts *opts)
 {
-       struct strbuf buf = STRBUF_INIT;
        struct rev_info log_tree_opt;
        const char *subject;
        char hex[GIT_MAX_HEXSZ + 1];
@@ -3515,18 +3514,16 @@ static int make_patch(struct repository *r,
                fclose(log_tree_opt.diffopt.file);
        }
 
-       strbuf_addf(&buf, "%s/message", get_dir(opts));
-       if (!file_exists(buf.buf)) {
+       if (!file_exists(rebase_path_message())) {
                const char *encoding = get_commit_output_encoding();
                const char *commit_buffer = repo_logmsg_reencode(r,
                                                                 commit, NULL,
                                                                 encoding);
                find_commit_subject(commit_buffer, &subject);
-               res |= write_message(subject, strlen(subject), buf.buf, 1);
+               res |= write_message(subject, strlen(subject), rebase_path_message(), 1);
                repo_unuse_commit_buffer(r, commit,
                                         commit_buffer);
        }
-       strbuf_release(&buf);
        release_revisions(&log_tree_opt);
 
        return res;