diff options
author | Taylor Blau <me@ttaylorr.com> | 2023-07-10 23:12:39 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-07-10 23:48:56 +0200 |
commit | 15af64dcfd176b65cdb938e9b7f27adb8aabffa4 (patch) | |
tree | ce98614a9e078badeabefda1a664378301b8bf22 /refs.c | |
parent | refs.h: let `for_each_namespaced_ref()` take excluded patterns (diff) | |
download | git-15af64dcfd176b65cdb938e9b7f27adb8aabffa4.tar.xz git-15af64dcfd176b65cdb938e9b7f27adb8aabffa4.zip |
refs.h: implement `hidden_refs_to_excludes()`
In subsequent commits, we'll teach `receive-pack` and `upload-pack` to
use the new jump list feature in the packed-refs iterator by ignoring
references which are mentioned via its respective hideRefs lists.
However, the packed-ref jump lists cannot handle un-hiding rules (that
begin with '!'), or namespace comparisons (that begin with '^'). Add a
convenience function to the refs.h API to detect when either of these
conditions are met, and returns an appropriate value to pass as excluded
patterns.
Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs.c')
-rw-r--r-- | refs.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -1480,6 +1480,30 @@ int ref_is_hidden(const char *refname, const char *refname_full, return 0; } +const char **hidden_refs_to_excludes(const struct strvec *hide_refs) +{ + const char **pattern; + for (pattern = hide_refs->v; *pattern; pattern++) { + /* + * We can't feed any excludes from hidden refs config + * sections, since later rules may override previous + * ones. For example, with rules "refs/foo" and + * "!refs/foo/bar", we should show "refs/foo/bar" (and + * everything underneath it), but the earlier exclusion + * would cause us to skip all of "refs/foo". We + * likewise don't implement the namespace stripping + * required for '^' rules. + * + * Both are possible to do, but complicated, so avoid + * populating the jump list at all if we see either of + * these patterns. + */ + if (**pattern == '!' || **pattern == '^') + return NULL; + } + return hide_refs->v; +} + const char *find_descendant_ref(const char *dirname, const struct string_list *extras, const struct string_list *skip) |