Merge branch 'ds/decorate-filter-tweak'
The namespaces used by "log --decorate" from "refs/" hierarchy by default has been tightened. * ds/decorate-filter-tweak: fetch: use ref_namespaces during prefetch maintenance: stop writing log.excludeDecoration log: create log.initialDecorationSet=all log: add --clear-decorations option log: add default decoration filter log-tree: use ref_namespaces instead of if/else-if refs: use ref_namespaces for replace refs base refs: add array of ref namespaces t4207: test coloring of grafted decorations t4207: modernize test refs: allow "HEAD" as decoration filter
This commit is contained in:
@ -490,7 +490,9 @@ static void filter_prefetch_refspec(struct refspec *rs)
|
||||
continue;
|
||||
if (!rs->items[i].dst ||
|
||||
(rs->items[i].src &&
|
||||
!strncmp(rs->items[i].src, "refs/tags/", 10))) {
|
||||
!strncmp(rs->items[i].src,
|
||||
ref_namespace[NAMESPACE_TAGS].ref,
|
||||
strlen(ref_namespace[NAMESPACE_TAGS].ref)))) {
|
||||
int j;
|
||||
|
||||
free(rs->items[i].src);
|
||||
@ -506,7 +508,7 @@ static void filter_prefetch_refspec(struct refspec *rs)
|
||||
}
|
||||
|
||||
old_dst = rs->items[i].dst;
|
||||
strbuf_addstr(&new_dst, "refs/prefetch/");
|
||||
strbuf_addstr(&new_dst, ref_namespace[NAMESPACE_PREFETCH].ref);
|
||||
|
||||
/*
|
||||
* If old_dst starts with "refs/", then place
|
||||
|
@ -910,12 +910,6 @@ static int fetch_remote(struct remote *remote, void *cbdata)
|
||||
|
||||
static int maintenance_task_prefetch(struct maintenance_run_opts *opts)
|
||||
{
|
||||
git_config_set_multivar_gently("log.excludedecoration",
|
||||
"refs/prefetch/",
|
||||
"refs/prefetch/",
|
||||
CONFIG_FLAGS_FIXED_VALUE |
|
||||
CONFIG_FLAGS_MULTI_REPLACE);
|
||||
|
||||
if (for_each_remote(fetch_remote, opts)) {
|
||||
error(_("failed to prefetch remotes"));
|
||||
return 1;
|
||||
|
@ -101,6 +101,20 @@ static int parse_decoration_style(const char *value)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int use_default_decoration_filter = 1;
|
||||
static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
|
||||
static struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP;
|
||||
static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
|
||||
|
||||
static int clear_decorations_callback(const struct option *opt,
|
||||
const char *arg, int unset)
|
||||
{
|
||||
string_list_clear(&decorate_refs_include, 0);
|
||||
string_list_clear(&decorate_refs_exclude, 0);
|
||||
use_default_decoration_filter = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int decorate_callback(const struct option *opt, const char *arg, int unset)
|
||||
{
|
||||
if (unset)
|
||||
@ -162,18 +176,61 @@ static void cmd_log_init_defaults(struct rev_info *rev)
|
||||
parse_date_format(default_date_mode, &rev->date_mode);
|
||||
}
|
||||
|
||||
static void set_default_decoration_filter(struct decoration_filter *decoration_filter)
|
||||
{
|
||||
int i;
|
||||
char *value = NULL;
|
||||
struct string_list *include = decoration_filter->include_ref_pattern;
|
||||
const struct string_list *config_exclude =
|
||||
git_config_get_value_multi("log.excludeDecoration");
|
||||
|
||||
if (config_exclude) {
|
||||
struct string_list_item *item;
|
||||
for_each_string_list_item(item, config_exclude)
|
||||
string_list_append(decoration_filter->exclude_ref_config_pattern,
|
||||
item->string);
|
||||
}
|
||||
|
||||
/*
|
||||
* By default, decorate_all is disabled. Enable it if
|
||||
* log.initialDecorationSet=all. Don't ever disable it by config,
|
||||
* since the command-line takes precedent.
|
||||
*/
|
||||
if (use_default_decoration_filter &&
|
||||
!git_config_get_string("log.initialdecorationset", &value) &&
|
||||
!strcmp("all", value))
|
||||
use_default_decoration_filter = 0;
|
||||
free(value);
|
||||
|
||||
if (!use_default_decoration_filter ||
|
||||
decoration_filter->exclude_ref_pattern->nr ||
|
||||
decoration_filter->include_ref_pattern->nr ||
|
||||
decoration_filter->exclude_ref_config_pattern->nr)
|
||||
return;
|
||||
|
||||
/*
|
||||
* No command-line or config options were given, so
|
||||
* populate with sensible defaults.
|
||||
*/
|
||||
for (i = 0; i < ARRAY_SIZE(ref_namespace); i++) {
|
||||
if (!ref_namespace[i].decoration)
|
||||
continue;
|
||||
|
||||
string_list_append(include, ref_namespace[i].ref);
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
|
||||
struct rev_info *rev, struct setup_revision_opt *opt)
|
||||
{
|
||||
struct userformat_want w;
|
||||
int quiet = 0, source = 0, mailmap;
|
||||
static struct line_opt_callback_data line_cb = {NULL, NULL, STRING_LIST_INIT_DUP};
|
||||
static struct string_list decorate_refs_exclude = STRING_LIST_INIT_NODUP;
|
||||
static struct string_list decorate_refs_exclude_config = STRING_LIST_INIT_NODUP;
|
||||
static struct string_list decorate_refs_include = STRING_LIST_INIT_NODUP;
|
||||
struct decoration_filter decoration_filter = {&decorate_refs_include,
|
||||
&decorate_refs_exclude,
|
||||
&decorate_refs_exclude_config};
|
||||
struct decoration_filter decoration_filter = {
|
||||
.exclude_ref_pattern = &decorate_refs_exclude,
|
||||
.include_ref_pattern = &decorate_refs_include,
|
||||
.exclude_ref_config_pattern = &decorate_refs_exclude_config,
|
||||
};
|
||||
static struct revision_sources revision_sources;
|
||||
|
||||
const struct option builtin_log_options[] = {
|
||||
@ -181,6 +238,10 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
|
||||
OPT_BOOL(0, "source", &source, N_("show source")),
|
||||
OPT_BOOL(0, "use-mailmap", &mailmap, N_("use mail map file")),
|
||||
OPT_ALIAS(0, "mailmap", "use-mailmap"),
|
||||
OPT_CALLBACK_F(0, "clear-decorations", NULL, NULL,
|
||||
N_("clear all previously-defined decoration filters"),
|
||||
PARSE_OPT_NOARG | PARSE_OPT_NONEG,
|
||||
clear_decorations_callback),
|
||||
OPT_STRING_LIST(0, "decorate-refs", &decorate_refs_include,
|
||||
N_("pattern"), N_("only decorate refs that match <pattern>")),
|
||||
OPT_STRING_LIST(0, "decorate-refs-exclude", &decorate_refs_exclude,
|
||||
@ -265,16 +326,7 @@ static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
|
||||
}
|
||||
|
||||
if (decoration_style || rev->simplify_by_decoration) {
|
||||
const struct string_list *config_exclude =
|
||||
repo_config_get_value_multi(the_repository,
|
||||
"log.excludeDecoration");
|
||||
|
||||
if (config_exclude) {
|
||||
struct string_list_item *item;
|
||||
for_each_string_list_item(item, config_exclude)
|
||||
string_list_append(&decorate_refs_exclude_config,
|
||||
item->string);
|
||||
}
|
||||
set_default_decoration_filter(&decoration_filter);
|
||||
|
||||
if (decoration_style)
|
||||
rev->show_decorations = 1;
|
||||
|
@ -106,6 +106,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
|
||||
size_t base_len;
|
||||
int had_error = 0;
|
||||
struct object_id oid;
|
||||
const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
|
||||
|
||||
strbuf_addstr(&ref, git_replace_ref_base);
|
||||
base_len = ref.len;
|
||||
@ -147,6 +148,8 @@ static int check_ref_valid(struct object_id *object,
|
||||
struct strbuf *ref,
|
||||
int force)
|
||||
{
|
||||
const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
|
||||
|
||||
strbuf_reset(ref);
|
||||
strbuf_addf(ref, "%s%s", git_replace_ref_base, oid_to_hex(object));
|
||||
if (check_refname_format(ref->buf, 0))
|
||||
|
Reference in New Issue
Block a user