help: do not expect built-in commands to be hardlinked
When building with SKIP_DASHED_BUILT_INS=YesPlease, the built-in commands are no longer present in the `PATH` as hardlinks to `git`. As a consequence, `load_command_list()` needs to be taught to find the names of the built-in commands from elsewhere. This only affected the output of `git --list-cmds=main`, but not the output of `git help -a` because the latter includes the built-in commands by virtue of them being listed in command-list.txt. The bug was detected via a patch series that turns the merge strategies included in Git into built-in commands: `git merge -s help` relies on `load_command_list()` to determine the list of available merge strategies. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
ef60e9f74b
commit
722fc37491
19
git.c
19
git.c
@ -637,6 +637,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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user