From: ZheNing Hu <adlternative@xxxxxxxxx> When using `interpret-trailers`, if user accidentally fill in the wrong option values (e.g. `--if-exists=addd` or `--where=begin` or `--if-missing=do-nothing`), git will exit quietly, and the user may not even know what happened. So lets provides warnings when git parsing this three options: "unknown value '%s' for key ('where'|'--if-exist'|'--if-missing')". This will remind the user :"Oh, it was because of my spelling error." (or using a synonym for error). Signed-off-by: ZheNing Hu <adlternative@xxxxxxxxx> --- builtin/interpret-trailers.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c index 84748eafc01b..6d8e86a44d43 100644 --- a/builtin/interpret-trailers.c +++ b/builtin/interpret-trailers.c @@ -24,19 +24,38 @@ static enum trailer_if_missing if_missing; static int option_parse_where(const struct option *opt, const char *arg, int unset) { - return trailer_set_where(&where, arg); + int ret; + + ret = trailer_set_where(&where, arg); + if (ret) + warning(_("unknown value '%s' for key 'where'"), + arg); + return ret; + } static int option_parse_if_exists(const struct option *opt, const char *arg, int unset) { - return trailer_set_if_exists(&if_exists, arg); + int ret; + + ret = trailer_set_if_exists(&if_exists, arg); + if (ret) + warning(_("unknown value '%s' for key 'if_exists'"), + arg); + return ret; } static int option_parse_if_missing(const struct option *opt, const char *arg, int unset) { - return trailer_set_if_missing(&if_missing, arg); + int ret; + + ret = trailer_set_if_missing(&if_missing, arg); + if (ret) + warning(_("unknown value '%s' for key 'if_missing'"), + arg); + return ret; } static void new_trailers_clear(struct list_head *trailers) -- gitgitgadget