зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
2d653c5036
Коммит
67985e4e4a
|
@ -863,8 +863,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "--bisect")) {
|
||||
for_each_fullref_in("refs/bisect/bad", show_reference, NULL, 0);
|
||||
for_each_fullref_in("refs/bisect/good", anti_reference, NULL, 0);
|
||||
for_each_fullref_in("refs/bisect/bad", show_reference, NULL);
|
||||
for_each_fullref_in("refs/bisect/good", anti_reference, NULL);
|
||||
continue;
|
||||
}
|
||||
if (opt_with_value(arg, "--branches", &arg)) {
|
||||
|
|
|
@ -171,7 +171,7 @@ int ls_refs(struct repository *r, struct packet_reader *request)
|
|||
if (!data.prefixes.nr)
|
||||
strvec_push(&data.prefixes, "");
|
||||
for_each_fullref_in_prefixes(get_git_namespace(), data.prefixes.v,
|
||||
send_ref, &data, 0);
|
||||
send_ref, &data);
|
||||
packet_fflush(stdout);
|
||||
strvec_clear(&data.prefixes);
|
||||
strbuf_release(&data.buf);
|
||||
|
|
19
ref-filter.c
19
ref-filter.c
|
@ -2100,8 +2100,7 @@ static int filter_pattern_match(struct ref_filter *filter, const char *refname)
|
|||
*/
|
||||
static int for_each_fullref_in_pattern(struct ref_filter *filter,
|
||||
each_ref_fn cb,
|
||||
void *cb_data,
|
||||
int broken)
|
||||
void *cb_data)
|
||||
{
|
||||
if (!filter->match_as_path) {
|
||||
/*
|
||||
|
@ -2109,7 +2108,7 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
|
|||
* prefixes like "refs/heads/" etc. are stripped off,
|
||||
* so we have to look at everything:
|
||||
*/
|
||||
return for_each_fullref_in("", cb, cb_data, broken);
|
||||
return for_each_fullref_in("", cb, cb_data);
|
||||
}
|
||||
|
||||
if (filter->ignore_case) {
|
||||
|
@ -2118,16 +2117,16 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
|
|||
* so just return everything and let the caller
|
||||
* sort it out.
|
||||
*/
|
||||
return for_each_fullref_in("", cb, cb_data, broken);
|
||||
return for_each_fullref_in("", cb, cb_data);
|
||||
}
|
||||
|
||||
if (!filter->name_patterns[0]) {
|
||||
/* no patterns; we have to look at everything */
|
||||
return for_each_fullref_in("", cb, cb_data, broken);
|
||||
return for_each_fullref_in("", cb, cb_data);
|
||||
}
|
||||
|
||||
return for_each_fullref_in_prefixes(NULL, filter->name_patterns,
|
||||
cb, cb_data, broken);
|
||||
cb, cb_data);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2425,13 +2424,13 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
|
|||
* of filter_ref_kind().
|
||||
*/
|
||||
if (filter->kind == FILTER_REFS_BRANCHES)
|
||||
ret = for_each_fullref_in("refs/heads/", ref_filter_handler, &ref_cbdata, 0);
|
||||
ret = for_each_fullref_in("refs/heads/", ref_filter_handler, &ref_cbdata);
|
||||
else if (filter->kind == FILTER_REFS_REMOTES)
|
||||
ret = for_each_fullref_in("refs/remotes/", ref_filter_handler, &ref_cbdata, 0);
|
||||
ret = for_each_fullref_in("refs/remotes/", ref_filter_handler, &ref_cbdata);
|
||||
else if (filter->kind == FILTER_REFS_TAGS)
|
||||
ret = for_each_fullref_in("refs/tags/", ref_filter_handler, &ref_cbdata, 0);
|
||||
ret = for_each_fullref_in("refs/tags/", ref_filter_handler, &ref_cbdata);
|
||||
else if (filter->kind & FILTER_REFS_ALL)
|
||||
ret = for_each_fullref_in_pattern(filter, ref_filter_handler, &ref_cbdata, 0);
|
||||
ret = for_each_fullref_in_pattern(filter, ref_filter_handler, &ref_cbdata);
|
||||
if (!ret && (filter->kind & FILTER_REFS_DETACHED_HEAD))
|
||||
head_ref(ref_filter_handler, &ref_cbdata);
|
||||
}
|
||||
|
|
22
refs.c
22
refs.c
|
@ -1522,25 +1522,16 @@ int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)
|
|||
return refs_for_each_ref_in(get_main_ref_store(the_repository), prefix, fn, cb_data);
|
||||
}
|
||||
|
||||
int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data, unsigned int broken)
|
||||
int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
enum do_for_each_ref_flags flag = 0;
|
||||
|
||||
if (broken)
|
||||
flag = DO_FOR_EACH_INCLUDE_BROKEN;
|
||||
return do_for_each_ref(get_main_ref_store(the_repository),
|
||||
prefix, fn, 0, flag, cb_data);
|
||||
prefix, fn, 0, 0, cb_data);
|
||||
}
|
||||
|
||||
int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
|
||||
each_ref_fn fn, void *cb_data,
|
||||
unsigned int broken)
|
||||
each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
enum do_for_each_ref_flags flag = 0;
|
||||
|
||||
if (broken)
|
||||
flag = DO_FOR_EACH_INCLUDE_BROKEN;
|
||||
return do_for_each_ref(refs, prefix, fn, 0, flag, cb_data);
|
||||
return do_for_each_ref(refs, prefix, fn, 0, 0, cb_data);
|
||||
}
|
||||
|
||||
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,
|
|||
|
||||
int for_each_fullref_in_prefixes(const char *namespace,
|
||||
const char **patterns,
|
||||
each_ref_fn fn, void *cb_data,
|
||||
unsigned int broken)
|
||||
each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
struct string_list prefixes = STRING_LIST_INIT_DUP;
|
||||
struct string_list_item *prefix;
|
||||
|
@ -1648,7 +1638,7 @@ int for_each_fullref_in_prefixes(const char *namespace,
|
|||
|
||||
for_each_string_list_item(prefix, &prefixes) {
|
||||
strbuf_addstr(&buf, prefix->string);
|
||||
ret = for_each_fullref_in(buf.buf, fn, cb_data, broken);
|
||||
ret = for_each_fullref_in(buf.buf, fn, cb_data);
|
||||
if (ret)
|
||||
break;
|
||||
strbuf_setlen(&buf, namespace_len);
|
||||
|
|
9
refs.h
9
refs.h
|
@ -342,10 +342,8 @@ int for_each_ref(each_ref_fn fn, void *cb_data);
|
|||
int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data);
|
||||
|
||||
int refs_for_each_fullref_in(struct ref_store *refs, const char *prefix,
|
||||
each_ref_fn fn, void *cb_data,
|
||||
unsigned int broken);
|
||||
int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data,
|
||||
unsigned int broken);
|
||||
each_ref_fn fn, void *cb_data);
|
||||
int for_each_fullref_in(const char *prefix, each_ref_fn fn, void *cb_data);
|
||||
|
||||
/**
|
||||
* 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,
|
|||
* callers should be prepared to ignore references that they did not ask for.
|
||||
*/
|
||||
int for_each_fullref_in_prefixes(const char *namespace, const char **patterns,
|
||||
each_ref_fn fn, void *cb_data,
|
||||
unsigned int broken);
|
||||
each_ref_fn fn, void *cb_data);
|
||||
/**
|
||||
* iterate refs from the respective area.
|
||||
*/
|
||||
|
|
|
@ -2548,7 +2548,7 @@ static int for_each_bisect_ref(struct ref_store *refs, each_ref_fn fn,
|
|||
struct strbuf bisect_refs = STRBUF_INIT;
|
||||
int status;
|
||||
strbuf_addf(&bisect_refs, "refs/bisect/%s", term);
|
||||
status = refs_for_each_fullref_in(refs, bisect_refs.buf, fn, cb_data, 0);
|
||||
status = refs_for_each_fullref_in(refs, bisect_refs.buf, fn, cb_data);
|
||||
strbuf_release(&bisect_refs);
|
||||
return status;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче