aboutsummaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
Diffstat (limited to 'help.c')
-rw-r--r--help.c39
1 files changed, 19 insertions, 20 deletions
diff --git a/help.c b/help.c
index 08b5c60204..95f576c5c8 100644
--- a/help.c
+++ b/help.c
@@ -20,6 +20,8 @@
#include "prompt.h"
#include "fsmonitor-ipc.h"
#include "repository.h"
+#include "alias.h"
+#include "utf8.h"
#ifndef NO_CURL
#include "git-curl-compat.h" /* For LIBCURL_VERSION only */
@@ -107,7 +109,7 @@ static void print_command_list(const struct cmdname_help *cmds,
for (i = 0; cmds[i].name; i++) {
if (cmds[i].category & mask) {
- size_t len = strlen(cmds[i].name);
+ size_t len = utf8_strwidth(cmds[i].name);
printf(" %s ", cmds[i].name);
if (longest > len)
mput_char(' ', longest - len);
@@ -468,20 +470,6 @@ void list_developer_interfaces_help(void)
putchar('\n');
}
-static int get_alias(const char *var, const char *value,
- const struct config_context *ctx UNUSED, void *data)
-{
- struct string_list *list = data;
-
- if (skip_prefix(var, "alias.", &var)) {
- if (!value)
- return config_error_nonbool(var);
- string_list_append(list, var)->util = xstrdup(value);
- }
-
- return 0;
-}
-
static void list_all_cmds_help_external_commands(void)
{
struct string_list others = STRING_LIST_INIT_DUP;
@@ -501,11 +489,11 @@ static void list_all_cmds_help_aliases(int longest)
struct cmdname_help *aliases;
int i;
- repo_config(the_repository, get_alias, &alias_list);
+ list_aliases(&alias_list);
string_list_sort(&alias_list);
for (i = 0; i < alias_list.nr; i++) {
- size_t len = strlen(alias_list.items[i].string);
+ size_t len = utf8_strwidth(alias_list.items[i].string);
if (longest < len)
longest = len;
}
@@ -586,7 +574,8 @@ static int git_unknown_cmd_config(const char *var, const char *value,
void *cb)
{
struct help_unknown_cmd_config *cfg = cb;
- const char *p;
+ const char *subsection, *key;
+ size_t subsection_len;
if (!strcmp(var, "help.autocorrect")) {
int v = parse_autocorrect(value);
@@ -601,8 +590,18 @@ static int git_unknown_cmd_config(const char *var, const char *value,
}
/* Also use aliases for command lookup */
- if (skip_prefix(var, "alias.", &p))
- add_cmdname(&cfg->aliases, p, strlen(p));
+ if (!parse_config_key(var, "alias", &subsection, &subsection_len,
+ &key)) {
+ if (subsection) {
+ /* [alias "name"] command = value */
+ if (!strcmp(key, "command"))
+ add_cmdname(&cfg->aliases, subsection,
+ subsection_len);
+ } else {
+ /* alias.name = value */
+ add_cmdname(&cfg->aliases, key, strlen(key));
+ }
+ }
return 0;
}