From 4f03559b9f198f97b417b33e56935a3f85e3a221 Mon Sep 17 00:00:00 2001 From: Thomas Koutcher Date: Fri, 26 Nov 2021 20:01:35 +0100 Subject: [PATCH] Add stash and other reference types This makes it possible to filter refs created by tools such as git-branchless with `set reference-format = hide:other`. Closes #1160 --- doc/tigrc.5.adoc | 8 +++++--- include/tig/types.h | 2 ++ src/refdb.c | 6 ++++++ tigrc | 8 +++++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc index 4f04d94cf..59204a5aa 100644 --- a/doc/tigrc.5.adoc +++ b/doc/tigrc.5.adoc @@ -185,12 +185,14 @@ The following variables can be set: Prefix with `hide:` to not show that reference type, e.g. `hide:remote`. Supported reference types are: - head : The current HEAD. - - tag : A signed tag. - - local-tag : An unsigned tag. + - tag : An annotated tag. + - local-tag : A lightweight tag. - remote : A remote. - tracked-remote : The remote tracked by current HEAD. - replace : A replaced reference. - - branch : Any other reference. + - branch : A branch. + - stash : The stash. + - other : Any other reference. 'line-graphics' (mixed) [ascii|default|utf-8|auto|]:: diff --git a/include/tig/types.h b/include/tig/types.h index 6bc481af7..e9fcc302e 100644 --- a/include/tig/types.h +++ b/include/tig/types.h @@ -143,7 +143,9 @@ bool map_enum_do(const struct enum_map_entry *map, size_t map_size, int *value, #define REFERENCE_ENUM(_) \ _(REFERENCE, HEAD), \ + _(REFERENCE, STASH), \ _(REFERENCE, BRANCH), \ + _(REFERENCE, OTHER), \ _(REFERENCE, TRACKED_REMOTE), \ _(REFERENCE, REMOTE), \ _(REFERENCE, TAG), \ diff --git a/src/refdb.c b/src/refdb.c index 3595cce0a..6a3ea4f8b 100644 --- a/src/refdb.c +++ b/src/refdb.c @@ -230,6 +230,12 @@ add_to_refs(const char *id, size_t idlen, char *name, size_t namelen, struct ref if (*opt->head) return SUCCESS; type = REFERENCE_HEAD; + + } else if (!strcmp(name, "refs/stash")) { + type = REFERENCE_STASH; + + } else if (!prefixcmp(name, "refs/")) { + type = REFERENCE_OTHER; } /* If we are reloading or it's an annotated tag, replace the diff --git a/tigrc b/tigrc index e2f1f84d7..8c08a4f72 100644 --- a/tigrc +++ b/tigrc @@ -93,12 +93,14 @@ set truncation-delimiter = ~ # Character drawn for truncations, or "utf-8" # Format reference names based on type. # - head : The current HEAD. -# - tag : A signed tag. -# - local-tag : An unsigned tag. +# - tag : An annotated tag. +# - local-tag : A lightweight tag. # - remote : A remote. # - tracked-remote : The remote tracked by current HEAD. # - replace : A replaced reference. -# - branch : Any other reference. +# - branch : A branch. +# - stash : The stash. +# - other : Any other reference. # If no format is defined for `local-tag` then the one for `tag` is used. # Similarly, `remote` is used if no `tracked-remote` format exists. # Prefix with `hide:` to not show that reference type, e.g. `hide:remote`.