Skip to content

Commit

Permalink
Show stash, notes and prefetch in refs view with tig refs --all
Browse files Browse the repository at this point in the history
Hide them by default and for other references, honor `reference-format = hide:tag`.

Closes #1359
  • Loading branch information
koutcher committed Jan 14, 2025
1 parent 5294f79 commit 210ec49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------
Expand Down
2 changes: 1 addition & 1 deletion include/tig/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
15 changes: 13 additions & 2 deletions src/refs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 210ec49

Please sign in to comment.