From 8b5ebbed0e793f6fcf92100e600b7a4bdd6452e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 2 Aug 2018 21:17:35 +0200 Subject: add, update-index: fix --chmod argument help Don't translate the argument specification for --chmod; "+x" and "-x" are the literal strings that the commands accept. Separate alternatives using a pipe character instead of a slash, for consistency. Use the flag PARSE_OPT_LITERAL_ARGHELP to prevent parseopt from adding a pair of angular brackets around the argument help string, as that would wrongly indicate that users need to replace the literal strings with some kind of value. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- builtin/update-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/update-index.c') diff --git a/builtin/update-index.c b/builtin/update-index.c index 52eaebae91..a2aee925a0 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -970,7 +970,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) PARSE_OPT_NOARG | /* disallow --cacheinfo= form */ PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP, (parse_opt_cb *) cacheinfo_callback}, - {OPTION_CALLBACK, 0, "chmod", &set_executable_bit, N_("(+/-)x"), + {OPTION_CALLBACK, 0, "chmod", &set_executable_bit, "(+|-)x", N_("override the executable bit of the listed files"), PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP, chmod_callback}, -- cgit v1.2.3 From 5f0df44cd79a953c287ccb598896ea7aaa2cc9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Thu, 2 Aug 2018 21:18:14 +0200 Subject: parse-options: automatically infer PARSE_OPT_LITERAL_ARGHELP Parseopt wraps argument help strings in a pair of angular brackets by default, to tell users that they need to replace it with an actual value. This is useful in most cases, because most option arguments are indeed single values of a certain type. The option PARSE_OPT_LITERAL_ARGHELP needs to be used in option definitions with arguments that have multiple parts or are literal strings. Stop adding these angular brackets if special characters are present, as they indicate that we don't deal with a simple placeholder. This simplifies the code a bit and makes defining special options slightly easier. Remove the flag PARSE_OPT_LITERAL_ARGHELP in the cases where the new and more cautious handling suffices. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- builtin/update-index.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/update-index.c') diff --git a/builtin/update-index.c b/builtin/update-index.c index a2aee925a0..6700a632be 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -972,7 +972,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) (parse_opt_cb *) cacheinfo_callback}, {OPTION_CALLBACK, 0, "chmod", &set_executable_bit, "(+|-)x", N_("override the executable bit of the listed files"), - PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP, + PARSE_OPT_NONEG, chmod_callback}, {OPTION_SET_INT, 0, "assume-unchanged", &mark_valid_only, NULL, N_("mark files as \"not changing\""), -- cgit v1.2.3