refs: drop "broken" flag from for_each_fullref_in()

No callers pass in anything but "0" here. Likewise to our sibling functions. Note that some of them ferry along the flag, but none of their callers pass anything but "0" either. Nor is anybody likely to change that. Callers which really want to see all of the raw refs use for_each_rawref(). And anybody interested in iterating a subset of the refs will likely be happy to use the now-default behavior of showing broken refs, but omitting dangling symlinks. So we can get rid of this whole feature. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Sep 24, 2021 at 14:48 UTC 67985e4e4aa85f11593b1aec35cf7cd7e9d02fba
6 files changed +22 -36
builtin/rev-parse.c
+2 -2
@@ -863,8 +863,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
863 continue;
864 }
865 if (!strcmp(arg, "--bisect")) {
866 - for_each_fullref_in("refs/bisect/bad", show_reference, NULL, 0);
867 - for_each_fullref_in("refs/bisect/good", anti_reference, NULL, 0);
866 + for_each_fullref_in("refs/bisect/bad", show_reference, NULL);
867 + for_each_fullref_in("refs/bisect/good", anti_reference, NULL);
868 continue;
869 }
870 if (opt_with_value(arg, "--branches", &arg)) {
ls-refs.c
+1 -1
@@ -171,7 +171,7 @@ int ls_refs(struct repository *r, struct packet_reader *request)
171 if (!data.prefixes.nr)
172 strvec_push(&data.prefixes, "");
173 for_each_fullref_in_prefixes(get_git_namespace(), data.prefixes.v,
174 - send_ref, &data, 0);
174 + send_ref, &data);
175 packet_fflush(stdout);
176 strvec_clear(&data.prefixes);
177 strbuf_release(&data.buf);
ref-filter.c
+9 -10
@@ -2100,8 +2100,7 @@ static int filter_pattern_match(struct ref_filter *filter, const char *refname)
2100 */
2101 static int for_each_fullref_in_pattern(struct ref_filter *filter,
2102 each_ref_fn cb,
2103 - void *cb_data,
2104 - int broken)
2103 + void *cb_data)
2104 {
2105 if (!filter->match_as_path) {
2106 /*
@@ -2109,7 +2108,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
2108 * prefixes like "refs/heads/" etc. are stripped off,
2109 * so we have to look at everything:
2110 */
2112 - return for_each_fullref_in("", cb, cb_data, broken);
2111 + return for_each_fullref_in("", cb, cb_data);
2112 }
2113
2114 if (filter->ignore_case) {
@@ -2118,16 +2117,16 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
2117 * so just return everything and let the caller
2118 * sort it out.
2119 */
2121 - return for_each_fullref_in("", cb, cb_data, broken);
2120 + return for_each_fullref_in("", cb, cb_data);
2121 }
2122
2123 if (!filter->name_patterns[0]) {
2124 /* no patterns; we have to look at everything */
2126 - return for_each_fullref_in("", cb, cb_data, broken);
2125 + return for_each_fullref_in("", cb, cb_data);
2126 }
2127
2128 return for_each_fullref_in_prefixes(NULL, filter->name_patterns,
2130 - cb, cb_data, broken);
2129 + cb, cb_data);
2130 }
2131
2132 /*
@@ -2425,13 +2424,13 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
2424 * of filter_ref_kind().
2425 */
2426 if (filter->kind == FILTER_REFS_BRANCHES)
2428 - ret = for_each_fullref_in("refs/heads/", ref_filter_handler, &ref_cbdata, 0);
2427 + ret = for_each_fullref_in("refs/heads/", ref_filter_handler, &ref_cbdata);
2428 else if (filter->kind == FILTER_REFS_REMOTES)
2430 - ret = for_each_fullref_in("refs/remotes/", ref_filter_handler, &ref_cbdata, 0);
2429 + ret = for_each_fullref_in("refs/remotes/", ref_filter_handler, &ref_cbdata);
2430 else if (filter->kind == FILTER_REFS_TAGS)
2432 - ret = for_each_fullref_in("refs/tags/", ref_filter_handler, &ref_cbdata, 0);
2431 + ret = for_each_fullref_in("refs/tags/", ref_filter_handler, &ref_cbdata);
2432 else if (filter->kind & FILTER_REFS_ALL)
2434 - ret = for_each_fullref_in_pattern(filter, ref_filter_handler, &ref_cbdata, 0);
2433 + ret = for_each_fullref_in_pattern(filter, ref_filter_handler, &ref_cbdata);
2434 if (!ret && (filter->kind & FILTER_REFS_DETACHED_HEAD))
2435 head_ref(ref_filter_handler, &ref_cbdata);
2436 }
refs.c
+6 -16
@@ -1522,25 +1522,16 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
1522 return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
1523 }
1524
1525 -int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data, unsigned int broken)
1525 +int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data)
1526 {
1527 - enum do_for_each_ref_flags flag = 0;
1528 -
1529 - if (broken)
1530 - flag = DO_FOR_EACH_INCLUDE_BROKEN;
1527 return do_for_each_ref(get_main_ref_store(the_repository),
1532 - prefix, fn, 0, flag, cb_data);
1528 + prefix, fn, 0, 0, cb_data);
1529 }
1530
1531 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
1536 - each_ref_fn fn, void *cb_data,
1537 - unsigned int broken)
1532 + each_ref_fn fn, void *cb_data)
1533 {
1539 - enum do_for_each_ref_flags flag = 0;
1540 -
1541 - if (broken)
1542 - flag = DO_FOR_EACH_INCLUDE_BROKEN;
1543 - return do_for_each_ref(refs, prefix, fn, 0, flag, cb_data);
1534 + return do_for_each_ref(refs, prefix, fn, 0, 0, cb_data);
1535 }
1536
1537 int for_each_replace_ref(struct repository *r, each_repo_ref_fn fn, void *cb_data)
@@ -1632,8 +1623,7 @@ static void find_longest_prefixes(struct string_list *out,
1623
1624 int for_each_fullref_in_prefixes(const char *namespace,
1625 const char **patterns,
1635 - each_ref_fn fn, void *cb_data,
1636 - unsigned int broken)
1626 + each_ref_fn fn, void *cb_data)
1627 {
1628 struct string_list prefixes = STRING_LIST_INIT_DUP;
1629 struct string_list_item *prefix;
@@ -1648,7 +1638,7 @@ int for_each_fullref_in_prefixes(const char *namespace,
1638
1639 for_each_string_list_item(prefix, &prefixes) {
1640 strbuf_addstr(&buf, prefix->string);
1651 - ret = for_each_fullref_in(buf.buf, fn, cb_data, broken);
1641 + ret = for_each_fullref_in(buf.buf, fn, cb_data);
1642 if (ret)
1643 break;
1644 strbuf_setlen(&buf, namespace_len);
refs.h
+3 -6
@@ -342,10 +342,8 @@ int for_each_ref(each_ref_fn fn, void *cb_data);
342 int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data);
343
344 int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
345 - each_ref_fn fn, void *cb_data,
346 - unsigned int broken);
347 -int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data,
348 - unsigned int broken);
345 + each_ref_fn fn, void *cb_data);
346 +int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data);
347
348 /**
349 * iterate all refs in "patterns" by partitioning patterns into disjoint sets
@@ -354,8 +352,7 @@ int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data,
352 * callers should be prepared to ignore references that they did not ask for.
353 */
354 int for_each_fullref_in_prefixes(const char *namespace, const char **patterns,
357 - each_ref_fn fn, void *cb_data,
358 - unsigned int broken);
355 + each_ref_fn fn, void *cb_data);
356 /**
357 * iterate refs from the respective area.
358 */
revision.c
+1 -1
@@ -2548,7 +2548,7 @@ static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn,
2548 struct strbuf bisect_refs = STRBUF_INIT;
2549 int status;
2550 strbuf_addf(&bisect_refs, "refs/bisect/%s", term);
2551 - status = refs_for_each_fullref_in(refs, bisect_refs.buf, fn, cb_data, 0);
2551 + status = refs_for_each_fullref_in(refs, bisect_refs.buf, fn, cb_data);
2552 strbuf_release(&bisect_refs);
2553 return status;
2554 }