[PATCH v2 3/3] sequencer.c: don't die on invalid cleanup_arg
- From
Denton Liu <liu.denton@gmail.com>
- Date
- Mar 7, 2019, 06:44 UTC
- Message-ID
- <f3af8000aec51e49f3fe8f90dbfec61606596b2e.1551940635.git.liu.denton@gmail.com>
- In-Reply-To
- <cover.1551940635.git.liu.denton@gmail.com>
When get_cleanup_mode was provided with an invalid cleanup_arg, it used to die. Warn user and fallback to default behaviour if an invalid cleanup_arg is given.
Signed-off-by: Denton Liu <liu.denton@gmail.com> --- sequencer.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/sequencer.c b/sequencer.c index 5c04bae7ac..f9bdfa90ad 100644 --- a/sequencer.c +++ b/sequencer.c @@ -502,8 +502,11 @@ enum commit_msg_cleanup_mode get_cleanup_mode(const char *cleanup_arg, else if (!strcmp(cleanup_arg, "scissors")) return use_editor ? COMMIT_MSG_CLEANUP_SCISSORS : COMMIT_MSG_CLEANUP_SPACE; - else - die(_("Invalid cleanup mode %s"), cleanup_arg); + else { + warning(_("Invalid cleanup mode %s, falling back to default"), cleanup_arg); + return use_editor ? COMMIT_MSG_CLEANUP_ALL : + COMMIT_MSG_CLEANUP_SPACE; + } } void append_conflicts_hint(struct strbuf *msgbuf, enum commit_msg_cleanup_mode cleanup_mode)
-- 2.21.0.368.gbf248417d7