]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git: read local config in --list-cmds
authorJeff King <peff@peff.net>
Wed, 20 Mar 2019 18:03:26 +0000 (14:03 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 21 Mar 2019 02:52:11 +0000 (11:52 +0900)
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>
git.c
help.c

diff --git a/git.c b/git.c
index 2014aab6b83c61695d50ac39a18864a8d77858e0..181785ec479de577cfb98217ca4064e90bb95a72 100644 (file)
--- a/git.c
+++ b/git.c
@@ -62,6 +62,13 @@ static int list_cmds(const char *spec)
 {
        struct string_list list = STRING_LIST_INIT_DUP;
        int i;
+       int nongit;
+
+       /*
+       * Set up the repository so we can pick up any repo-level config (like
+       * completion.commands).
+       */
+       setup_git_directory_gently(&nongit);
 
        while (*spec) {
                const char *sep = strchrnul(spec, ',');
diff --git a/help.c b/help.c
index 520c9080e8e4abf7793af0966588aa370f09d316..fac7e421d01d40ee2c60c9d182c3f8305633683d 100644 (file)
--- a/help.c
+++ b/help.c
@@ -375,13 +375,6 @@ void list_cmds_by_config(struct string_list *list)
 {
        const char *cmd_list;
 
-       /*
-        * There's no actual repository setup at this point (and even
-        * if there is, we don't really care; only global config
-        * matters). If we accidentally set up a repository, it's ok
-        * too since the caller (git --list-cmds=) should exit shortly
-        * anyway.
-        */
        if (git_config_get_string_const("completion.commands", &cmd_list))
                return;