Merge branch 'ab/plug-leak-in-revisions'

Plug the memory leaks from the trickiest API of all, the revision
walker.

* ab/plug-leak-in-revisions: (27 commits)
  revisions API: add a TODO for diff_free(&revs->diffopt)
  revisions API: have release_revisions() release "topo_walk_info"
  revisions API: have release_revisions() release "date_mode"
  revisions API: call diff_free(&revs->pruning) in revisions_release()
  revisions API: release "reflog_info" in release revisions()
  revisions API: clear "boundary_commits" in release_revisions()
  revisions API: have release_revisions() release "prune_data"
  revisions API: have release_revisions() release "grep_filter"
  revisions API: have release_revisions() release "filter"
  revisions API: have release_revisions() release "cmdline"
  revisions API: have release_revisions() release "mailmap"
  revisions API: have release_revisions() release "commits"
  revisions API users: use release_revisions() for "prune_data" users
  revisions API users: use release_revisions() with UNLEAK()
  revisions API users: use release_revisions() in builtin/log.c
  revisions API users: use release_revisions() in http-push.c
  revisions API users: add "goto cleanup" for release_revisions()
  stash: always have the owner of "stash_info" free it
  revisions API users: use release_revisions() needing REV_INFO_INIT
  revision.[ch]: document and move code declared around "init"
  ...
This commit is contained in:
Junio C Hamano 2022-06-07 14:10:56 -07:00
commit 2da81d1efb
117 changed files with 500 additions and 190 deletions

View File

@ -568,8 +568,7 @@ static int get_modified_files(struct repository *r,
run_diff_files(&rev, 0);
}
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);
}
/*
@ -1008,7 +1010,7 @@ void read_bisect_terms(const char **read_bad, const char **read_good)
*/
enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
{
struct rev_info revs;
struct rev_info revs = REV_INFO_INIT;
struct commit_list *tried;
int reaches = 0, all = 0, nr, steps;
enum bisect_error res = BISECT_OK;
@ -1033,7 +1035,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
res = check_good_are_ancestors_of_bad(r, prefix, no_checkout);
if (res)
return res;
goto cleanup;
bisect_rev_setup(r, &revs, prefix, "%s", "^%s", 1);
@ -1058,14 +1060,16 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
term_good,
term_bad);
return BISECT_FAILED;
res = BISECT_FAILED;
goto cleanup;
}
if (!all) {
fprintf(stderr, _("No testable commit found.\n"
"Maybe you started with bad path arguments?\n"));
return BISECT_NO_TESTABLE_COMMIT;
res = BISECT_NO_TESTABLE_COMMIT;
goto cleanup;
}
bisect_rev = &revs.commits->item->object.oid;
@ -1085,7 +1089,8 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
* for negative return values for early returns up
* until the cmd_bisect__helper() caller.
*/
return BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND;
res = BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND;
goto cleanup;
}
nr = all - reaches - 1;
@ -1104,7 +1109,10 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
/* Clean up objects used, as they will be reused. */
repo_clear_commit_marks(r, ALL_REV_FLAGS);
return bisect_checkout(bisect_rev, no_checkout);
res = bisect_checkout(bisect_rev, no_checkout);
cleanup:
release_revisions(&revs);
return res;
}
static inline int log2i(int n)

View File

@ -151,7 +151,7 @@ int add_files_to_cache(const char *prefix,
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
end_odb_transaction();
clear_pathspec(&rev.prune_data);
release_revisions(&rev);
return !!data.add_errors;
}
@ -344,6 +344,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

@ -596,6 +596,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
reset_revision_walk();
strbuf_release(&commit_name);
release_revisions(&revs);
fclose(fp);
return 0;
}
@ -1084,6 +1085,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

@ -1171,7 +1171,7 @@ parse_done:
if (!incremental)
setup_pager();
else
return 0;
goto cleanup;
blame_sort_final(&sb);
@ -1205,6 +1205,8 @@ parse_done:
printf("num commits: %d\n", sb.num_commits);
}
cleanup:
cleanup_scoreboard(&sb);
release_revisions(&revs);
return 0;
}

View File

@ -629,7 +629,7 @@ static void show_local_changes(struct object *head,
diff_setup_done(&rev.diffopt);
add_pending_object(&rev, head, NULL);
run_diff_index(&rev, 0);
object_array_clear(&rev.pending);
release_revisions(&rev);
}
static void describe_detached_head(const char *msg, struct commit *commit)
@ -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

@ -1100,7 +1100,6 @@ static const char *find_author_by_nickname(const char *name)
struct rev_info revs;
struct commit *commit;
struct strbuf buf = STRBUF_INIT;
struct string_list mailmap = STRING_LIST_INIT_NODUP;
const char *av[20];
int ac = 0;
@ -1111,7 +1110,8 @@ static const char *find_author_by_nickname(const char *name)
av[++ac] = buf.buf;
av[++ac] = NULL;
setup_revisions(ac, av, &revs, NULL);
revs.mailmap = &mailmap;
revs.mailmap = xmalloc(sizeof(struct string_list));
string_list_init_nodup(revs.mailmap);
read_mailmap(revs.mailmap);
if (prepare_revision_walk(&revs))
@ -1122,7 +1122,7 @@ static const char *find_author_by_nickname(const char *name)
ctx.date_mode.type = DATE_NORMAL;
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

@ -77,8 +77,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
perror("read_cache_preload");
return -1;
result = -1;
goto cleanup;
}
cleanup:
result = run_diff_files(&rev, options);
return diff_result_code(&rev.diffopt, result);
result = diff_result_code(&rev.diffopt, result);
release_revisions(&rev);
return result;
}

View File

@ -70,6 +70,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
return -1;
}
result = run_diff_index(&rev, option);
UNLEAK(rev);
return diff_result_code(&rev.diffopt, result);
result = diff_result_code(&rev.diffopt, result);
release_revisions(&rev);
return result;
}

View File

@ -594,7 +594,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
result = diff_result_code(&rev.diffopt, result);
if (1 < rev.diffopt.skip_stat_unmatch)
refresh_index_quietly();
UNLEAK(rev);
release_revisions(&rev);
UNLEAK(ent);
UNLEAK(blob);
return result;

