diff --git a/NEWS.adoc b/NEWS.adoc index 8c1761a5d..1d90d7480 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -26,6 +26,8 @@ Improvements: - Allow different colors for all references types. - Enable search in sections titles. (#1043) - Show committer date by default in the date column. (#294) + - Only show stash, notes and prefetch in the refs view when + invoked with `tig refs --all`. (#1359) tig-2.5.10 ---------- diff --git a/include/tig/options.h b/include/tig/options.h index f001d4037..debcca362 100644 --- a/include/tig/options.h +++ b/include/tig/options.h @@ -65,7 +65,7 @@ typedef struct view_column *view_settings; _(pager_autoscroll, bool, VIEW_NO_FLAGS) \ _(pager_view, view_settings, VIEW_NO_FLAGS) \ _(pgrp, bool, VIEW_NO_FLAGS) \ - _(reference_format, struct ref_format **, VIEW_NO_FLAGS) \ + _(reference_format, struct ref_format **, VIEW_LOG_LIKE) \ _(refresh_interval, int, VIEW_NO_FLAGS) \ _(refresh_mode, enum refresh_mode, VIEW_NO_FLAGS) \ _(refs_view, view_settings, VIEW_NO_FLAGS) \ diff --git a/src/refs.c b/src/refs.c index 34bd761ca..78316951a 100644 --- a/src/refs.c +++ b/src/refs.c @@ -43,6 +43,7 @@ enum refs_filter { REFS_FILTER_TAGS = 1 << 0, REFS_FILTER_BRANCHES = 1 << 1, REFS_FILTER_REMOTES = 1 << 2, + REFS_FILTER_ALL = 1 << 3, } refs_filter = REFS_FILTER_NONE; static bool @@ -139,9 +140,10 @@ refs_open_visitor(void *data, const struct ref *ref) struct view *view = data; struct reference *reference; bool is_all = ref == refs_all; + const struct ref_format *fmt = get_ref_format(opt_reference_format, ref); struct line *line; - if (!is_all) + if (!is_all) switch (refs_filter) { case REFS_FILTER_TAGS: if (ref->type != REFERENCE_TAG && ref->type != REFERENCE_LOCAL_TAG) @@ -156,6 +158,13 @@ refs_open_visitor(void *data, const struct ref *ref) return true; break; case REFS_FILTER_NONE: + if (ref->type == REFERENCE_STASH || + ref->type == REFERENCE_NOTE || + ref->type == REFERENCE_PREFETCH || + (!strcmp(fmt->start, "hide:") && !*fmt->end)) + return true; + break; + case REFS_FILTER_ALL: default: break; } @@ -207,6 +216,8 @@ refs_open(struct view *view, enum open_flags flags) } else if (!strncmp(refs_argv[i], "--remotes", 9)) { refs_filter = REFS_FILTER_REMOTES; name = REFS_REMOTES_NAME; + } else if (!strncmp(refs_argv[i], "--all", 5)) { + refs_filter = REFS_FILTER_ALL; } } @@ -256,7 +267,7 @@ refs_select(struct view *view, struct line *line) static struct view_ops refs_ops = { "reference", argv_env.head, - VIEW_REFRESH | VIEW_SORTABLE | VIEW_BLAME_LIKE, + VIEW_REFRESH | VIEW_SORTABLE | VIEW_LOG_LIKE, 0, refs_open, refs_read,