Later on we may support non-overlapping command groups to
--list-cmds. Allow the user to execute just one "git" process and get
multiple groups. This may matter for git-completion.bash on Windows
because we don't want the user to way for long when TAB-ing and
Windows is slow on launching new processes.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@gmail.com>
---
 git.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/git.c b/git.c
index 28bfa96d87..a46263306d 100644
--- a/git.c
+++ b/git.c
@@ -64,6 +64,7 @@ void setup_auto_pager(const char *cmd, int def)
 static int handle_options(const char ***argv, int *argc, int *envchanged)
 {
        const char **orig_argv = *argv;
+       int commands_listed = 0;
 
        while (*argc > 0) {
                const char *cmd = (*argv)[0];
@@ -230,7 +231,7 @@ static int handle_options(const char ***argv, int *argc, 
int *envchanged)
                                list_builtins(NO_PARSEOPT, ' ');
                        else
                                die("unsupported command listing type '%s'", 
cmd);
-                       exit(0);
+                       commands_listed++;
                } else {
                        fprintf(stderr, _("unknown option: %s\n"), cmd);
                        usage(git_usage_string);
@@ -239,6 +240,8 @@ static int handle_options(const char ***argv, int *argc, 
int *envchanged)
                (*argv)++;
                (*argc)--;
        }
+       if (commands_listed)
+               exit(0);
        return (*argv) - orig_argv;
 }
 
-- 
2.17.0.519.gb89679a4aa

Reply via email to