submodule deinit: handle non existing pathspecs gracefully
authorStefan Beller <sbeller@google.com>
Tue, 27 Mar 2018 23:28:24 +0000 (16:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Mar 2018 05:07:13 +0000 (22:07 -0700)
This fixes a regression introduced in 2e612731b5 (submodule: port
submodule subcommand 'deinit' from shell to C, 2018-01-15), when
handling pathspecs that do not exist gracefully. This restores the
historic behavior of reporting the pathspec as unknown and returning
instead of reporting a bug.

Reported-by: Peter Oberndorfer <kumbayo84@arcor.de>
Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
index b1daca995f2f46ceb15148b609c4a89ccaa13de4..b5d37137984adff7d0ba5622f6d75dbe5f2f5daf 100644 (file)
@@ -1042,7 +1042,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
                die(_("Use '--all' if you really want to deinitialize all submodules"));
 
        if (module_list_compute(argc, argv, prefix, &pathspec, &list) < 0)
-               BUG("module_list_compute should not choke on empty pathspec");
+               return 1;
 
        info.prefix = prefix;
        if (quiet)