Skip to content

Commit c3a4ba5

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 <[email protected]>
1 parent 0f2e232 commit c3a4ba5

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

git.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,19 @@ static void list_builtins(struct string_list *out, unsigned int exclude_option)
650650
}
651651
}
652652

653+
void load_builtin_commands(const char *prefix, struct cmdnames *cmds)
654+
{
655+
const char *name;
656+
int i;
657+
658+
if (!skip_prefix(prefix, "git-", &prefix))
659+
return;
660+
661+
for (i = 0; i < ARRAY_SIZE(commands); i++)
662+
if (skip_prefix(commands[i].cmd, prefix, &name))
663+
add_cmdname(cmds, name, strlen(name));
664+
}
665+
653666
#ifdef STRIP_EXTENSION
654667
static void strip_extension(const char **argv)
655668
{

help.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ void load_command_list(const char *prefix,
263263
const char *env_path = getenv("PATH");
264264
const char *exec_path = git_exec_path();
265265

266+
load_builtin_commands(prefix, main_cmds);
267+
266268
if (exec_path) {
267269
list_commands_in_dir(main_cmds, exec_path, prefix);
268270
QSORT(main_cmds->names, main_cmds->cnt, cmdname_compare);

help.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const char *help_unknown_cmd(const char *cmd);
3232
void load_command_list(const char *prefix,
3333
struct cmdnames *main_cmds,
3434
struct cmdnames *other_cmds);
35+
void load_builtin_commands(const char *prefix, struct cmdnames *cmds);
3536
void add_cmdname(struct cmdnames *cmds, const char *name, int len);
3637
/* Here we require that excludes is a sorted list. */
3738
void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes);

0 commit comments

Comments
 (0)