From: Junio C Hamano Date: Tue, 7 Jun 2022 21:10:56 +0000 (-0700) Subject: Merge branch 'ab/plug-leak-in-revisions' X-Git-Tag: v2.37.0-rc0~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2da81d1efb0166e1cec7a8582b837994dde6225b;p=thirdparty%2Fgit.git 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" ... --- 2da81d1efb0166e1cec7a8582b837994dde6225b diff --cc builtin/add.c index 145fc9b8f2,fc729e14c1..f84372964c --- a/builtin/add.c +++ b/builtin/add.c @@@ -141,17 -141,8 +141,17 @@@ int add_files_to_cache(const char *pref rev.diffopt.format_callback_data = &data; rev.diffopt.flags.override_submodule_config = 1; rev.max_count = 0; /* do not compare unmerged paths with stage #2 */ + + /* + * Use an ODB transaction to optimize adding multiple objects. + * This function is invoked from commands other than 'add', which + * may not have their own transaction active. + */ + begin_odb_transaction(); run_diff_files(&rev, DIFF_RACY_IS_MODIFIED); + end_odb_transaction(); + - clear_pathspec(&rev.prune_data); + release_revisions(&rev); return !!data.add_errors; } diff --cc builtin/log.c index 2eb0063cc1,c40ebe1c3f..88a5e98875 --- a/builtin/log.c +++ b/builtin/log.c @@@ -745,12 -738,7 +752,11 @@@ int cmd_show(int argc, const char **arg ret = error(_("unknown type: %d"), o->type); } } + + rev.diffopt.no_free = 0; + diff_free(&rev.diffopt); + - free(objects); - return ret; + return cmd_log_deinit(ret, &rev); } /* diff --cc submodule.c index 86c8f0f89d,e9c320d16d..7923e951e1 --- a/submodule.c +++ b/submodule.c @@@ -928,9 -905,10 +928,10 @@@ static void collect_changed_submodules( } reset_revision_walk(); + release_revisions(&rev); } -static void free_submodules_oids(struct string_list *submodules) +static void free_submodules_data(struct string_list *submodules) { struct string_list_item *item; for_each_string_list_item(item, submodules)