Skip to content

Commit 83b0ecf

Browse files
peffgitster
authored andcommitted
git: read local config in --list-cmds
Normally code that is checking config before we've decided to do setup_git_directory() would use read_early_config(), which uses discover_git_directory() to tentatively see if we're in a repo, and if so to add it to the config sequence. But list_cmds() uses the caching configset mechanism which rightly does not use read_early_config(), because it has no idea if it's being called early. Call setup_git_directory_gently() so we can pick up repo-level config (like completion.commands). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e94f7a commit 83b0ecf

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

git.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ static int list_cmds(const char *spec)
6262
{
6363
struct string_list list = STRING_LIST_INIT_DUP;
6464
int i;
65+
int nongit;
66+
67+
/*
68+
* Set up the repository so we can pick up any repo-level config (like
69+
* completion.commands).
70+
*/
71+
setup_git_directory_gently(&nongit);
6572

6673
while (*spec) {
6774
const char *sep = strchrnul(spec, ',');

help.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,13 +375,6 @@ void list_cmds_by_config(struct string_list *list)
375375
{
376376
const char *cmd_list;
377377

378-
/*
379-
* There's no actual repository setup at this point (and even
380-
* if there is, we don't really care; only global config
381-
* matters). If we accidentally set up a repository, it's ok
382-
* too since the caller (git --list-cmds=) should exit shortly
383-
* anyway.
384-
*/
385378
if (git_config_get_string_const("completion.commands", &cmd_list))
386379
return;
387380

0 commit comments

Comments
 (0)