Skip to content

Commit 67985e4

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Reviewed-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d653c5 commit 67985e4

File tree

6 files changed

+22
-36
lines changed

6 files changed

+22
-36
lines changed

builtin/rev-parse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
863863
continue;
864864
}
865865
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);
868868
continue;
869869
}
870870
if (opt_with_value(arg, "--branches", &arg)) {

ls-refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ int ls_refs(struct repository *r, struct packet_reader *request)
171171
if (!data.prefixes.nr)
172172
strvec_push(&data.prefixes, "");
173173
for_each_fullref_in_prefixes(get_git_namespace(), data.prefixes.v,
174-
send_ref, &data, 0);
174+
send_ref, &data);
175175
packet_fflush(stdout);
176176
strvec_clear(&data.prefixes);
177177
strbuf_release(&data.buf);

ref-filter.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,16 +2100,15 @@ static int filter_pattern_match(struct ref_filter *filter, const char *refname)
21002100
*/
21012101
static int for_each_fullref_in_pattern(struct ref_filter *filter,
21022102
each_ref_fn cb,
2103-
void *cb_data,
2104-
int broken)
2103+
void *cb_data)
21052104
{
21062105
if (!filter->match_as_path) {
21072106
/*
21082107
* in this case, the patterns are applied after
21092108
* prefixes like "refs/heads/" etc. are stripped off,
21102109
* so we have to look at everything:
21112110
*/
2112-
return for_each_fullref_in("", cb, cb_data, broken);
2111+
return for_each_fullref_in("", cb, cb_data);
21132112
}
21142113

21152114
if (filter->ignore_case) {
@@ -2118,16 +2117,16 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
21182117
* so just return everything and let the caller
21192118
* sort it out.
21202119
*/
2121-
return for_each_fullref_in("", cb, cb_data, broken);
2120+
return for_each_fullref_in("", cb, cb_data);
21222121
}
21232122

21242123
if (!filter->name_patterns[0]) {
21252124
/* 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);
21272126
}
21282127

21292128
return for_each_fullref_in_prefixes(NULL, filter->name_patterns,
2130-
cb, cb_data, broken);
2129+
cb, cb_data);
21312130
}
21322131

21332132
/*
@@ -2425,13 +2424,13 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
24252424
* of filter_ref_kind().
24262425
*/
24272426
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);
24292428
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);
24312430
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);
24332432
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);
24352434
if (!ret && (filter->kind & FILTER_REFS_DETACHED_HEAD))
24362435
head_ref(ref_filter_handler, &ref_cbdata);
24372436
}

refs.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,25 +1522,16 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
15221522
return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
15231523
}
15241524

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)
15261526
{
1527-
enum do_for_each_ref_flags flag = 0;
1528-
1529-
if (broken)
1530-
flag = DO_FOR_EACH_INCLUDE_BROKEN;
15311527
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);
15331529
}
15341530

15351531
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)
15381533
{
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);
15441535
}
15451536

15461537
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,
16321623

16331624
int for_each_fullref_in_prefixes(const char *namespace,
16341625
const char **patterns,
1635-
each_ref_fn fn, void *cb_data,
1636-
unsigned int broken)
1626+
each_ref_fn fn, void *cb_data)
16371627
{
16381628
struct string_list prefixes = STRING_LIST_INIT_DUP;
16391629
struct string_list_item *prefix;
@@ -1648,7 +1638,7 @@ int for_each_fullref_in_prefixes(const char *namespace,
16481638

16491639
for_each_string_list_item(prefix, &prefixes) {
16501640
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);
16521642
if (ret)
16531643
break;
16541644
strbuf_setlen(&buf, namespace_len);

refs.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,8 @@ int for_each_ref(each_ref_fn fn, void *cb_data);
342342
int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data);
343343

344344
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);
349347

350348
/**
351349
* 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,
354352
* callers should be prepared to ignore references that they did not ask for.
355353
*/
356354
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);
359356
/**
360357
* iterate refs from the respective area.
361358
*/

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2548,7 +2548,7 @@ static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn,
25482548
struct strbuf bisect_refs = STRBUF_INIT;
25492549
int status;
25502550
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);
25522552
strbuf_release(&bisect_refs);
25532553
return status;
25542554
}

0 commit comments

Comments
 (0)