View File

@ -1276,6 +1276,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

@ -231,7 +231,8 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
}
if (mailmap) {
rev->mailmap = xcalloc(1, sizeof(struct string_list));
rev->mailmap = xmalloc(sizeof(struct string_list));
string_list_init_nodup(rev->mailmap);
read_mailmap(rev->mailmap);
}
@ -294,6 +295,12 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
cmd_log_init_finish(argc, argv, prefix, rev, opt);
}
static int cmd_log_deinit(int ret, struct rev_info *rev)
{
release_revisions(rev);
return ret;
}
/*
* This gives a rough estimate for how many commits we
* will print out in the list.
@ -565,7 +572,7 @@ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
cmd_log_init(argc, argv, prefix, &rev, &opt);
if (!rev.diffopt.output_format)
rev.diffopt.output_format = DIFF_FORMAT_RAW;
return cmd_log_walk(&rev);
return cmd_log_deinit(cmd_log_walk(&rev), &rev);
}
static void show_tagger(const char *buf, struct rev_info *rev)
@ -689,7 +696,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
cmd_log_init(argc, argv, prefix, &rev, &opt);
if (!rev.no_walk)
return cmd_log_walk(&rev);
return cmd_log_deinit(cmd_log_walk(&rev), &rev);
count = rev.pending.nr;
objects = rev.pending.objects;
@ -749,8 +756,7 @@ int cmd_show(int argc, const char **argv, const char *prefix)
rev.diffopt.no_free = 0;
diff_free(&rev.diffopt);
free(objects);
return ret;
return cmd_log_deinit(ret, &rev);
}
/*
@ -778,7 +784,7 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
rev.always_show_header = 1;
cmd_log_init_finish(argc, argv, prefix, &rev, &opt);
return cmd_log_walk(&rev);
return cmd_log_deinit(cmd_log_walk(&rev), &rev);
}
static void log_setup_revisions_tweak(struct rev_info *rev,
@ -809,7 +815,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
opt.revarg_opt = REVARG_COMMITTISH;
opt.tweak = log_setup_revisions_tweak;
cmd_log_init(argc, argv, prefix, &rev, &opt);
return cmd_log_walk(&rev);
return cmd_log_deinit(cmd_log_walk(&rev), &rev);
}
/* format-patch */
@ -1764,6 +1770,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
struct commit *commit;
struct commit **list = NULL;
struct rev_info rev;
char *to_free = NULL;
struct setup_revision_opt s_r_opt;
int nr = 0, total, i;
int use_stdout = 0;
@ -1965,7 +1972,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
strbuf_addch(&buf, '\n');
}
rev.extra_headers = strbuf_detach(&buf, NULL);
rev.extra_headers = to_free = strbuf_detach(&buf, NULL);
if (from) {
if (split_ident_line(&rev.from_ident, from, strlen(from)))
@ -2186,8 +2193,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
prepare_bases(&bases, base, list, nr);
}
if (in_reply_to || thread || cover_letter)
rev.ref_message_ids = xcalloc(1, sizeof(struct string_list));
if (in_reply_to || thread || cover_letter) {
rev.ref_message_ids = xmalloc(sizeof(*rev.ref_message_ids));
string_list_init_nodup(rev.ref_message_ids);
}
if (in_reply_to) {
const char *msgid = clean_message_id(in_reply_to);
string_list_append(rev.ref_message_ids, msgid);
@ -2294,8 +2303,11 @@ done:
strbuf_release(&rdiff1);
strbuf_release(&rdiff2);
strbuf_release(&rdiff_title);
UNLEAK(rev);
return 0;
free(to_free);
if (rev.ref_message_ids)
string_list_clear(rev.ref_message_ids, 0);
free(rev.ref_message_ids);
return cmd_log_deinit(0, &rev);
}
static int add_pending_commit(const char *arg, struct rev_info *revs, int flags)

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

@ -4464,11 +4464,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

@ -293,6 +293,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

@ -213,10 +213,8 @@ static void show_commit(struct commit *commit, void *data)
static void finish_commit(struct commit *commit)
{
if (commit->parents) {
free_commit_list(commit->parents);
commit->parents = NULL;
}
free_commit_list(commit->parents);
commit->parents = NULL;
free_commit_buffer(the_repository->parsed_objects,
commit);
}
@ -502,6 +500,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
int use_bitmap_index = 0;
int filter_provided_objects = 0;
const char *show_progress = NULL;
int ret = 0;
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(rev_list_usage);
@ -585,7 +584,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
}
if (!strcmp(arg, "--test-bitmap")) {
test_bitmap_walk(&revs);
return 0;
goto cleanup;
}
if (skip_prefix(arg, "--progress=", &arg)) {
show_progress = arg;
@ -674,11 +673,11 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
if (use_bitmap_index) {
if (!try_bitmap_count(&revs, filter_provided_objects))
return 0;
goto cleanup;
if (!try_bitmap_disk_usage(&revs, filter_provided_objects))
return 0;
goto cleanup;
if (!try_bitmap_traversal(&revs, filter_provided_objects))
return 0;
goto cleanup;
}
if (prepare_revision_walk(&revs))
@ -698,8 +697,10 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
find_bisection(&revs.commits, &reaches, &all, bisect_flags);
if (bisect_show_vars)
return show_bisect_vars(&info, reaches, all);
if (bisect_show_vars) {
ret = show_bisect_vars(&info, reaches, all);
goto cleanup;
}
}
if (filter_provided_objects) {
@ -754,5 +755,7 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
if (show_disk_usage)
printf("%"PRIuMAX"\n", (uintmax_t)total_disk_usage);
return 0;
cleanup:
release_revisions(&revs);
return ret;
}

View File

@ -81,8 +81,10 @@ static void insert_one_record(struct shortlog *log,
format_subject(&subject, oneline, " ");
buffer = strbuf_detach(&subject, NULL);
if (!item->util)
item->util = xcalloc(1, sizeof(struct string_list));
if (!item->util) {
item->util = xmalloc(sizeof(struct string_list));
string_list_init_nodup(item->util);
}
string_list_append(item->util, buffer);
}
}
@ -420,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

