From: Junio C Hamano Date: Wed, 15 Nov 2017 03:14:29 +0000 (+0900) Subject: Merge branch 'mh/tidy-ref-update-flags' X-Git-Tag: v2.16.0-rc0~132 X-Git-Url: http://git.bitbasher.net/?a=commitdiff_plain;h=a97222978ab3e0e86e87dccacf59269a9060de9e;p=git.git Merge branch 'mh/tidy-ref-update-flags' Code clean-up in refs API implementation. * mh/tidy-ref-update-flags: refs: update some more docs to use "oid" rather than "sha1" write_packed_entry(): take `object_id` arguments refs: rename constant `REF_ISPRUNING` to `REF_IS_PRUNING` refs: rename constant `REF_NODEREF` to `REF_NO_DEREF` refs: tidy up and adjust visibility of the `ref_update` flags ref_transaction_add_update(): remove a check ref_transaction_update(): die on disallowed flags prune_ref(): call `ref_transaction_add_update()` directly files_transaction_prepare(): don't leak flags to packed transaction --- a97222978ab3e0e86e87dccacf59269a9060de9e diff --cc bisect.c index de551c6d5e,c09f7bbbcb..0fca17c02b --- a/bisect.c +++ b/bisect.c @@@ -1055,40 -1045,3 +1055,40 @@@ int estimate_bisect_steps(int all return (e < 3 * x) ? n : n - 1; } + +static int mark_for_removal(const char *refname, const struct object_id *oid, + int flag, void *cb_data) +{ + struct string_list *refs = cb_data; + char *ref = xstrfmt("refs/bisect%s", refname); + string_list_append(refs, ref); + return 0; +} + +int bisect_clean_state(void) +{ + int result = 0; + + /* There may be some refs packed during bisection */ + struct string_list refs_for_removal = STRING_LIST_INIT_NODUP; + for_each_ref_in("refs/bisect", mark_for_removal, (void *) &refs_for_removal); + string_list_append(&refs_for_removal, xstrdup("BISECT_HEAD")); - result = delete_refs("bisect: remove", &refs_for_removal, REF_NODEREF); ++ result = delete_refs("bisect: remove", &refs_for_removal, REF_NO_DEREF); + refs_for_removal.strdup_strings = 1; + string_list_clear(&refs_for_removal, 0); + unlink_or_warn(git_path_bisect_expected_rev()); + unlink_or_warn(git_path_bisect_ancestors_ok()); + unlink_or_warn(git_path_bisect_log()); + unlink_or_warn(git_path_bisect_names()); + unlink_or_warn(git_path_bisect_run()); + unlink_or_warn(git_path_bisect_terms()); + /* Cleanup head-name if it got left by an old version of git-bisect */ + unlink_or_warn(git_path_head_name()); + /* + * Cleanup BISECT_START last to support the --no-checkout option + * introduced in the commit 4796e823a. + */ + unlink_or_warn(git_path_bisect_start()); + + return result; +}