summaryrefslogtreecommitdiff
path: root/parse-options.c
diff options
context:
space:
mode:
authorErik Faye-Lund <kusmabite@gmail.com>2013-02-12 00:13:48 +0100
committerJunio C Hamano <gitster@pobox.com>2013-02-11 15:19:30 -0800
commitb141a47801d6fb2d68ec48adfe7597ec3ce49c0d (patch)
tree70d3a883efb6842ffef0e2496f3b900e6283efc7 /parse-options.c
parent901fd180c9d19025bafefc34e131125628169bdd (diff)
downloadgit-b141a47801d6fb2d68ec48adfe7597ec3ce49c0d.tar.gz
parse-options: report uncorrupted multi-byte options
Because our command-line parser considers only one byte at the time for short-options, we incorrectly report only the first byte when multi-byte input was provided. This makes user-errors slightly awkward to diagnose for instance under UTF-8 locale and non-English keyboard layouts. Report the whole argument-string when a non-ASCII short-option is detected. Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> Improved-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'parse-options.c')
-rw-r--r--parse-options.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/parse-options.c b/parse-options.c
index c1c66bd408..052bf72bb8 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -470,8 +470,11 @@ int parse_options(int argc, const char **argv, const char *prefix,
default: /* PARSE_OPT_UNKNOWN */
if (ctx.argv[0][1] == '-') {
error("unknown option `%s'", ctx.argv[0] + 2);
- } else {
+ } else if (isascii(*ctx.opt)) {
error("unknown switch `%c'", *ctx.opt);
+ } else {
+ error("unknown non-ascii option in string: `%s'",
+ ctx.argv[0]);
}
usage_with_options(usagestr, options);
}