@@ -14,9 +14,9 @@ static char const * const pack_refs_usage[] = {
int cmd_pack_refs(int argc, const char **argv, const char *prefix)
{
unsigned int flags = PACK_REFS_PRUNE;
- static struct ref_exclusions excludes = REF_EXCLUSIONS_INIT;
+ static struct ref_visibility visibility = REF_VISIBILITY_INIT;
static struct string_list included_refs = STRING_LIST_INIT_NODUP;
- struct pack_refs_opts pack_refs_opts = { .exclusions = &excludes,
+ struct pack_refs_opts pack_refs_opts = { .visibility = &visibility,
.includes = &included_refs,
.flags = flags };
static struct string_list option_excluded_refs = STRING_LIST_INIT_NODUP;
@@ -36,7 +36,7 @@ int cmd_pack_refs(int argc, const char **argv, const char *prefix)
usage_with_options(pack_refs_usage, opts);
for_each_string_list_item(item, &option_excluded_refs)
- add_ref_exclusion(pack_refs_opts.exclusions, item->string);
+ add_ref_exclusion(pack_refs_opts.visibility, item->string);
if (pack_refs_opts.flags & PACK_REFS_ALL)
string_list_append(pack_refs_opts.includes, "*");
@@ -46,7 +46,7 @@ static int abbrev_ref_strict;
static int output_sq;
static int stuck_long;
-static struct ref_exclusions ref_excludes = REF_EXCLUSIONS_INIT;
+static struct ref_visibility refs_visible = REF_VISIBILITY_INIT;
/*
* Some arguments are relevant "revision" arguments,
@@ -208,7 +208,7 @@ static int show_default(void)
static int show_reference(const char *refname, const struct object_id *oid,
int flag UNUSED, void *cb_data UNUSED)
{
- if (ref_excluded(&ref_excludes, refname))
+ if (ref_excluded(&refs_visible, refname))
return 0;
show_rev(NORMAL, oid, refname);
return 0;
@@ -596,7 +596,7 @@ static void handle_ref_opt(const char *pattern, const char *prefix)
for_each_glob_ref_in(show_reference, pattern, prefix, NULL);
else
for_each_ref_in(prefix, show_reference, NULL);
- clear_ref_exclusions(&ref_excludes);
+ clear_ref_visibility(&refs_visible);
}
enum format_type {
@@ -874,7 +874,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
}
if (!strcmp(arg, "--all")) {
for_each_ref(show_reference, NULL);
- clear_ref_exclusions(&ref_excludes);
+ clear_ref_visibility(&refs_visible);
continue;
}
if (skip_prefix(arg, "--disambiguate=", &arg)) {
@@ -888,13 +888,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (opt_with_value(arg, "--branches", &arg)) {
- if (ref_excludes.hidden_refs_configured)
+ if (refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --branches"));
handle_ref_opt(arg, "refs/heads/");
continue;
}
if (opt_with_value(arg, "--tags", &arg)) {
- if (ref_excludes.hidden_refs_configured)
+ if (refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --tags"));
handle_ref_opt(arg, "refs/tags/");
continue;
@@ -904,17 +904,17 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
continue;
}
if (opt_with_value(arg, "--remotes", &arg)) {
- if (ref_excludes.hidden_refs_configured)
+ if (refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --remotes"));
handle_ref_opt(arg, "refs/remotes/");
continue;
}
if (skip_prefix(arg, "--exclude=", &arg)) {
- add_ref_exclusion(&ref_excludes, arg);
+ add_ref_exclusion(&refs_visible, arg);
continue;
}
if (skip_prefix(arg, "--exclude-hidden=", &arg)) {
- exclude_hidden_refs(&ref_excludes, arg);
+ exclude_hidden_refs(&refs_visible, arg);
continue;
}
if (!strcmp(arg, "--show-toplevel")) {
@@ -65,7 +65,7 @@ struct worktree;
struct pack_refs_opts {
unsigned int flags;
- struct ref_exclusions *exclusions;
+ struct ref_visibility *visibility;
struct string_list *includes;
};
@@ -1194,7 +1194,7 @@ static int should_pack_ref(const char *refname,
if (!ref_resolves_to_object(refname, the_repository, oid, ref_flags))
return 0;
- if (ref_excluded(opts->exclusions, refname))
+ if (ref_excluded(opts->visibility, refname))
return 0;
for_each_string_list_item(item, opts->includes)
@@ -1533,54 +1533,54 @@ static void add_rev_cmdline_list(struct rev_info *revs,
}
}
-int ref_excluded(const struct ref_exclusions *exclusions, const char *path)
+int ref_excluded(const struct ref_visibility *visibility, const char *path)
{
const char *stripped_path = strip_namespace(path);
struct string_list_item *item;
- for_each_string_list_item(item, &exclusions->excluded_refs) {
+ for_each_string_list_item(item, &visibility->excluded_refs) {
if (!wildmatch(item->string, path, 0))
return 1;
}
- if (ref_is_hidden(stripped_path, path, &exclusions->hidden_refs))
+ if (ref_is_hidden(stripped_path, path, &visibility->hidden_refs))
return 1;
return 0;
}
-void init_ref_exclusions(struct ref_exclusions *exclusions)
+void init_ref_visibility(struct ref_visibility *visibility)
{
- struct ref_exclusions blank = REF_EXCLUSIONS_INIT;
- memcpy(exclusions, &blank, sizeof(*exclusions));
+ struct ref_visibility blank = REF_VISIBILITY_INIT;
+ memcpy(visibility, &blank, sizeof(*visibility));
}
-void clear_ref_exclusions(struct ref_exclusions *exclusions)
+void clear_ref_visibility(struct ref_visibility *visibility)
{
- string_list_clear(&exclusions->excluded_refs, 0);
- string_list_clear(&exclusions->hidden_refs, 0);
- exclusions->hidden_refs_configured = 0;
+ string_list_clear(&visibility->excluded_refs, 0);
+ string_list_clear(&visibility->hidden_refs, 0);
+ visibility->hidden_refs_configured = 0;
}
-void add_ref_exclusion(struct ref_exclusions *exclusions, const char *exclude)
+void add_ref_exclusion(struct ref_visibility *visibility, const char *exclude)
{
- string_list_append(&exclusions->excluded_refs, exclude);
+ string_list_append(&visibility->excluded_refs, exclude);
}
struct exclude_hidden_refs_cb {
- struct ref_exclusions *exclusions;
+ struct ref_visibility *visibility;
const char *section;
};
static int hide_refs_config(const char *var, const char *value, void *cb_data)
{
struct exclude_hidden_refs_cb *cb = cb_data;
- cb->exclusions->hidden_refs_configured = 1;
+ cb->visibility->hidden_refs_configured = 1;
return parse_hide_refs_config(var, value, cb->section,
- &cb->exclusions->hidden_refs);
+ &cb->visibility->hidden_refs);
}
-void exclude_hidden_refs(struct ref_exclusions *exclusions, const char *section)
+void exclude_hidden_refs(struct ref_visibility *visibility, const char *section)
{
struct exclude_hidden_refs_cb cb;
@@ -1588,10 +1588,10 @@ void exclude_hidden_refs(struct ref_exclusions *exclusions, const char *section)
strcmp(section, "uploadpack"))
die(_("unsupported section for hidden refs: %s"), section);
- if (exclusions->hidden_refs_configured)
+ if (visibility->hidden_refs_configured)
die(_("--exclude-hidden= passed more than once"));
- cb.exclusions = exclusions;
+ cb.visibility = visibility;
cb.section = section;
git_config(hide_refs_config, &cb);
@@ -1612,7 +1612,7 @@ static int handle_one_ref(const char *path, const struct object_id *oid,
struct all_refs_cb *cb = cb_data;
struct object *object;
- if (ref_excluded(&cb->all_revs->ref_excludes, path))
+ if (ref_excluded(&cb->all_revs->refs_visible, path))
return 0;
object = get_reference(cb->all_revs, path, oid, cb->all_flags);
@@ -1935,7 +1935,7 @@ void repo_init_revisions(struct repository *r,
init_display_notes(&revs->notes_opt);
list_objects_filter_init(&revs->filter);
- init_ref_exclusions(&revs->ref_excludes);
+ init_ref_visibility(&revs->refs_visible);
}
static void add_pending_commit_list(struct rev_info *revs,
@@ -2724,12 +2724,12 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
init_all_refs_cb(&cb, revs, *flags);
other_head_refs(handle_one_ref, &cb);
}
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
} else if (!strcmp(arg, "--branches")) {
- if (revs->ref_excludes.hidden_refs_configured)
+ if (revs->refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --branches"));
handle_refs(refs, revs, *flags, refs_for_each_branch_ref);
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
} else if (!strcmp(arg, "--bisect")) {
read_bisect_terms(&term_bad, &term_good);
handle_refs(refs, revs, *flags, for_each_bad_bisect_ref);
@@ -2737,48 +2737,48 @@ static int handle_revision_pseudo_opt(struct rev_info *revs,
for_each_good_bisect_ref);
revs->bisect = 1;
} else if (!strcmp(arg, "--tags")) {
- if (revs->ref_excludes.hidden_refs_configured)
+ if (revs->refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --tags"));
handle_refs(refs, revs, *flags, refs_for_each_tag_ref);
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
} else if (!strcmp(arg, "--remotes")) {
- if (revs->ref_excludes.hidden_refs_configured)
+ if (revs->refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --remotes"));
handle_refs(refs, revs, *flags, refs_for_each_remote_ref);
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
} else if ((argcount = parse_long_opt("glob", argv, &optarg))) {
struct all_refs_cb cb;
init_all_refs_cb(&cb, revs, *flags);
for_each_glob_ref(handle_one_ref, optarg, &cb);
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
return argcount;
} else if ((argcount = parse_long_opt("exclude", argv, &optarg))) {
- add_ref_exclusion(&revs->ref_excludes, optarg);
+ add_ref_exclusion(&revs->refs_visible, optarg);
return argcount;
} else if ((argcount = parse_long_opt("exclude-hidden", argv, &optarg))) {
- exclude_hidden_refs(&revs->ref_excludes, optarg);
+ exclude_hidden_refs(&revs->refs_visible, optarg);
return argcount;
} else if (skip_prefix(arg, "--branches=", &optarg)) {
struct all_refs_cb cb;
- if (revs->ref_excludes.hidden_refs_configured)
+ if (revs->refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --branches"));
init_all_refs_cb(&cb, revs, *flags);
for_each_glob_ref_in(handle_one_ref, optarg, "refs/heads/", &cb);
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
} else if (skip_prefix(arg, "--tags=", &optarg)) {
struct all_refs_cb cb;
- if (revs->ref_excludes.hidden_refs_configured)
+ if (revs->refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --tags"));
init_all_refs_cb(&cb, revs, *flags);
for_each_glob_ref_in(handle_one_ref, optarg, "refs/tags/", &cb);
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
} else if (skip_prefix(arg, "--remotes=", &optarg)) {
struct all_refs_cb cb;
- if (revs->ref_excludes.hidden_refs_configured)
+ if (revs->refs_visible.hidden_refs_configured)
return error(_("--exclude-hidden cannot be used together with --remotes"));
init_all_refs_cb(&cb, revs, *flags);
for_each_glob_ref_in(handle_one_ref, optarg, "refs/remotes/", &cb);
- clear_ref_exclusions(&revs->ref_excludes);
+ clear_ref_visibility(&revs->refs_visible);
} else if (!strcmp(arg, "--reflog")) {
add_reflogs_to_pending(revs, *flags);
} else if (!strcmp(arg, "--indexed-objects")) {
@@ -84,7 +84,7 @@ struct rev_cmdline_info {
} *rev;
};
-struct ref_exclusions {
+struct ref_visibility {
/*
* Excluded refs is a list of wildmatch patterns. If any of the
* patterns match, the reference will be excluded.
@@ -106,9 +106,9 @@ struct ref_exclusions {
};
/**
- * Initialize a `struct ref_exclusions` with a macro.
+ * Initialize a `struct ref_visibility` with a macro.
*/
-#define REF_EXCLUSIONS_INIT { \
+#define REF_VISIBILITY_INIT { \
.excluded_refs = STRING_LIST_INIT_DUP, \
.hidden_refs = STRING_LIST_INIT_DUP, \
}
@@ -135,7 +135,7 @@ struct rev_info {
struct list_objects_filter_options filter;
/* excluding from --branches, --refs, etc. expansion */
- struct ref_exclusions ref_excludes;
+ struct ref_visibility refs_visible;
/* Basic information */
const char *prefix;
@@ -487,11 +487,11 @@ void show_object_with_name(FILE *, struct object *, const char *);
* Helpers to check if a reference should be excluded.
*/
-int ref_excluded(const struct ref_exclusions *exclusions, const char *path);
-void init_ref_exclusions(struct ref_exclusions *);
-void clear_ref_exclusions(struct ref_exclusions *);
-void add_ref_exclusion(struct ref_exclusions *, const char *exclude);
-void exclude_hidden_refs(struct ref_exclusions *, const char *section);
+int ref_excluded(const struct ref_visibility *exclusions, const char *path);
+void init_ref_visibility(struct ref_visibility *);
+void clear_ref_visibility(struct ref_visibility *);
+void add_ref_exclusion(struct ref_visibility *, const char *exclude);
+void exclude_hidden_refs(struct ref_visibility *, const char *section);
/**
* This function can be used if you want to add commit objects as revision
@@ -117,10 +117,10 @@ static struct flag_definition pack_flags[] = { FLAG_DEF(PACK_REFS_PRUNE),
static int cmd_pack_refs(struct ref_store *refs, const char **argv)
{
unsigned int flags = arg_flags(*argv++, "flags", pack_flags);
- static struct ref_exclusions exclusions = REF_EXCLUSIONS_INIT;
+ static struct ref_visibility visibility = REF_VISIBILITY_INIT;
static struct string_list included_refs = STRING_LIST_INIT_NODUP;
struct pack_refs_opts pack_opts = { .flags = flags,
- .exclusions = &exclusions,
+ .visibility = &visibility,
.includes = &included_refs };
if (pack_opts.flags & PACK_REFS_ALL)