@ -117,6 +117,10 @@ struct stash_info {
int has_u;
};
#define STASH_INFO_INIT { \
.revision = STRBUF_INIT, \
}
static void free_stash_info(struct stash_info *info)
{
strbuf_release(&info->revision);
@ -158,10 +162,8 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
if (argc == 1)
commit = argv[0];
strbuf_init(&info->revision, 0);
if (!commit) {
if (!ref_exists(ref_stash)) {
free_stash_info(info);
fprintf_ln(stderr, _("No stash entries found."));
return -1;
}
@ -175,11 +177,8 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
revision = info->revision.buf;
if (get_oid(revision, &info->w_commit)) {
error(_("%s is not a valid reference"), revision);
free_stash_info(info);
return -1;
}
if (get_oid(revision, &info->w_commit))
return error(_("%s is not a valid reference"), revision);
assert_stash_like(info, revision);
@ -198,7 +197,7 @@ static int get_stash_info(struct stash_info *info, int argc, const char **argv)
info->is_stash_ref = !strcmp(expanded_ref, ref_stash);
break;
default: /* Invalid or ambiguous */
free_stash_info(info);
break;
}
free(expanded_ref);
@ -616,10 +615,10 @@ restore_untracked:
static int apply_stash(int argc, const char **argv, const char *prefix)
{
int ret;
int ret = -1;
int quiet = 0;
int index = 0;
struct stash_info info;
struct stash_info info = STASH_INFO_INIT;
struct option options[] = {
OPT__QUIET(&quiet, N_("be quiet, only report errors")),
OPT_BOOL(0, "index", &index,
@ -631,9 +630,10 @@ static int apply_stash(int argc, const char **argv, const char *prefix)
git_stash_apply_usage, 0);
if (get_stash_info(&info, argc, argv))
return -1;
goto cleanup;
ret = do_apply_stash(prefix, &info, index, quiet);
cleanup:
free_stash_info(&info);
return ret;
}
@ -669,20 +669,25 @@ static int do_drop_stash(struct stash_info *info, int quiet)
return 0;
}
static void assert_stash_ref(struct stash_info *info)
static int get_stash_info_assert(struct stash_info *info, int argc,
const char **argv)
{
if (!info->is_stash_ref) {
error(_("'%s' is not a stash reference"), info->revision.buf);
free_stash_info(info);
exit(1);
}
int ret = get_stash_info(info, argc, argv);
if (ret < 0)
return ret;
if (!info->is_stash_ref)
return error(_("'%s' is not a stash reference"), info->revision.buf);
return 0;
}
static int drop_stash(int argc, const char **argv, const char *prefix)
{
int ret;
int ret = -1;
int quiet = 0;
struct stash_info info;
struct stash_info info = STASH_INFO_INIT;
struct option options[] = {
OPT__QUIET(&quiet, N_("be quiet, only report errors")),
OPT_END()
@ -691,22 +696,21 @@ static int drop_stash(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, options,
git_stash_drop_usage, 0);
if (get_stash_info(&info, argc, argv))
return -1;
assert_stash_ref(&info);
if (get_stash_info_assert(&info, argc, argv))
goto cleanup;
ret = do_drop_stash(&info, quiet);
cleanup:
free_stash_info(&info);
return ret;
}
static int pop_stash(int argc, const char **argv, const char *prefix)
{
int ret;
int ret = -1;
int index = 0;
int quiet = 0;
struct stash_info info;
struct stash_info info = STASH_INFO_INIT;
struct option options[] = {
OPT__QUIET(&quiet, N_("be quiet, only report errors")),
OPT_BOOL(0, "index", &index,
@ -717,25 +721,25 @@ static int pop_stash(int argc, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix, options,
git_stash_pop_usage, 0);
if (get_stash_info(&info, argc, argv))
return -1;
if (get_stash_info_assert(&info, argc, argv))
goto cleanup;
assert_stash_ref(&info);
if ((ret = do_apply_stash(prefix, &info, index, quiet)))
printf_ln(_("The stash entry is kept in case "
"you need it again."));
else
ret = do_drop_stash(&info, quiet);
cleanup:
free_stash_info(&info);
return ret;
}
static int branch_stash(int argc, const char **argv, const char *prefix)
{
int ret;
int ret = -1;
const char *branch = NULL;
struct stash_info info;
struct stash_info info = STASH_INFO_INIT;
struct child_process cp = CHILD_PROCESS_INIT;
struct option options[] = {
OPT_END()
@ -752,7 +756,7 @@ static int branch_stash(int argc, const char **argv, const char *prefix)
branch = argv[0];
if (get_stash_info(&info, argc - 1, argv + 1))
return -1;
goto cleanup;
cp.git_cmd = 1;
strvec_pushl(&cp.args, "checkout", "-b", NULL);
@ -764,8 +768,8 @@ static int branch_stash(int argc, const char **argv, const char *prefix)
if (!ret && info.is_stash_ref)
ret = do_drop_stash(&info, 0);
cleanup:
free_stash_info(&info);
return ret;
}
@ -843,8 +847,8 @@ static void diff_include_untracked(const struct stash_info *info, struct diff_op
static int show_stash(int argc, const char **argv, const char *prefix)
{
int i;
int ret = 0;
struct stash_info info;
int ret = -1;
struct stash_info info = STASH_INFO_INIT;
struct rev_info rev;
struct strvec stash_args = STRVEC_INIT;
struct strvec revision_args = STRVEC_INIT;
@ -862,6 +866,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
UNTRACKED_ONLY, PARSE_OPT_NONEG),
OPT_END()
};
int do_usage = 0;
init_diff_ui_defaults();
git_config(git_diff_ui_config, NULL);
@ -879,10 +884,8 @@ static int show_stash(int argc, const char **argv, const char *prefix)
strvec_push(&revision_args, argv[i]);
}
ret = get_stash_info(&info, stash_args.nr, stash_args.v);
strvec_clear(&stash_args);
if (ret)
return -1;
if (get_stash_info(&info, stash_args.nr, stash_args.v))
goto cleanup;
/*
* The config settings are applied only if there are not passed
@ -896,16 +899,14 @@ static int show_stash(int argc, const char **argv, const char *prefix)
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
if (!show_stat && !show_patch) {
free_stash_info(&info);
return 0;
ret = 0;
goto cleanup;
}
}
argc = setup_revisions(revision_args.nr, revision_args.v, &rev, NULL);
if (argc > 1) {
free_stash_info(&info);
usage_with_options(git_stash_show_usage, options);
}
if (argc > 1)
goto usage;
if (!rev.diffopt.output_format) {
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
diff_setup_done(&rev.diffopt);
@ -930,8 +931,17 @@ static int show_stash(int argc, const char **argv, const char *prefix)
}
log_tree_diff_flush(&rev);
ret = diff_result_code(&rev.diffopt, 0);
cleanup:
strvec_clear(&stash_args);
free_stash_info(&info);
return diff_result_code(&rev.diffopt, 0);
release_revisions(&rev);
if (do_usage)
usage_with_options(git_stash_show_usage, options);
return ret;
usage:
do_usage = 1;
goto cleanup;
}
static int do_store_stash(const struct object_id *w_commit, const char *stash_msg,
@ -1065,7 +1075,6 @@ static int check_changes_tracked_files(const struct pathspec *ps)
goto done;
}
object_array_clear(&rev.pending);
result = run_diff_files(&rev, 0);
if (diff_result_code(&rev.diffopt, result)) {
ret = 1;
@ -1073,7 +1082,7 @@ static int check_changes_tracked_files(const struct pathspec *ps)
}
done:
clear_pathspec(&rev.prune_data);
release_revisions(&rev);
return ret;
}
@ -1284,9 +1293,7 @@ static int stash_working_tree(struct stash_info *info, const struct pathspec *ps
done:
discard_index(&istate);
UNLEAK(rev);
object_array_clear(&rev.pending);
clear_pathspec(&rev.prune_data);
release_revisions(&rev);
strbuf_release(&diff_output);
remove_path(stash_index_path.buf);
return ret;
@ -1428,9 +1435,9 @@ done:
static int create_stash(int argc, const char **argv, const char *prefix)
{
int ret = 0;
int ret;
struct strbuf stash_msg_buf = STRBUF_INIT;
struct stash_info info;
struct stash_info info = STASH_INFO_INIT;
struct pathspec ps;
/* Starting with argv[1], since argv[0] is "create" */
@ -1445,6 +1452,7 @@ static int create_stash(int argc, const char **argv, const char *prefix)
if (!ret)
printf_ln("%s", oid_to_hex(&info.w_commit));
free_stash_info(&info);
strbuf_release(&stash_msg_buf);
return ret;
}
@ -1453,7 +1461,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
int keep_index, int patch_mode, int include_untracked, int only_staged)
{
int ret = 0;
struct stash_info info;
struct stash_info info = STASH_INFO_INIT;
struct strbuf patch = STRBUF_INIT;
struct strbuf stash_msg_buf = STRBUF_INIT;
struct strbuf untracked_files = STRBUF_INIT;
@ -1652,6 +1660,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
}
done:
free_stash_info(&info);
strbuf_release(&stash_msg_buf);
return ret;
}

View File

@ -649,7 +649,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
{
char *displaypath;
struct strvec diff_files_args = STRVEC_INIT;
struct rev_info rev;
struct rev_info rev = REV_INFO_INIT;
int diff_files_result;
struct strbuf buf = STRBUF_INIT;
const char *git_dir;
@ -736,6 +736,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
cleanup:
strvec_clear(&diff_files_args);
free(displaypath);
release_revisions(&rev);
}
static void status_submodule_cb(const struct cache_entry *list_item,
@ -1114,6 +1115,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
struct strvec diff_args = STRVEC_INIT;
struct rev_info rev;
struct module_cb_list list = MODULE_CB_LIST_INIT;
int ret = 0;
strvec_push(&diff_args, get_diff_cmd(diff_cmd));
if (info->cached)
@ -1139,11 +1141,13 @@ static int compute_summary_module_list(struct object_id *head_oid,
setup_work_tree();
if (read_cache_preload(&rev.diffopt.pathspec) < 0) {
perror("read_cache_preload");
return -1;
ret = -1;
goto cleanup;
}
} else if (read_cache() < 0) {
perror("read_cache");
return -1;
ret = -1;
goto cleanup;
}
if (diff_cmd == DIFF_INDEX)
@ -1151,8 +1155,10 @@ static int compute_summary_module_list(struct object_id *head_oid,
else
run_diff_files(&rev, 0);
prepare_submodule_summary(info, &list);
cleanup:
strvec_clear(&diff_args);
return 0;
release_revisions(&rev);
return ret;
}
static int module_summary(int argc, const char **argv, const char *prefix)

View File

@ -196,14 +196,16 @@ int verify_bundle(struct repository *r,
* to be verbose about the errors
*/
struct string_list *p = &header->prerequisites;
struct rev_info revs;
struct rev_info revs = REV_INFO_INIT;
const char *argv[] = {NULL, "--all", NULL};
struct commit *commit;
int i, ret = 0, req_nr;
const char *message = _("Repository lacks these prerequisite commits:");
if (!r || !r->objects || !r->objects->odb)
return error(_("need a repository to verify a bundle"));
if (!r || !r->objects || !r->objects->odb) {
ret = error(_("need a repository to verify a bundle"));
goto cleanup;
}
repo_init_revisions(r, &revs, NULL);
for (i = 0; i < p->nr; i++) {
@ -221,7 +223,7 @@ int verify_bundle(struct repository *r,
error("%s %s", oid_to_hex(oid), name);
}
if (revs.pending.nr != p->nr)
return ret;
goto cleanup;
req_nr = revs.pending.nr;
setup_revisions(2, argv, &revs, NULL);
@ -284,6 +286,8 @@ int verify_bundle(struct repository *r,
printf_ln("The bundle uses this filter: %s",
list_objects_filter_spec(&header->filter));
}
cleanup:
release_revisions(&revs);
return ret;
}

View File

@ -407,17 +407,14 @@ int parse_commit_buffer(struct repository *r, struct commit *item, const void *b
if (item->object.parsed)
return 0;
if (item->parents) {
/*
* Presumably this is leftover from an earlier failed parse;
* clear it out in preparation for us re-parsing (we'll hit the
* same error, but that's good, since it lets our caller know
* the result cannot be trusted.
*/
free_commit_list(item->parents);
item->parents = NULL;
}
/*
* Presumably this is leftover from an earlier failed parse;
* clear it out in preparation for us re-parsing (we'll hit the
* same error, but that's good, since it lets our caller know
* the result cannot be trusted.
*/
free_commit_list(item->parents);
item->parents = NULL;
tail += size;
if (tail <= bufptr + tree_entry_len + 1 || memcmp(bufptr, "tree ", 5) ||

View File

@ -2,13 +2,21 @@
expression E;
@@
- if (E)
(
free(E);
|
free_commit_list(E);
)
@@
expression E;
@@
- if (!E)
(
free(E);
|
free_commit_list(E);
)
@@
expression E;
@ -16,3 +24,22 @@ expression E;
- free(E);
+ FREE_AND_NULL(E);
- E = NULL;
@@
expression E;
@@
- if (E)
- {
free_commit_list(E);
E = NULL;
- }
@@
expression E;
statement S;
@@
- if (E) {
+ if (E)
S
free_commit_list(E);
- }

View File

@ -641,7 +641,7 @@ int do_diff_cache(const struct object_id *tree_oid, struct diff_options *opt)
if (diff_cache(&revs, tree_oid, NULL, 1))
exit(128);
clear_pathspec(&revs.prune_data);
release_revisions(&revs);
return 0;
}
@ -651,6 +651,7 @@ int index_differs_from(struct repository *r,
{
struct rev_info rev;
struct setup_revision_opt opt;
unsigned has_changes;
repo_init_revisions(r, &rev, NULL);
memset(&opt, 0, sizeof(opt));
@ -662,8 +663,9 @@ int index_differs_from(struct repository *r,
diff_flags_or(&rev.diffopt.flags, flags);
rev.diffopt.ita_invisible_in_index = ita_invisible_in_index;
run_diff_index(&rev, 1);
object_array_clear(&rev.pending);
return (rev.diffopt.flags.has_changes != 0);
has_changes = rev.diffopt.flags.has_changes;
release_revisions(&rev);
return (has_changes != 0);
}
static struct strbuf *idiff_prefix_cb(struct diff_options *opt, void *data)

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

@ -1689,7 +1689,6 @@ int cmd_main(int argc, const char **argv)
struct refspec rs = REFSPEC_INIT_PUSH;
struct remote_lock *ref_lock = NULL;
struct remote_lock *info_ref_lock = NULL;
struct rev_info revs;
int delete_branch = 0;
int force_delete = 0;
int objects_to_send;
@ -1825,6 +1824,7 @@ int cmd_main(int argc, const char **argv)
new_refs = 0;
for (ref = remote_refs; ref; ref = ref->next) {
struct rev_info revs;
struct strvec commit_argv = STRVEC_INIT;
if (!ref->peer_ref)
@ -1941,6 +1941,7 @@ int cmd_main(int argc, const char **argv)
unlock_remote(ref_lock);
check_locks();
strvec_clear(&commit_argv);
release_revisions(&revs);
}
/* Update remote server info if appropriate */

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

@ -522,10 +522,10 @@ static struct stage_data *insert_stage_data(struct repository *r,
*/
static struct string_list *get_unmerged(struct index_state *istate)
{
struct string_list *unmerged = xcalloc(1, sizeof(struct string_list));
struct string_list *unmerged = xmalloc(sizeof(struct string_list));
int i;
unmerged->strdup_strings = 1;
string_list_init_dup(unmerged);
/* TODO: audit for interaction with sparse-index. */
ensure_full_index(istate);
@ -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

@ -1049,6 +1049,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

@ -596,6 +596,6 @@ int is_range_diff_range(const char *arg)
}
free(copy);
object_array_clear(&revs.pending);
release_revisions(&revs);
return negative > 0 && positive > 0;
}

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

@ -8,7 +8,7 @@
struct complete_reflogs {
char *ref;
const char *short_ref;
char *short_ref;
struct reflog_info {
struct object_id ooid, noid;
char *email;
@ -51,9 +51,16 @@ static void free_complete_reflog(struct complete_reflogs *array)
}
free(array->items);
free(array->ref);
free(array->short_ref);
free(array);
}
static void complete_reflogs_clear(void *util, const char *str)
{
struct complete_reflogs *array = util;
free_complete_reflog(array);
}
static struct complete_reflogs *read_complete_reflog(const char *ref)
{
struct complete_reflogs *reflogs =
@ -116,6 +123,21 @@ void init_reflog_walk(struct reflog_walk_info **info)
(*info)->complete_reflogs.strdup_strings = 1;
}
void reflog_walk_info_release(struct reflog_walk_info *info)
{
size_t i;
if (!info)
return;
for (i = 0; i < info->nr; i++)
free(info->logs[i]);
string_list_clear_func(&info->complete_reflogs,
complete_reflogs_clear);
free(info->logs);
free(info);
}
int add_reflog_for_walk(struct reflog_walk_info *info,
struct commit *commit, const char *name)
{

View File

@ -8,6 +8,7 @@ struct reflog_walk_info;
struct date_mode;
void init_reflog_walk(struct reflog_walk_info **info);
void reflog_walk_info_release(struct reflog_walk_info *info);
int add_reflog_for_walk(struct reflog_walk_info *info,
struct commit *commit, const char *name);
void show_reflog_message(struct reflog_walk_info *info, int,

View File

@ -2175,6 +2175,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

@ -606,6 +606,10 @@ static struct commit *one_relevant_parent(const struct rev_info *revs,
*
* 2. We saw anything except REV_TREE_NEW.
*/
#define REV_TREE_SAME 0
#define REV_TREE_NEW 1 /* Only new files */
#define REV_TREE_OLD 2 /* Only files removed */
#define REV_TREE_DIFFERENT 3 /* Mixed changes */
static int tree_difference = REV_TREE_SAME;
static void file_add_remove(struct diff_options *options,
@ -1459,10 +1463,9 @@ static int limit_list(struct rev_info *revs)
if (revs->left_only || revs->right_only)
limit_left_right(newlist, revs);
if (bottom) {
if (bottom)
limit_to_ancestry(bottom, newlist);
free_commit_list(bottom);
}
free_commit_list(bottom);
/*
* Check if any commits have become TREESAME by some of their parents
@ -2930,6 +2933,42 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
return left;
}
static void release_revisions_cmdline(struct rev_cmdline_info *cmdline)
{
unsigned int i;
for (i = 0; i < cmdline->nr; i++)
free((char *)cmdline->rev[i].name);
free(cmdline->rev);
}
static void release_revisions_mailmap(struct string_list *mailmap)
{
if (!mailmap)
return;
clear_mailmap(mailmap);
free(mailmap);
}
static void release_revisions_topo_walk_info(struct topo_walk_info *info);
void release_revisions(struct rev_info *revs)
{
free_commit_list(revs->commits);
object_array_clear(&revs->pending);
object_array_clear(&revs->boundary_commits);
release_revisions_cmdline(&revs->cmdline);
list_objects_filter_release(&revs->filter);
clear_pathspec(&revs->prune_data);
date_mode_release(&revs->date_mode);
release_revisions_mailmap(revs->mailmap);
free_grep_patterns(&revs->grep_filter);
/* TODO (need to handle "no_free"): diff_free(&revs->diffopt) */
diff_free(&revs->pruning);
reflog_walk_info_release(revs->reflog_info);
release_revisions_topo_walk_info(revs->topo_walk_info);
}
static void add_child(struct rev_info *revs, struct commit *parent, struct commit *child)
{
struct commit_list *l = xcalloc(1, sizeof(*l));
@ -3440,17 +3479,22 @@ static void compute_indegrees_to_depth(struct rev_info *revs,
indegree_walk_step(revs);
}
static void reset_topo_walk(struct rev_info *revs)
static void release_revisions_topo_walk_info(struct topo_walk_info *info)
{
struct topo_walk_info *info = revs->topo_walk_info;
if (!info)
return;
clear_prio_queue(&info->explore_queue);
clear_prio_queue(&info->indegree_queue);
clear_prio_queue(&info->topo_queue);
clear_indegree_slab(&info->indegree);
clear_author_date_slab(&info->author_date);
free(info);
}
FREE_AND_NULL(revs->topo_walk_info);
static void reset_topo_walk(struct rev_info *revs)
{
release_revisions_topo_walk_info(revs->topo_walk_info);
revs->topo_walk_info = NULL;
}
static void init_topo_walk(struct rev_info *revs)
@ -4090,10 +4134,8 @@ static void create_boundary_commit_list(struct rev_info *revs)
* boundary commits anyway. (This is what the code has always
* done.)
*/
if (revs->commits) {
free_commit_list(revs->commits);
revs->commits = NULL;
}
free_commit_list(revs->commits);
revs->commits = NULL;
/*
* Put all of the actual boundary commits from revs->boundary_commits
@ -4230,10 +4272,8 @@ struct commit *get_revision(struct rev_info *revs)
graph_update(revs->graph, c);
if (!c) {
free_saved_parents(revs);
if (revs->previous_parents) {
free_commit_list(revs->previous_parents);
revs->previous_parents = NULL;
}
free_commit_list(revs->previous_parents);
revs->previous_parents = NULL;
}
return c;
}

View File

@ -330,31 +330,24 @@ struct rev_info {
struct tmp_objdir *remerge_objdir;
};
int ref_excluded(struct string_list *, const char *path);
void clear_ref_exclusion(struct string_list **);
void add_ref_exclusion(struct string_list **, const char *exclude);
#define REV_TREE_SAME 0
#define REV_TREE_NEW 1 /* Only new files */
#define REV_TREE_OLD 2 /* Only files removed */
#define REV_TREE_DIFFERENT 3 /* Mixed changes */
/* revision.c */
typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
extern volatile show_early_output_fn_t show_early_output;
struct setup_revision_opt {
const char *def;
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
unsigned int assume_dashdash:1,
allow_exclude_promisor_objects:1;
unsigned revarg_opt;
};
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix)
#endif
/**
* Initialize the "struct rev_info" structure with a macro.
*
* This will not fully initialize a "struct rev_info", the
* repo_init_revisions() function needs to be called before
* setup_revisions() and any revision walking takes place.
*
* Use REV_INFO_INIT to make the "struct rev_info" safe for passing to
* release_revisions() when it's inconvenient (e.g. due to a "goto
* cleanup" pattern) to arrange for repo_init_revisions() to be called
* before release_revisions() is called.
*
* Initializing with this REV_INFO_INIT is redundant to invoking
* repo_init_revisions(). If repo_init_revisions() is guaranteed to be
* called before release_revisions() the "struct rev_info" can be left
* uninitialized.
*/
#define REV_INFO_INIT { 0 }
/**
* Initialize a rev_info structure with default values. The third parameter may
@ -367,6 +360,9 @@ struct setup_revision_opt {
void repo_init_revisions(struct repository *r,
struct rev_info *revs,
const char *prefix);
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
#define init_revisions(revs, prefix) repo_init_revisions(the_repository, revs, prefix)
#endif
/**
* Parse revision information, filling in the `rev_info` structure, and
@ -375,9 +371,22 @@ void repo_init_revisions(struct repository *r,
* head of the argument list. The last parameter is used in case no
* parameter given by the first two arguments.
*/
struct setup_revision_opt {
const char *def;
void (*tweak)(struct rev_info *, struct setup_revision_opt *);
unsigned int assume_dashdash:1,
allow_exclude_promisor_objects:1;
unsigned revarg_opt;
};
int setup_revisions(int argc, const char **argv, struct rev_info *revs,
struct setup_revision_opt *);
/**
* Free data allocated in a "struct rev_info" after it's been
* initialized with repo_init_revisions() or REV_INFO_INIT.
*/
void release_revisions(struct rev_info *revs);
void parse_revision_opt(struct rev_info *revs, struct parse_opt_ctx_t *ctx,
const struct option *options,
const char * const usagestr[]);
@ -418,6 +427,14 @@ void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees)
void show_object_with_name(FILE *, struct object *, const char *);
/**
* Helpers to check if a "struct string_list" item matches with
* wildmatch().
*/
int ref_excluded(struct string_list *, const char *path);
void clear_ref_exclusion(struct string_list **);
void add_ref_exclusion(struct string_list **, const char *exclude);
/**
* This function can be used if you want to add commit objects as revision
* information. You can use the `UNINTERESTING` object flag to indicate if
@ -473,4 +490,10 @@ int rewrite_parents(struct rev_info *revs,
*/
struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit *commit);
/**
* Global for the (undocumented) "--early-output" flag for "git log".
*/
typedef void (*show_early_output_fn_t)(struct rev_info *, struct commit_list *);
extern volatile show_early_output_fn_t show_early_output;
#endif

View File

@ -1346,6 +1346,7 @@ void print_commit_summary(struct repository *r,
log_tree_commit(&rev, commit);
}
release_revisions(&rev);
strbuf_release(&format);
}
@ -3414,6 +3415,7 @@ static int make_patch(struct repository *r,
unuse_commit_buffer(commit, commit_buffer);
}
strbuf_release(&buf);
release_revisions(&log_tree_opt);
return res;
}
@ -4524,6 +4526,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) &&
@ -5350,6 +5353,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
int rebase_merges = flags & TODO_LIST_REBASE_MERGES;
int reapply_cherry_picks = flags & TODO_LIST_REAPPLY_CHERRY_PICKS;
int skipped_commit = 0;
int ret = 0;
repo_init_revisions(r, &revs, NULL);
revs.verbose_header = 1;
@ -5373,14 +5377,20 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
pp.fmt = revs.commit_format;
pp.output_encoding = get_log_output_encoding();
if (setup_revisions(argc, argv, &revs, NULL) > 1)
return error(_("make_script: unhandled options"));
if (setup_revisions(argc, argv, &revs, NULL) > 1) {
ret = error(_("make_script: unhandled options"));
goto cleanup;
}
if (prepare_revision_walk(&revs) < 0)
return error(_("make_script: error preparing revisions"));
if (prepare_revision_walk(&revs) < 0) {
ret = error(_("make_script: error preparing revisions"));
goto cleanup;
}
if (rebase_merges)
return make_script_with_merges(&pp, &revs, out, flags);
if (rebase_merges) {
ret = make_script_with_merges(&pp, &revs, out, flags);
goto cleanup;
}
while ((commit = get_revision(&revs))) {
int is_empty = is_original_commit_empty(commit);
@ -5404,7 +5414,9 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
if (skipped_commit)
advise_if_enabled(ADVICE_SKIPPED_CHERRY_PICKS,
_("use --reapply-cherry-picks to include skipped commits"));
return 0;
cleanup:
release_revisions(&revs);
return ret;
}
/*

View File

@ -262,6 +262,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

@ -619,7 +619,7 @@ void show_submodule_diff_summary(struct diff_options *o, const char *path,
struct object_id *one, struct object_id *two,
unsigned dirty_submodule)
{
struct rev_info rev;
struct rev_info rev = REV_INFO_INIT;
struct commit *left = NULL, *right = NULL;
struct commit_list *merge_bases = NULL;
struct repository *sub;
@ -645,8 +645,8 @@ void show_submodule_diff_summary(struct diff_options *o, const char *path,
print_submodule_diff_summary(sub, &rev, o);
out:
if (merge_bases)
free_commit_list(merge_bases);
free_commit_list(merge_bases);
release_revisions(&rev);
clear_commit_marks(left, ~0);
clear_commit_marks(right, ~0);
if (sub) {
@ -735,8 +735,7 @@ void show_submodule_inline_diff(struct diff_options *o, const char *path,
done:
strbuf_release(&sb);
if (merge_bases)
free_commit_list(merge_bases);
free_commit_list(merge_bases);
if (left)
clear_commit_marks(left, ~0);
if (right)
@ -925,9 +924,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_data(struct string_list *submodules)

View File

@ -99,6 +99,7 @@ int cmd__fast_rebase(int argc, const char **argv)
struct merge_result result;
struct strbuf reflog_msg = STRBUF_INIT;
struct strbuf branch_name = STRBUF_INIT;
int ret = 0;
/*
* test-tool stuff doesn't set up the git directory by default; need to
@ -137,13 +138,17 @@ int cmd__fast_rebase(int argc, const char **argv)
revs.topo_order = 1;
strvec_pushl(&rev_walk_args, "", argv[4], "--not", argv[3], NULL);
if (setup_revisions(rev_walk_args.nr, rev_walk_args.v, &revs, NULL) > 1)
return error(_("unhandled options"));
if (setup_revisions(rev_walk_args.nr, rev_walk_args.v, &revs, NULL) > 1) {
ret = error(_("unhandled options"));
goto cleanup;
}
strvec_clear(&rev_walk_args);
if (prepare_revision_walk(&revs) < 0)
return error(_("error preparing revisions"));
if (prepare_revision_walk(&revs) < 0) {
ret = error(_("error preparing revisions"));
goto cleanup;
}
init_merge_options(&merge_opt, the_repository);
memset(&result, 0, sizeof(result));
@ -201,8 +206,6 @@ int cmd__fast_rebase(int argc, const char **argv)
}
if (create_symref("HEAD", branch_name.buf, reflog_msg.buf) < 0)
die(_("unable to update HEAD"));
strbuf_release(&reflog_msg);
strbuf_release(&branch_name);
prime_cache_tree(the_repository, the_repository->index,
result.tree);
@ -221,5 +224,11 @@ int cmd__fast_rebase(int argc, const char **argv)
if (write_locked_index(&the_index, &lock,
COMMIT_LOCK | SKIP_IF_UNCHANGED))
die(_("unable to write %s"), get_index_file());
return (result.clean == 0);
ret = (result.clean == 0);
cleanup:
strbuf_release(&reflog_msg);
strbuf_release(&branch_name);
release_revisions(&revs);
return ret;
}

View File

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

View File

@ -1,3 +1,7 @@
if test -z "$TEST_FAILS_SANITIZE_LEAK"
then
TEST_PASSES_SANITIZE_LEAK=true
fi
. ./test-lib.sh
if test -n "$NO_SVN_TESTS"

View File

@ -2,6 +2,7 @@
test_description='"-C <path>" option and its effects on other path-related options'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success '"git -C <path>" runs git from the directory <path>' '

View File

@ -5,6 +5,7 @@
test_description='Test revision walking api'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
cat >run_twice_expected <<-EOF

View File

@ -5,6 +5,7 @@ test_description='previous branch syntax @{-n}'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'branch -d @{-1}' '

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='various @{whatever} syntax tests'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -21,6 +21,7 @@ In the test, these paths are used:
yomin - not in H or M
'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh

View File

@ -9,6 +9,7 @@ This is identical to t1001, but uses -u to update the work tree as well.
'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-read-tree.sh

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='see how we handle various forms of corruption'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# convert "1234abcd" to ".git/objects/12/34abcd"

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='basic symbolic-ref tests'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# If the tests munging HEAD fail, they can break detection of

View File

@ -4,6 +4,7 @@ test_description='Test reflog display routines'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='reflog walk shows repeated commits again'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup commits' '

View File

@ -2,6 +2,7 @@
test_description='per-worktree refs'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -4,6 +4,7 @@ test_description='checkout from unborn branch'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -14,6 +14,7 @@ only the updates to dir/sub.
Also tested are "git add -u" without limiting, and "git add -u"
without contents changes, and other conditions'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -8,6 +8,7 @@ test_description='Test commit notes index (expensive!)'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
create_repo () {

View File

@ -5,6 +5,7 @@ test_description='Test commit notes organized in subtrees'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
number_of_commits=100

View File

@ -2,6 +2,7 @@
test_description='Test that adding/removing many notes triggers automatic fanout restructuring'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
path_has_fanout() {

View File

@ -5,6 +5,7 @@ test_description='rebasing a commit with multi-line first paragraph.'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -5,6 +5,7 @@
test_description='Format-patch numbering options'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -2,6 +2,7 @@
test_description='difference in submodules'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff.sh

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='format-patch mime headers and extra headers do not conflict'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'create commit with utf-8 body' '

View File

@ -2,6 +2,7 @@
test_description='format-patch -s should force MIME encoding as needed'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -2,6 +2,7 @@
test_description='diff with assume-unchanged entries'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# external diff has been tested in t4020-diff-external.sh

View File

@ -5,6 +5,7 @@
test_description='diff.context configuration'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -4,6 +4,7 @@ test_description='test combined/stat/moved interaction'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# This test covers a weird 3-way interaction between "--cc -p", which will run

View File

@ -4,6 +4,7 @@ test_description='apply to deeper directory without getting fooled with symlink'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -2,7 +2,6 @@
test_description='apply empty'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

View File

@ -2,6 +2,7 @@
test_description='apply same filename'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -6,6 +6,8 @@
test_description='Test --follow should always find copies hard in git log.
'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-diff.sh

View File

@ -8,6 +8,7 @@ test_description='Test for "git log --decorate" colors'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -2,6 +2,7 @@
test_description='git log with invalid commit headers'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -4,6 +4,8 @@
#
test_description='mmap sliding window tests'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success \

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='bounds-checking of access to mmapped on-disk file formats'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
clear_base () {

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='pack-objects breaks long cross-pack delta chains'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# This mirrors a repeated push setup:

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='exercise delta islands'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# returns true iff $1 is a delta based on $2

View File

@ -4,6 +4,7 @@ test_description='pack-objects object selection using sparse algorithm'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup repo' '

View File

@ -4,6 +4,7 @@ test_description='git remote group handling'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
mark() {

View File

@ -2,6 +2,7 @@
test_description='fetch follows remote-tracking branches correctly'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -14,6 +14,7 @@ export GIT_TEST_PROTOCOL_VERSION
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
build_script () {

View File

@ -8,6 +8,7 @@ test_description='fetch exit status test'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='fetching via git:// using core.gitproxy'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup remote repo' '

View File

@ -13,6 +13,7 @@ Unless the directory already exists, in which case we clean up only what we
wrote.
'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
corrupt_repo () {

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='selecting remote repo in ambiguous cases'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
reset() {

View File

@ -4,6 +4,7 @@
#
test_description='Tests git rev-list --bisect functionality'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions

View File

@ -5,6 +5,7 @@
test_description='Tests git rev-list --topo-order functionality'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions

View File

@ -2,6 +2,7 @@
test_description='git rev-list --max-count and --skip test'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -5,6 +5,7 @@ test_description='rev-list/rev-parse --glob'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
commit () {

View File

@ -2,6 +2,7 @@
test_description='rev-list testing in-commit-order'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup a commit history with trees, blobs' '

View File

@ -8,6 +8,7 @@ test_description='Test git rev-parse with different parent options'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_cmp_rev_output () {

View File

@ -4,6 +4,7 @@ test_description='operations that cull histories in unusual ways'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='rev-list with .keep packs'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success 'setup' '

View File

@ -1,6 +1,8 @@
#!/bin/sh
test_description='test case insensitive pathspec limiting'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
if test_have_prereq CASE_INSENSITIVE_FS

View File

@ -1,6 +1,7 @@
#!/bin/sh
test_description='filter-branch removal of trees with null sha1'
. ./test-lib.sh
test_expect_success 'setup: base commits' '

View File

@ -4,6 +4,8 @@
#
test_description='repack involving cyclic alternate'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
test_expect_success setup '

View File

@ -4,6 +4,7 @@ test_description='git send-email'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
# May be altered later in the test

View File

@ -8,6 +8,7 @@ test_description='git svn basic tests'
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
TEST_FAILS_SANITIZE_LEAK=true
. ./lib-git-svn.sh
prepare_utf8_locale

Some files were not shown because too many files have changed in this diff Show More