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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 20, 2019 at 14:03 UTC 83b0ecf333e518867935f6b12c18294a8a7f5017
2 files changed +7 -7
git.c
+7
@@ -62,6 +62,13 @@ static int list_cmds(const char *spec)
62 {
63 struct string_list list = STRING_LIST_INIT_DUP;
64 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);
72
73 while (*spec) {
74 const char *sep = strchrnul(spec, ',');
help.c
-7
@@ -375,13 +375,6 @@ void list_cmds_by_config(struct string_list *list)
375 {
376 const char *cmd_list;
377
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 - */
378 if (git_config_get_string_const("completion.commands", &cmd_list))
379 return;
380