diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-10-08 21:53:26 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-10-08 21:53:26 -0700 |
commit | 86e1007abc58f8458ce90dc10a385239722cf08a (patch) | |
tree | 8d7ae6caf3219ff0684ebefdb4df704649940836 | |
parent | Merge branch 'js/ghwf-setup-msbuild-update' (diff) | |
parent | help: do not expect built-in commands to be hardlinked (diff) | |
download | tgif-86e1007abc58f8458ce90dc10a385239722cf08a.tar.xz |
Merge branch 'js/no-builtins-on-disk-option'
Hotfix to breakage introduced in the topic in v2.29-rc0
* js/no-builtins-on-disk-option:
help: do not expect built-in commands to be hardlinked
-rw-r--r-- | git.c | 19 | ||||
-rw-r--r-- | help.c | 2 | ||||
-rw-r--r-- | help.h | 1 |
3 files changed, 22 insertions, 0 deletions
@@ -638,6 +638,25 @@ static void list_builtins(struct string_list *out, unsigned int exclude_option) } } +void load_builtin_commands(const char *prefix, struct cmdnames *cmds) +{ + const char *name; + int i; + + /* + * Callers can ask for a subset of the commands based on a certain + * prefix, which is then dropped from the added names. The names in + * the `commands[]` array do not have the `git-` prefix, though, + * therefore we must expect the `prefix` to at least start with `git-`. + */ + if (!skip_prefix(prefix, "git-", &prefix)) + BUG("prefix '%s' must start with 'git-'", prefix); + + for (i = 0; i < ARRAY_SIZE(commands); i++) + if (skip_prefix(commands[i].cmd, prefix, &name)) + add_cmdname(cmds, name, strlen(name)); +} + #ifdef STRIP_EXTENSION static void strip_extension(const char **argv) { @@ -263,6 +263,8 @@ void load_command_list(const char *prefix, const char *env_path = getenv("PATH"); const char *exec_path = git_exec_path(); + load_builtin_commands(prefix, main_cmds); + if (exec_path) { list_commands_in_dir(main_cmds, exec_path, prefix); QSORT(main_cmds->names, main_cmds->cnt, cmdname_compare); @@ -32,6 +32,7 @@ const char *help_unknown_cmd(const char *cmd); void load_command_list(const char *prefix, struct cmdnames *main_cmds, struct cmdnames *other_cmds); +void load_builtin_commands(const char *prefix, struct cmdnames *cmds); void add_cmdname(struct cmdnames *cmds, const char *name, int len); /* Here we require that excludes is a sorted list. */ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes); |