diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2022-04-13 23:01:38 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-04-14 09:56:08 +0300 |
commit | f196c1e908db9242206e1fc9c64f33baf92676bb (patch) | |
tree | 9cd60bdf5437d0aa3037d32cbecdc12946713a9f /revision.h | |
parent | 296a1438455d366475570ac49afb466f591417dc (diff) |
revisions API users: use release_revisions() needing REV_INFO_INIT
Use release_revisions() to various users of "struct rev_list" which
need to have their "struct rev_info" zero-initialized before we can
start using it.
For the bundle.c code see the early exit case added in
3bbbe467f29 (bundle verify: error out if called without an object
database, 2019-05-27).
For the relevant bisect.c code see 45b6370812c (bisect: libify
`check_good_are_ancestors_of_bad` and its dependents, 2020-02-17).
For the submodule.c code see the "goto" on "(!left || !right || !sub)"
added in 8e6df65015f (submodule: refactor show_submodule_summary with
helper function, 2016-08-31).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'revision.h')
-rw-r--r-- | revision.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/revision.h b/revision.h index b9070e4342..2621eb6d65 100644 --- a/revision.h +++ b/revision.h @@ -330,6 +330,25 @@ struct rev_info { }; /** + * 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 * be NULL or can be prefix path, and then the `.prefix` variable will be set * to it. This is typically the first function you want to call when you want @@ -363,7 +382,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, /** * Free data allocated in a "struct rev_info" after it's been - * initialized with repo_init_revisions(). + * initialized with repo_init_revisions() or REV_INFO_INIT. */ void release_revisions(struct rev_info *revs); |