revisions API users: add straightforward release_revisions()

Add a release_revisions() to various users of "struct rev_list" in
those straightforward cases where we only need to add the
release_revisions() call to the end of a block, and don't need to
e.g. refactor anything to use a "goto cleanup" pattern.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason 2022-04-13 22:01:36 +02:00 committed by Junio C Hamano
parent 1878b5edc0
commit 2108fe4a19
28 changed files with 39 additions and 0 deletions

View File

@ -570,6 +570,7 @@ static int get_modified_files(struct repository *r,
if (ps)
clear_pathspec(&rev.prune_data);
release_revisions(&rev);
}
hashmap_clear_and_free(&s.file_map, struct pathname_entry, ent);
if (unmerged_count)

View File

@ -884,6 +884,7 @@ static int check_ancestors(struct repository *r, int rev_nr,
/* Clean up objects used, as they will be reused. */
clear_commit_marks_many(rev_nr, rev, ALL_REV_FLAGS);
release_revisions(&revs);
return res;
}
@ -964,6 +965,7 @@ static void show_diff_tree(struct repository *r,
setup_revisions(ARRAY_SIZE(argv) - 1, argv, &opt, NULL);
log_tree_commit(&opt, commit);
release_revisions(&opt);
}
/*

View File

@ -340,6 +340,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
unlink(file);
free(file);
release_revisions(&rev);
return 0;
}

View File

@ -1397,6 +1397,7 @@ static void write_commit_patch(const struct am_state *state, struct commit *comm
add_pending_object(&rev_info, &commit->object, "");
diff_setup_done(&rev_info.diffopt);
log_tree_commit(&rev_info, commit);
release_revisions(&rev_info);
}
/**
@ -1429,6 +1430,7 @@ static void write_index_patch(const struct am_state *state)
add_pending_object(&rev_info, &tree->object, "");
diff_setup_done(&rev_info.diffopt);
run_diff_index(&rev_info, 1);
release_revisions(&rev_info);
}
/**
@ -1582,6 +1584,7 @@ static int fall_back_threeway(const struct am_state *state, const char *index_pa
add_pending_oid(&rev_info, "HEAD", &our_tree, 0);
diff_setup_done(&rev_info.diffopt);
run_diff_index(&rev_info, 1);
release_revisions(&rev_info);
}
if (run_apply(state, index_path))

View File

@ -555,6 +555,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
reset_revision_walk();
strbuf_release(&commit_name);
release_revisions(&revs);
fclose(fp);
return 0;
}
@ -1041,6 +1042,7 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
oid_to_hex(&commit->object.oid));
reset_revision_walk();
release_revisions(&revs);
} else {
strvec_push(&argv_state, argv[i]);
}

View File

@ -1203,5 +1203,6 @@ parse_done:
cleanup:
cleanup_scoreboard(&sb);
release_revisions(&revs);
return 0;
}

View File

@ -1082,6 +1082,7 @@ static void orphaned_commit_warning(struct commit *old_commit, struct commit *ne
/* Clean up objects used, as they will be reused. */
repo_clear_commit_marks(the_repository, ALL_REV_FLAGS);
release_revisions(&revs);
}
static int switch_branches(const struct checkout_opts *opts,

View File

@ -1123,6 +1123,7 @@ static const char *find_author_by_nickname(const char *name)
strbuf_release(&buf);
format_commit_message(commit, "%aN <%aE>", &buf, &ctx);
clear_mailmap(&mailmap);
release_revisions(&revs);
return strbuf_detach(&buf, NULL);
}
die(_("--author '%s' is not 'Name <email>' and matches no existing author"), name);

View File

@ -517,6 +517,7 @@ static void describe_blob(struct object_id oid, struct strbuf *dst)
traverse_commit_list(&revs, process_commit, process_object, &pcd);
reset_revision_walk();
release_revisions(&revs);
}
static void describe(const char *arg, int last_one)
@ -667,6 +668,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
suffix = NULL;
else
suffix = dirty;
release_revisions(&revs);
}
describe("HEAD", 1);
} else if (dirty) {

View File

@ -1275,6 +1275,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
printf("done\n");
refspec_clear(&refspecs);
release_revisions(&revs);
return 0;
}

View File

@ -443,6 +443,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
}
write_file_buf(git_path_squash_msg(the_repository), out.buf, out.len);
strbuf_release(&out);
release_revisions(&rev);
}
static void finish(struct commit *head_commit,
@ -998,6 +999,7 @@ static int evaluate_result(void)
*/
cnt += count_unmerged_entries();
release_revisions(&rev);
return cnt;
}

