summaryrefslogtreecommitdiff
path: root/bisect.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2022-04-13 20:01:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-04-14 06:56:08 (GMT)
commitf196c1e908db9242206e1fc9c64f33baf92676bb (patch)
tree9cd60bdf5437d0aa3037d32cbecdc12946713a9f /bisect.c
parent296a1438455d366475570ac49afb466f591417dc (diff)
downloadgit-f196c1e908db9242206e1fc9c64f33baf92676bb.zip
git-f196c1e908db9242206e1fc9c64f33baf92676bb.tar.gz
git-f196c1e908db9242206e1fc9c64f33baf92676bb.tar.bz2
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 'bisect.c')
-rw-r--r--bisect.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/bisect.c b/bisect.c
index cc6b8b6..b63669c 100644
--- a/bisect.c
+++ b/bisect.c
@@ -1010,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;
@@ -1035,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);
@@ -1060,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;
@@ -1087,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;
@@ -1106,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)