Skip to content

Commit 86e1007

Browse files
committed
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
2 parents 08f06e5 + 722fc37 commit 86e1007

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

git.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,25 @@ static void list_builtins(struct string_list *out, unsigned int exclude_option)
638638
}
639639
}
640640

641+
void load_builtin_commands(const char *prefix, struct cmdnames *cmds)
642+
{
643+
const char *name;
644+
int i;
645+
646+
/*
647+
* Callers can ask for a subset of the commands based on a certain
648+
* prefix, which is then dropped from the added names. The names in
649+
* the `commands[]` array do not have the `git-` prefix, though,
650+
* therefore we must expect the `prefix` to at least start with `git-`.
651+
*/
652+
if (!skip_prefix(prefix, "git-", &prefix))
653+
BUG("prefix '%s' must start with 'git-'", prefix);
654+
655+
for (i = 0; i < ARRAY_SIZE(commands); i++)
656+
if (skip_prefix(commands[i].cmd, prefix, &name))
657+
add_cmdname(cmds, name, strlen(name));
658+
}
659+
641660
#ifdef STRIP_EXTENSION
642661
static void strip_extension(const char **argv)
643662
{

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)