View File

@ -4167,11 +4167,13 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
read_object_list_from_stdin();
} else if (pfd.have_revs) {
get_object_list(&pfd.revs, rp.nr, rp.v);
release_revisions(&pfd.revs);
} else {
struct rev_info revs;
repo_init_revisions(the_repository, &revs, NULL);
get_object_list(&revs, rp.nr, rp.v);
release_revisions(&revs);
}
cleanup_preferred_base();
if (include_tag && nr_result)

View File

@ -196,5 +196,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
prune_shallow(show_only ? PRUNE_SHOW_ONLY : 0);
}
release_revisions(&revs);
return 0;
}

View File

@ -248,6 +248,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
if (verbose)
printf(_("Marking reachable objects..."));
mark_reachable_objects(&revs, 0, 0, NULL);
release_revisions(&revs);
if (verbose)
putchar('\n');
}

View File

@ -422,6 +422,8 @@ parse_done:
else
get_from_rev(&rev, &log);
release_revisions(&rev);
shortlog_output(&log);
if (log.file != stdout)
fclose(log.file);

View File

@ -1269,6 +1269,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
run_diff_files(&rev, 0);
prepare_submodule_summary(info, &list);
strvec_clear(&diff_args);
release_revisions(&rev);
return 0;
}

View File

@ -699,6 +699,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
shortlog(origins.items[i].string,
origins.items[i].util,
head, &rev, opts, out);
release_revisions(&rev);
}
strbuf_complete_line(out);

View File

@ -1594,6 +1594,7 @@ static int find_first_merges(struct repository *repo,
}
object_array_clear(&merges);
release_revisions(&revs);
return result->nr;
}

View File

@ -1160,6 +1160,7 @@ static int find_first_merges(struct repository *repo,
}
object_array_clear(&merges);
release_revisions(&revs);
return result->nr;
}

1
midx.c
View File

@ -1061,6 +1061,7 @@ static struct commit **find_commits_for_midx_bitmap(uint32_t *indexed_commits_nr
if (indexed_commits_nr_p)
*indexed_commits_nr_p = cb.commits_nr;
release_revisions(&revs);
return cb.commits;
}

View File

@ -326,6 +326,7 @@ next:
trace2_data_intmax("pack-bitmap-write", the_repository,
"num_maximal_commits", num_maximal);
release_revisions(&revs);
free_commit_list(reusable);
}

View File

@ -2392,6 +2392,7 @@ static void reach_filter(struct ref_array *array,
clear_commit_marks(merge_commit, ALL_REV_FLAGS);
}
release_revisions(&revs);
free(to_clear);
}

View File

@ -2172,6 +2172,7 @@ static int stat_branch_pair(const char *branch_name, const char *base,
clear_commit_marks(theirs, ALL_REV_FLAGS);
strvec_clear(&argv);
release_revisions(&revs);
return 1;
}

View File

@ -1347,6 +1347,7 @@ void print_commit_summary(struct repository *r,
log_tree_commit(&rev, commit);
}
release_revisions(&rev);
strbuf_release(&format);
}
@ -3415,6 +3416,7 @@ static int make_patch(struct repository *r,
unuse_commit_buffer(commit, commit_buffer);
}
strbuf_release(&buf);
release_revisions(&log_tree_opt);
return res;
}
@ -4525,6 +4527,7 @@ cleanup_head_ref:
&log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
}
release_revisions(&log_tree_opt);
}
flush_rewritten_pending();
if (!stat(rebase_path_rewritten_list(), &st) &&

View File

@ -261,6 +261,7 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
if ((o->flags & both_flags) == both_flags)
o->flags &= ~not_shallow_flag;
}
release_revisions(&revs);
return result;
}

View File

@ -900,9 +900,11 @@ static void collect_changed_submodules(struct repository *r,
diff_rev.diffopt.format_callback_data = &data;
diff_rev.dense_combined_merges = 1;
diff_tree_combined_merge(commit, &diff_rev);
release_revisions(&diff_rev);
}
reset_revision_walk();
release_revisions(&rev);
}
static void free_submodules_oids(struct string_list *submodules)

View File

@ -43,6 +43,7 @@ static int run_revision_walk(void)
}
reset_revision_walk();
release_revisions(&rev);
return got_revision;
}

View File

@ -1152,6 +1152,7 @@ static void wt_longstatus_print_verbose(struct wt_status *s)
rev.diffopt.b_prefix = "w/";
run_diff_files(&rev, 0);
}
release_revisions(&rev);
}
static void wt_longstatus_print_tracking(struct wt_status *s)