fix histedit's interactive retry loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
diff --git a/got/got.c b/got/got.c
index 7486c8d..cb74254 100644
--- a/got/got.c
+++ b/got/got.c
@@ -4502,21 +4502,28 @@ histedit_edit_list_retry(struct got_histedit_list *histedit_cmds,
printf("%s: %s\n(c)ontinue editing, (r)estart editing, "
"or (a)bort: ", getprogname(), errmsg);
resp = getchar();
- switch (resp) {
- case 'c':
+ if (resp == 'c') {
err = histedit_run_editor(histedit_cmds, path, repo);
- break;
- case 'r':
+ if (err) {
+ if (err->code != GOT_ERR_HISTEDIT_SYNTAX)
+ break;
+ resp = ' ';
+ continue;
+ }
+ } else if (resp == 'r') {
err = histedit_edit_script(histedit_cmds,
commits, repo);
- break;
- case 'a':
+ if (err) {
+ if (err->code != GOT_ERR_HISTEDIT_SYNTAX)
+ break;
+ resp = ' ';
+ continue;
+ }
+ } else if (resp == 'a') {
err = got_error(GOT_ERR_HISTEDIT_CANCEL);
break;
- default:
+ } else
printf("invalid response '%c'\n", resp);
- break;
- }
}
return err;