]> git.ipfire.org Git - thirdparty/git.git/blobdiff - sequencer.c
strmap: enable allocations to come from a mem_pool
[thirdparty/git.git] / sequencer.c
index 3367eb5fbfb0448de4ab0dddb0d6f071f5f15944..23a09c3e7abe5122364e3da4d145bf1a4513d7a2 100644 (file)
@@ -249,11 +249,20 @@ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob,
        struct trailer_info info;
        size_t i;
        int found_sob = 0, found_sob_last = 0;
+       char saved_char;
 
        opts.no_divider = 1;
 
+       if (ignore_footer) {
+               saved_char = sb->buf[sb->len - ignore_footer];
+               sb->buf[sb->len - ignore_footer] = '\0';
+       }
+
        trailer_info_get(&info, sb->buf, &opts);
 
+       if (ignore_footer)
+               sb->buf[sb->len - ignore_footer] = saved_char;
+
        if (info.trailer_start == info.trailer_end)
                return 0;
 
@@ -934,8 +943,7 @@ static int run_command_silent_on_success(struct child_process *cmd)
  * interactive rebase: in that case, we will want to retain the
  * author metadata.
  */
-static int run_git_commit(struct repository *r,
-                         const char *defmsg,
+static int run_git_commit(const char *defmsg,
                          struct replay_opts *opts,
                          unsigned int flags)
 {
@@ -1545,7 +1553,7 @@ static int do_commit(struct repository *r,
                if (is_rebase_i(opts) && oid)
                        if (write_rebase_head(oid))
                            return -1;
-               return run_git_commit(r, msg_file, opts, flags);
+               return run_git_commit(msg_file, opts, flags);
        }
 
        return res;
@@ -2060,7 +2068,7 @@ static int do_pick_commit(struct repository *r,
                *check_todo = !!(flags & EDIT_MSG);
                if (!res && reword) {
 fast_forward_edit:
-                       res = run_git_commit(r, NULL, opts, EDIT_MSG |
+                       res = run_git_commit(NULL, opts, EDIT_MSG |
                                             VERIFY_MSG | AMEND_MSG |
                                             (flags & ALLOW_EMPTY));
                        *check_todo = 1;
@@ -3749,7 +3757,7 @@ static int do_merge(struct repository *r,
                 * command needs to be rescheduled).
                 */
        fast_forward_edit:
-               ret = !!run_git_commit(r, git_path_merge_msg(r), opts,
+               ret = !!run_git_commit(git_path_merge_msg(r), opts,
                                       run_commit_flags);
 
 leave_merge:
@@ -4438,7 +4446,7 @@ static int commit_staged_changes(struct repository *r,
                        return 0;
        }
 
-       if (run_git_commit(r, final_fixup ? NULL : rebase_path_message(),
+       if (run_git_commit(final_fixup ? NULL : rebase_path_message(),
                           opts, flags))
                return error(_("could not commit staged changes."));
        unlink(rebase_path_amend());
@@ -5050,7 +5058,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
 
        oidmap_free(&commit2todo, 1);
        oidmap_free(&state.commit2label, 1);
-       hashmap_free_entries(&state.labels, struct labels_entry, entry);
+       hashmap_clear_and_free(&state.labels, struct labels_entry, entry);
        strbuf_release(&state.buf);
 
        return 0;
@@ -5569,7 +5577,7 @@ int todo_list_rearrange_squash(struct todo_list *todo_list)
        for (i = 0; i < todo_list->nr; i++)
                free(subjects[i]);
        free(subjects);
-       hashmap_free_entries(&subject2item, struct subject2item_entry, entry);
+       hashmap_clear_and_free(&subject2item, struct subject2item_entry, entry);
 
        clear_commit_todo_item(&commit_todo);