diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-06-25 22:22:38 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-06-25 22:22:38 +0200 |
commit | ebaf0a56f3f5f823df4166bc8fd626b523f864dc (patch) | |
tree | 1eb7aa0e578fb8636f721721f9d0767e68776138 /log-tree.c | |
parent | Merge branch 'sb/object-store-alloc' (diff) | |
parent | completion: complete general config vars in two steps (diff) | |
download | git-ebaf0a56f3f5f823df4166bc8fd626b523f864dc.tar.xz git-ebaf0a56f3f5f823df4166bc8fd626b523f864dc.zip |
Merge branch 'nd/complete-config-vars'
Continuing with the idea to programatically enumerate various
pieces of data required for command line completion, teach the
codebase to report the list of configuration variables
subcommands care about to help complete them.
* nd/complete-config-vars:
completion: complete general config vars in two steps
log-tree: allow to customize 'grafted' color
completion: support case-insensitive config vars
completion: keep other config var completion in camelCase
completion: drop the hard coded list of config vars
am: move advice.amWorkDir parsing back to advice.c
advice: keep config name in camelCase in advice_config[]
fsck: produce camelCase config key names
help: add --config to list all available config
fsck: factor out msg_id_info[] lazy initialization code
grep: keep all colors in an array
Add and use generic name->id mapping code for color slot parsing
Diffstat (limited to 'log-tree.c')
-rw-r--r-- | log-tree.c | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/log-tree.c b/log-tree.c index 0b97de5e87..d3a43e29cd 100644 --- a/log-tree.c +++ b/log-tree.c @@ -12,6 +12,7 @@ #include "gpg-interface.h" #include "sequencer.h" #include "line-log.h" +#include "help.h" static struct decoration name_decoration = { "object names" }; static int decoration_loaded; @@ -27,6 +28,15 @@ static char decoration_colors[][COLOR_MAXLEN] = { GIT_COLOR_BOLD_BLUE, /* GRAFTED */ }; +static const char *color_decorate_slots[] = { + [DECORATION_REF_LOCAL] = "branch", + [DECORATION_REF_REMOTE] = "remoteBranch", + [DECORATION_REF_TAG] = "tag", + [DECORATION_REF_STASH] = "stash", + [DECORATION_REF_HEAD] = "HEAD", + [DECORATION_GRAFTED] = "grafted", +}; + static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix) { if (want_color(decorate_use_color)) @@ -34,34 +44,11 @@ static const char *decorate_get_color(int decorate_use_color, enum decoration_ty return ""; } -static int parse_decorate_color_slot(const char *slot) -{ - /* - * We're comparing with 'ignore-case' on - * (because config.c sets them all tolower), - * but let's match the letters in the literal - * string values here with how they are - * documented in Documentation/config.txt, for - * consistency. - * - * We love being consistent, don't we? - */ - if (!strcasecmp(slot, "branch")) - return DECORATION_REF_LOCAL; - if (!strcasecmp(slot, "remoteBranch")) - return DECORATION_REF_REMOTE; - if (!strcasecmp(slot, "tag")) - return DECORATION_REF_TAG; - if (!strcasecmp(slot, "stash")) - return DECORATION_REF_STASH; - if (!strcasecmp(slot, "HEAD")) - return DECORATION_REF_HEAD; - return -1; -} +define_list_config_array(color_decorate_slots); int parse_decorate_color_config(const char *var, const char *slot_name, const char *value) { - int slot = parse_decorate_color_slot(slot_name); + int slot = LOOKUP_CONFIG(color_decorate_slots, slot_name); if (slot < 0) return 0; if (!value) |