Skip to content

Commit c88434f

Browse files
committed
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 <[email protected]>
1 parent dc66d6c commit c88434f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

add-interactive.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,11 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
992992
add_untracked = { { "add untracked" }, run_add_untracked },
993993
patch = { { "patch" }, run_patch },
994994
diff = { { "diff" }, run_diff },
995+
quit = { { "quit" }, NULL },
995996
help = { { "help" }, run_help };
996997
struct command_item *commands[] = {
997998
&status, &update, &revert, &add_untracked,
998-
&patch, &diff, &help
999+
&patch, &diff, &quit, &help
9991000
};
10001001

10011002
struct print_file_item_data print_file_item_data = {
@@ -1040,7 +1041,8 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
10401041
for (;;) {
10411042
i = list_and_choose((struct prefix_item **)commands, NULL,
10421043
ARRAY_SIZE(commands), &s, &main_loop_opts);
1043-
if (i == LIST_AND_CHOOSE_QUIT)
1044+
if (i == LIST_AND_CHOOSE_QUIT ||
1045+
(i != LIST_AND_CHOOSE_ERROR && !commands[i]->command)) {
10441046
printf(_("Bye.\n"));
10451047
res = 0;
10461048
break;

0 commit comments

Comments
 (0)