aboutsummaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
Diffstat (limited to 'help.c')
-rw-r--r--help.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/help.c b/help.c
index 5854dd4a7e..3e59d07c37 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);
@@ -420,8 +422,7 @@ void list_cmds_by_config(struct string_list *list)
if (repo_config_get_string_tmp(the_repository, "completion.commands", &cmd_list))
return;
- string_list_sort(list);
- string_list_remove_duplicates(list, 0);
+ string_list_sort_u(list, 1);
while (*cmd_list) {
struct strbuf sb = STRBUF_INIT;
@@ -469,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;
@@ -502,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;
}
@@ -587,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);
@@ -602,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;
}
@@ -799,6 +797,9 @@ void get_version_info(struct strbuf *buf, int show_build_options)
if (fsmonitor_ipc__is_supported())
strbuf_addstr(buf, "feature: fsmonitor--daemon\n");
+#if !defined NO_GETTEXT
+ strbuf_addstr(buf, "gettext: enabled\n");
+#endif
#if defined LIBCURL_VERSION
strbuf_addf(buf, "libcurl: %s\n", LIBCURL_VERSION);
#endif
@@ -851,18 +852,16 @@ struct similar_ref_cb {
struct string_list *similar_refs;
};
-static int append_similar_ref(const char *refname, const char *referent UNUSED,
- const struct object_id *oid UNUSED,
- int flags UNUSED, void *cb_data)
+static int append_similar_ref(const struct reference *ref, void *cb_data)
{
struct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data);
- char *branch = strrchr(refname, '/') + 1;
+ const char *branch = strrchr(ref->name, '/') + 1;
/* A remote branch of the same name is deemed similar */
- if (starts_with(refname, "refs/remotes/") &&
+ if (starts_with(ref->name, "refs/remotes/") &&
!strcmp(branch, cb->base_ref))
string_list_append_nodup(cb->similar_refs,
- refs_shorten_unambiguous_ref(get_main_ref_store(the_repository), refname, 1));
+ refs_shorten_unambiguous_ref(get_main_ref_store(the_repository), ref->name, 1));
return 0;
}