built-in add -i: offer the quit command

We do not really want to `exit()` here, of course, as this is safely
libified code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2019-03-07 23:37:23 +01:00
parent 99b7a13466
commit dbd1dd759b

View File

@@ -992,10 +992,11 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
add_untracked = { { "add untracked" }, run_add_untracked },
patch = { { "patch" }, run_patch },
diff = { { "diff" }, run_diff },
quit = { { "quit" }, NULL },
help = { { "help" }, run_help };
struct command_item *commands[] = {
&status, &update, &revert, &add_untracked,
&patch, &diff, &help
&patch, &diff, &quit, &help
};
struct print_file_item_data print_file_item_data = {
@@ -1040,7 +1041,8 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
for (;;) {
i = list_and_choose((struct prefix_item **)commands, NULL,
ARRAY_SIZE(commands), &s, &main_loop_opts);
if (i == LIST_AND_CHOOSE_QUIT) {
if (i == LIST_AND_CHOOSE_QUIT ||
(i != LIST_AND_CHOOSE_ERROR && !commands[i]->command)) {
printf(_("Bye.\n"));
res = 0;
break;