Message ID | 20200412133022.17590-4-worldhello.net@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | New proc-receive hook for centralized workflow | expand |
Jiang Xin <worldhello.net@gmail.com> writes: > From: Jiang Xin <zhiyou.jx@alibaba-inc.com> > > Add new function `ref_is_matched()` to reuse `ref_is_hidden()`. Will use ref_is_matched() may not be wrong per-se, but I would imagine that ref_matches() would sound more natural. The ancient varilabe hide_refs is probably misnamed and should be renamed when the codebase is quiescent to hidden_refs but of course we shouldn't do so before stablizing this series.
Junio C Hamano <gitster@pobox.com> 于2020年4月13日周一 上午5:38写道: > > Jiang Xin <worldhello.net@gmail.com> writes: > > > From: Jiang Xin <zhiyou.jx@alibaba-inc.com> > > > > Add new function `ref_is_matched()` to reuse `ref_is_hidden()`. Will use > > ref_is_matched() may not be wrong per-se, but I would imagine that > ref_matches() would sound more natural. Will do. > > The ancient varilabe hide_refs is probably misnamed and should be > renamed when the codebase is quiescent to hidden_refs but of course > we shouldn't do so before stablizing this series. >
diff --git a/refs.c b/refs.c index 1ab0bb54d3..229159ea1a 100644 --- a/refs.c +++ b/refs.c @@ -1389,13 +1389,18 @@ int parse_hide_refs_config(const char *var, const char *value, const char *secti } int ref_is_hidden(const char *refname, const char *refname_full) +{ + return ref_is_matched(hide_refs, refname, refname_full); +} + +int ref_is_matched(struct string_list *match_refs, const char *refname, const char *refname_full) { int i; - if (!hide_refs) + if (!match_refs) return 0; - for (i = hide_refs->nr - 1; i >= 0; i--) { - const char *match = hide_refs->items[i].string; + for (i = match_refs->nr - 1; i >= 0; i--) { + const char *match = match_refs->items[i].string; const char *subject; int neg = 0; const char *p; diff --git a/refs.h b/refs.h index 545029c6d8..a2ea043f7f 100644 --- a/refs.h +++ b/refs.h @@ -739,6 +739,7 @@ int parse_hide_refs_config(const char *var, const char *value, const char *); * parameter always points to the full ref name. */ int ref_is_hidden(const char *, const char *); +int ref_is_matched(struct string_list *, const char *, const char *); enum ref_type { REF_TYPE_PER_WORKTREE, /* refs inside refs/ but not shared */