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
This commit is contained in:
Junio C Hamano
2018-06-25 13:22:38 -07:00
21 changed files with 445 additions and 553 deletions

View File

@@ -32,6 +32,7 @@
#include "column.h"
#include "sequencer.h"
#include "mailmap.h"
#include "help.h"
static const char * const builtin_commit_usage[] = {
N_("git commit [<options>] [--] <pathspec>..."),
@@ -66,6 +67,18 @@ N_("If you wish to skip this commit, use:\n"
"Then \"git cherry-pick --continue\" will resume cherry-picking\n"
"the remaining commits.\n");
static const char *color_status_slots[] = {
[WT_STATUS_HEADER] = "header",
[WT_STATUS_UPDATED] = "updated",
[WT_STATUS_CHANGED] = "changed",
[WT_STATUS_UNTRACKED] = "untracked",
[WT_STATUS_NOBRANCH] = "noBranch",
[WT_STATUS_UNMERGED] = "unmerged",
[WT_STATUS_LOCAL_BRANCH] = "localBranch",
[WT_STATUS_REMOTE_BRANCH] = "remoteBranch",
[WT_STATUS_ONBRANCH] = "branch",
};
static const char *use_message_buffer;
static struct lock_file index_lock; /* real index */
static struct lock_file false_lock; /* used only for partial commits */
@@ -1183,27 +1196,14 @@ static int dry_run_commit(int argc, const char **argv, const char *prefix,
return commitable ? 0 : 1;
}
define_list_config_array_extra(color_status_slots, {"added"});
static int parse_status_slot(const char *slot)
{
if (!strcasecmp(slot, "header"))
return WT_STATUS_HEADER;
if (!strcasecmp(slot, "branch"))
return WT_STATUS_ONBRANCH;
if (!strcasecmp(slot, "updated") || !strcasecmp(slot, "added"))
if (!strcasecmp(slot, "added"))
return WT_STATUS_UPDATED;
if (!strcasecmp(slot, "changed"))
return WT_STATUS_CHANGED;
if (!strcasecmp(slot, "untracked"))
return WT_STATUS_UNTRACKED;
if (!strcasecmp(slot, "nobranch"))
return WT_STATUS_NOBRANCH;
if (!strcasecmp(slot, "unmerged"))
return WT_STATUS_UNMERGED;
if (!strcasecmp(slot, "localBranch"))
return WT_STATUS_LOCAL_BRANCH;
if (!strcasecmp(slot, "remoteBranch"))
return WT_STATUS_REMOTE_BRANCH;
return -1;
return LOOKUP_CONFIG(color_status_slots, slot);
}
static int git_status_config(const char *k, const char *v, void *cb)