aboutsummaryrefslogtreecommitdiffstats
path: root/add-interactive.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-11-29 21:11:49 +0000
committerJunio C Hamano <gitster@pobox.com>2019-12-01 07:30:54 -0800
commit2e697ced9d647d6998d70f010d582ba8019fe3af (patch)
treeb5586e73e39176d210f671b4d43519d778cb63cd /add-interactive.c
parentd7633578b5ecf0d75e2793b01aa2e9afe645c186 (diff)
downloadgit-2e697ced9d647d6998d70f010d582ba8019fe3af.tar.gz
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'add-interactive.c')
-rw-r--r--add-interactive.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/add-interactive.c b/add-interactive.c
index 4d7d44a917..f395d54c08 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -1071,6 +1071,7 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
{ "add untracked", run_add_untracked },
{ "patch", run_patch },
{ "diff", run_diff },
+ { "quit", NULL },
{ "help", run_help },
};
struct prefix_item_list commands = PREFIX_ITEM_LIST_INIT;
@@ -1122,17 +1123,22 @@ int run_add_i(struct repository *r, const struct pathspec *ps)
res = run_status(&s, ps, &files, &opts);
for (;;) {
+ struct command_item *util;
+
i = list_and_choose(&s, &commands, &main_loop_opts);
- if (i == LIST_AND_CHOOSE_QUIT) {
+ if (i < 0 || i >= commands.items.nr)
+ util = NULL;
+ else
+ util = commands.items.items[i].util;
+
+ if (i == LIST_AND_CHOOSE_QUIT || (util && !util->command)) {
printf(_("Bye.\n"));
res = 0;
break;
}
- if (i != LIST_AND_CHOOSE_ERROR) {
- struct command_item *util =
- commands.items.items[i].util;
+
+ if (util)
res = util->command(&s, ps, &files, &opts);
- }
}
prefix_item_list_clear(&files);