diff --git a/NEWS.adoc b/NEWS.adoc index 879c44848..8f1b88c22 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -12,6 +12,8 @@ Improvements: - Use HTTPS for GitHub clone URLs. (#1310) - Move default log view options to tigrc. - Allow to go to stage view without Enter. (#1284) + - Add new "prefetch" reference type for refs created by `git maintenance` + (hidden in default config). (#1318) Bug fixes: diff --git a/doc/tigrc.5.adoc b/doc/tigrc.5.adoc index 9a647ebc9..b61af4fba 100644 --- a/doc/tigrc.5.adoc +++ b/doc/tigrc.5.adoc @@ -181,7 +181,9 @@ The following variables can be set: names. Wrap the name of the reference type with the characters you would like to use for formatting, e.g. `[tag]` and ``. If no format is specified for `local-tag`, the format for `tag` is used. Similarly, if no - format is specified for `tracked-remote` the `remote` format is used. + format is specified for `tracked-remote`, the format for `remote` is used, + and if no format is specified for any other reference type, the format for + `branch` is used. Prefix with `hide:` to not show that reference type, e.g. `hide:remote`. Supported reference types are: - head : The current HEAD. @@ -192,6 +194,7 @@ The following variables can be set: - replace : A replaced reference. - branch : A branch. - stash : The stash. + - prefetch : Refs prefetched by `git maintenance`. - 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 0f2645fc1..85e24452e 100644 --- a/include/tig/types.h +++ b/include/tig/types.h @@ -150,7 +150,8 @@ bool map_enum_do(const struct enum_map_entry *map, size_t map_size, int *value, _(REFERENCE, REMOTE), \ _(REFERENCE, TAG), \ _(REFERENCE, LOCAL_TAG), \ - _(REFERENCE, REPLACE) + _(REFERENCE, REPLACE), \ + _(REFERENCE, PREFETCH) #define STATUS_LABEL_ENUM(_) \ _(STATUS_LABEL, NO), \ diff --git a/src/refdb.c b/src/refdb.c index b4560e1ab..fe5ac216c 100644 --- a/src/refdb.c +++ b/src/refdb.c @@ -224,6 +224,9 @@ add_to_refs(const char *id, size_t idlen, char *name, size_t namelen, struct ref !strncmp(opt->head, name, namelen)) type = REFERENCE_HEAD; + } else if (!prefixcmp(name, "refs/prefetch/")) { + type = REFERENCE_PREFETCH; + } else if (!strcmp(name, "HEAD")) { /* Handle the case of HEAD not being a symbolic ref, * i.e. during a rebase. */ diff --git a/tigrc b/tigrc index 21ff13864..1a7041eb8 100644 --- a/tigrc +++ b/tigrc @@ -100,12 +100,15 @@ set truncation-delimiter = ~ # Character drawn for truncations, or "utf-8" # - replace : A replaced reference. # - branch : A branch. # - stash : The stash. +# - prefetch : Refs prefetched by `git maintenance`. # - 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`. +# # Expects a space-separated list of format strings. -set reference-format = [branch] {remote} ~replace~ +# - If no format is specified for `local-tag`, the format for `tag` is used. +# - If no format is specified for `tracked-remote`, the format for `remote` is used. +# - If no format is specified for any other reference type, the format for `branch` is used. +# Prefix with `hide:` to not show that reference type, e.g. `hide:remote`. +set reference-format = [branch] {remote} ~replace~ hide:prefetch # Settings controlling how content is read from Git set commit-order = auto # Enum: auto, default, topo, date, reverse (main)