{"thread":{"id":"59418","subject":"[PATCH 0/3] parse-options.h: use designated initializers in OPT_* macros","startedAt":"2023-03-19T16:56:57Z","lastAt":"2023-03-20T18:24:10Z","messageCount":6,"participants":["SZEDER Gábor","Elijah Newren","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"473735","messageId":"20230319165648.656738-1-szeder.dev@gmail.com","threadId":"59418","inReplyTo":null,"subject":"[PATCH 0/3] parse-options.h: use designated initializers in OPT_* macros","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2023-03-19T16:56:45Z","receivedAt":"2023-03-19T16:56:57Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Use designated initializers in the expansions of the OPT_* macros to\nmake it more readable which one-letter macro parameter initializes\nwhich field in the resulting 'struct option'.\n\nSZEDER Gábor (3):\n  parse-options.h: use consistent name for the callback parameters\n  parse-options.h: rename _OPT_CONTAINS_OR_WITH()'s parameters\n  parse-options.h: use designated initializers in OPT_* macros\n\n parse-options.h | 311 +++++++++++++++++++++++++++++++++++++-----------\n 1 file changed, 244 insertions(+), 67 deletions(-)\n\n-- \n2.40.0.499.g88fa0b00d2\n\n"},{"id":"473736","messageId":"20230319165648.656738-2-szeder.dev@gmail.com","threadId":"59418","inReplyTo":"20230319165648.656738-1-szeder.dev@gmail.com","subject":"[PATCH 1/3] parse-options.h: use consistent name for the callback parameters","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2023-03-19T16:56:46Z","receivedAt":"2023-03-19T16:56:59Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"In the various OPT_* macros the 'f' parameter is usually used to\nspecify flags, while the 'cb' parameter is used to specify a callback\nfunction.  OPT_CALLBACK and OPT_NUMBER_CALLBACKS, however, are\ninconsistent with the rest, as they use 'f' to specify their callback\nfunction.\n\nRename their callback macro parameters to 'cb' to avoid the\ninconsistency.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n parse-options.h | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex 50d852f299..34f8caf369 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -199,10 +199,10 @@ struct option {\n #define OPT_EXPIRY_DATE(s, l, v, h) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), N_(\"expiry-date\"),(h), 0,\t\\\n \t  parse_opt_expiry_date_cb }\n-#define OPT_CALLBACK(s, l, v, a, h, f) OPT_CALLBACK_F(s, l, v, a, h, 0, f)\n-#define OPT_NUMBER_CALLBACK(v, h, f) \\\n+#define OPT_CALLBACK(s, l, v, a, h, cb) OPT_CALLBACK_F(s, l, v, a, h, 0, cb)\n+#define OPT_NUMBER_CALLBACK(v, h, cb) \\\n \t{ OPTION_NUMBER, 0, NULL, (v), NULL, (h), \\\n-\t  PARSE_OPT_NOARG | PARSE_OPT_NONEG, (f) }\n+\t  PARSE_OPT_NOARG | PARSE_OPT_NONEG, (cb) }\n #define OPT_FILENAME(s, l, v, h)    { OPTION_FILENAME, (s), (l), (v), \\\n \t\t\t\t       N_(\"file\"), (h) }\n #define OPT_COLOR_FLAG(s, l, v, h) \\\n-- \n2.40.0.499.g88fa0b00d2\n\n"},{"id":"473737","messageId":"20230319165648.656738-3-szeder.dev@gmail.com","threadId":"59418","inReplyTo":"20230319165648.656738-1-szeder.dev@gmail.com","subject":"[PATCH 2/3] parse-options.h: rename _OPT_CONTAINS_OR_WITH()'s parameters","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2023-03-19T16:56:47Z","receivedAt":"2023-03-19T16:57:03Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Rename the 'help' parameter as it matches one of the fields in 'struct\noption', and, while at it, rename all other parameters to the usual\none-letter name used in similar macro definitions.\n\nFurthermore, put all parameters in the replacement list between\nparentheses, like all other OPT_* macros do.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n parse-options.h | 6 +++---\n 1 file changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex 34f8caf369..7e99322bab 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -381,9 +381,9 @@ int parse_opt_tracking_mode(const struct option *, const char *, int);\n \t{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), parse_opt_passthru }\n #define OPT_PASSTHRU_ARGV(s, l, v, a, h, f) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), parse_opt_passthru_argv }\n-#define _OPT_CONTAINS_OR_WITH(name, variable, help, flag) \\\n-\t{ OPTION_CALLBACK, 0, name, (variable), N_(\"commit\"), (help), \\\n-\t  PARSE_OPT_LASTARG_DEFAULT | flag, \\\n+#define _OPT_CONTAINS_OR_WITH(l, v, h, f) \\\n+\t{ OPTION_CALLBACK, 0, (l), (v), N_(\"commit\"), (h), \\\n+\t  PARSE_OPT_LASTARG_DEFAULT | (f), \\\n \t  parse_opt_commits, (intptr_t) \"HEAD\" \\\n \t}\n #define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"contains\", v, h, PARSE_OPT_NONEG)\n-- \n2.40.0.499.g88fa0b00d2\n\n"},{"id":"473738","messageId":"20230319165648.656738-4-szeder.dev@gmail.com","threadId":"59418","inReplyTo":"20230319165648.656738-1-szeder.dev@gmail.com","subject":"[PATCH 3/3] parse-options.h: use designated initializers in OPT_* macros","fromName":"SZEDER Gábor","fromEmail":"szeder.dev@gmail.com","sentAt":"2023-03-19T16:56:48Z","receivedAt":"2023-03-19T16:57:09Z","isPatch":true,"sender":{"key":"szeder.dev@gmail.com","avatar":"https://avatars.githubusercontent.com/u/116324?v=4"},"body":"Use designated initializers in the expansions of the OPT_* macros to\nmake it more readable which one-letter macro parameter initializes\nwhich field in the resulting 'struct option'.\n\nSigned-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n---\n parse-options.h | 309 +++++++++++++++++++++++++++++++++++++-----------\n 1 file changed, 243 insertions(+), 66 deletions(-)\n\ndiff --git a/parse-options.h b/parse-options.h\nindex 7e99322bab..26f19384e5 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -158,71 +158,202 @@ struct option {\n \tparse_opt_subcommand_fn *subcommand_fn;\n };\n \n-#define OPT_BIT_F(s, l, v, h, b, f) { OPTION_BIT, (s), (l), (v), NULL, (h), \\\n-\t\t\t\t      PARSE_OPT_NOARG|(f), NULL, (b) }\n-#define OPT_COUNTUP_F(s, l, v, h, f) { OPTION_COUNTUP, (s), (l), (v), NULL, \\\n-\t\t\t\t       (h), PARSE_OPT_NOARG|(f) }\n-#define OPT_SET_INT_F(s, l, v, h, i, f) { OPTION_SET_INT, (s), (l), (v), NULL, \\\n-\t\t\t\t\t  (h), PARSE_OPT_NOARG | (f), NULL, (i) }\n+#define OPT_BIT_F(s, l, v, h, b, f) { \\\n+\t.type = OPTION_BIT, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG|(f), \\\n+\t.callback = NULL, \\\n+\t.defval = (b), \\\n+}\n+#define OPT_COUNTUP_F(s, l, v, h, f) { \\\n+\t.type = OPTION_COUNTUP, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG|(f), \\\n+}\n+#define OPT_SET_INT_F(s, l, v, h, i, f) { \\\n+\t.type = OPTION_SET_INT, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG | (f), \\\n+\t.defval = (i), \\\n+}\n #define OPT_BOOL_F(s, l, v, h, f)   OPT_SET_INT_F(s, l, v, h, 1, f)\n-#define OPT_CALLBACK_F(s, l, v, a, h, f, cb)\t\t\t\\\n-\t{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), (cb) }\n-#define OPT_STRING_F(s, l, v, a, h, f)   { OPTION_STRING,  (s), (l), (v), (a), (h), (f) }\n-#define OPT_INTEGER_F(s, l, v, h, f)     { OPTION_INTEGER, (s), (l), (v), N_(\"n\"), (h), (f) }\n+#define OPT_CALLBACK_F(s, l, v, a, h, f, cb) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = (a), \\\n+\t.help = (h), \\\n+\t.flags = (f), \\\n+\t.callback = (cb), \\\n+}\n+#define OPT_STRING_F(s, l, v, a, h, f) { \\\n+\t.type = OPTION_STRING, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = (a), \\\n+\t.help = (h), \\\n+\t.flags = (f), \\\n+}\n+#define OPT_INTEGER_F(s, l, v, h, f) { \\\n+\t.type = OPTION_INTEGER, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = N_(\"n\"), \\\n+\t.help = (h), \\\n+\t.flags = (f), \\\n+}\n \n-#define OPT_END()                   { OPTION_END }\n-#define OPT_GROUP(h)                { OPTION_GROUP, 0, NULL, NULL, NULL, (h) }\n+#define OPT_END() { \\\n+\t.type = OPTION_END, \\\n+}\n+#define OPT_GROUP(h) { \\\n+\t.type = OPTION_GROUP, \\\n+\t.help = (h), \\\n+}\n #define OPT_BIT(s, l, v, h, b)      OPT_BIT_F(s, l, v, h, b, 0)\n-#define OPT_BITOP(s, l, v, h, set, clear) { OPTION_BITOP, (s), (l), (v), NULL, (h), \\\n-\t\t\t\t\t    PARSE_OPT_NOARG|PARSE_OPT_NONEG, NULL, \\\n-\t\t\t\t\t    (set), NULL, (clear) }\n-#define OPT_NEGBIT(s, l, v, h, b)   { OPTION_NEGBIT, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG, NULL, (b) }\n+#define OPT_BITOP(s, l, v, h, set, clear) { \\\n+\t.type = OPTION_BITOP, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG|PARSE_OPT_NONEG, \\\n+\t.defval = (set), \\\n+\t.extra = (clear), \\\n+}\n+#define OPT_NEGBIT(s, l, v, h, b) { \\\n+\t.type = OPTION_NEGBIT, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG, \\\n+\t.defval = (b), \\\n+}\n #define OPT_COUNTUP(s, l, v, h)     OPT_COUNTUP_F(s, l, v, h, 0)\n #define OPT_SET_INT(s, l, v, h, i)  OPT_SET_INT_F(s, l, v, h, i, 0)\n #define OPT_BOOL(s, l, v, h)        OPT_BOOL_F(s, l, v, h, 0)\n-#define OPT_HIDDEN_BOOL(s, l, v, h) { OPTION_SET_INT, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, NULL, 1}\n-#define OPT_CMDMODE_F(s, l, v, h, i, f)  { OPTION_SET_INT, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_CMDMODE|PARSE_OPT_NOARG|PARSE_OPT_NONEG | (f), NULL, (i) }\n+#define OPT_HIDDEN_BOOL(s, l, v, h) { \\\n+\t.type = OPTION_SET_INT, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG | PARSE_OPT_HIDDEN, \\\n+\t.defval = 1, \\\n+}\n+#define OPT_CMDMODE_F(s, l, v, h, i, f) { \\\n+\t.type = OPTION_SET_INT, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_CMDMODE|PARSE_OPT_NOARG|PARSE_OPT_NONEG | (f), \\\n+\t.defval = (i), \\\n+}\n #define OPT_CMDMODE(s, l, v, h, i)  OPT_CMDMODE_F(s, l, v, h, i, 0)\n \n #define OPT_INTEGER(s, l, v, h)     OPT_INTEGER_F(s, l, v, h, 0)\n-#define OPT_MAGNITUDE(s, l, v, h)   { OPTION_MAGNITUDE, (s), (l), (v), \\\n-\t\t\t\t      N_(\"n\"), (h), PARSE_OPT_NONEG }\n+#define OPT_MAGNITUDE(s, l, v, h) { \\\n+\t.type = OPTION_MAGNITUDE, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = N_(\"n\"), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NONEG, \\\n+}\n #define OPT_STRING(s, l, v, a, h)   OPT_STRING_F(s, l, v, a, h, 0)\n-#define OPT_STRING_LIST(s, l, v, a, h) \\\n-\t\t\t\t    { OPTION_CALLBACK, (s), (l), (v), (a), \\\n-\t\t\t\t      (h), 0, &parse_opt_string_list }\n-#define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n-\t\t\t\t      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }\n-#define OPT_EXPIRY_DATE(s, l, v, h) \\\n-\t{ OPTION_CALLBACK, (s), (l), (v), N_(\"expiry-date\"),(h), 0,\t\\\n-\t  parse_opt_expiry_date_cb }\n+#define OPT_STRING_LIST(s, l, v, a, h) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = (a), \\\n+\t.help = (h), \\\n+\t.callback = &parse_opt_string_list, \\\n+}\n+#define OPT_UYN(s, l, v, h) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG, \\\n+\t.callback = &parse_opt_tertiary, \\\n+}\n+#define OPT_EXPIRY_DATE(s, l, v, h) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = N_(\"expiry-date\"), \\\n+\t.help = (h), \\\n+\t.callback = parse_opt_expiry_date_cb, \\\n+}\n #define OPT_CALLBACK(s, l, v, a, h, cb) OPT_CALLBACK_F(s, l, v, a, h, 0, cb)\n-#define OPT_NUMBER_CALLBACK(v, h, cb) \\\n-\t{ OPTION_NUMBER, 0, NULL, (v), NULL, (h), \\\n-\t  PARSE_OPT_NOARG | PARSE_OPT_NONEG, (cb) }\n-#define OPT_FILENAME(s, l, v, h)    { OPTION_FILENAME, (s), (l), (v), \\\n-\t\t\t\t       N_(\"file\"), (h) }\n-#define OPT_COLOR_FLAG(s, l, v, h) \\\n-\t{ OPTION_CALLBACK, (s), (l), (v), N_(\"when\"), (h), PARSE_OPT_OPTARG, \\\n-\t\tparse_opt_color_flag_cb, (intptr_t)\"always\" }\n+#define OPT_NUMBER_CALLBACK(v, h, cb) { \\\n+\t.type = OPTION_NUMBER, \\\n+\t.value = (v), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_NOARG | PARSE_OPT_NONEG, \\\n+\t.callback = (cb), \\\n+}\n+#define OPT_FILENAME(s, l, v, h) { \\\n+\t.type = OPTION_FILENAME, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = N_(\"file\"), \\\n+\t.help = (h), \\\n+}\n+#define OPT_COLOR_FLAG(s, l, v, h) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = N_(\"when\"), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_OPTARG, \\\n+\t.callback = parse_opt_color_flag_cb, \\\n+\t.defval = (intptr_t)\"always\", \\\n+}\n \n-#define OPT_NOOP_NOARG(s, l) \\\n-\t{ OPTION_CALLBACK, (s), (l), NULL, NULL, \\\n-\t  N_(\"no-op (backward compatibility)\"),\t\t\\\n-\t  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, parse_opt_noop_cb }\n+#define OPT_NOOP_NOARG(s, l) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.help = N_(\"no-op (backward compatibility)\"), \\\n+\t.flags = PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, \\\n+\t.callback = parse_opt_noop_cb, \\\n+}\n \n-#define OPT_ALIAS(s, l, source_long_name) \\\n-\t{ OPTION_ALIAS, (s), (l), (source_long_name) }\n+#define OPT_ALIAS(s, l, source_long_name) { \\\n+\t.type = OPTION_ALIAS, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (source_long_name), \\\n+}\n \n #define OPT_SUBCOMMAND_F(l, v, fn, f) { \\\n \t.type = OPTION_SUBCOMMAND, \\\n \t.long_name = (l), \\\n \t.value = (v), \\\n \t.flags = (f), \\\n-\t.subcommand_fn = (fn) }\n+\t.subcommand_fn = (fn), \\\n+}\n #define OPT_SUBCOMMAND(l, v, fn)    OPT_SUBCOMMAND_F((l), (v), (fn), 0)\n \n /*\n@@ -358,34 +489,80 @@ int parse_opt_tracking_mode(const struct option *, const char *, int);\n \n #define OPT__VERBOSE(var, h)  OPT_COUNTUP('v', \"verbose\", (var), (h))\n #define OPT__QUIET(var, h)    OPT_COUNTUP('q', \"quiet\",   (var), (h))\n-#define OPT__VERBOSITY(var) \\\n-\t{ OPTION_CALLBACK, 'v', \"verbose\", (var), NULL, N_(\"be more verbose\"), \\\n-\t  PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }, \\\n-\t{ OPTION_CALLBACK, 'q', \"quiet\", (var), NULL, N_(\"be more quiet\"), \\\n-\t  PARSE_OPT_NOARG, &parse_opt_verbosity_cb, 0 }\n+#define OPT__VERBOSITY(var) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = 'v', \\\n+\t.long_name = \"verbose\", \\\n+\t.value = (var), \\\n+\t.help = N_(\"be more verbose\"), \\\n+\t.flags = PARSE_OPT_NOARG, \\\n+\t.callback = &parse_opt_verbosity_cb, \\\n+}, { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = 'q', \\\n+\t.long_name = \"quiet\", \\\n+\t.value = (var), \\\n+\t.help = N_(\"be more quiet\"), \\\n+\t.flags = PARSE_OPT_NOARG, \\\n+\t.callback = &parse_opt_verbosity_cb, \\\n+}\n #define OPT__DRY_RUN(var, h)  OPT_BOOL('n', \"dry-run\", (var), (h))\n #define OPT__FORCE(var, h, f) OPT_COUNTUP_F('f', \"force\",   (var), (h), (f))\n-#define OPT__ABBREV(var)  \\\n-\t{ OPTION_CALLBACK, 0, \"abbrev\", (var), N_(\"n\"),\t\\\n-\t  N_(\"use <n> digits to display object names\"),\t\\\n-\t  PARSE_OPT_OPTARG, &parse_opt_abbrev_cb, 0 }\n+#define OPT__ABBREV(var) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.long_name = \"abbrev\", \\\n+\t.value = (var), \\\n+\t.argh = N_(\"n\"), \\\n+\t.help = N_(\"use <n> digits to display object names\"), \\\n+\t.flags = PARSE_OPT_OPTARG, \\\n+\t.callback = &parse_opt_abbrev_cb, \\\n+}\n #define OPT__SUPER_PREFIX(var) \\\n \tOPT_STRING_F(0, \"super-prefix\", (var), N_(\"prefix\"), \\\n \t\tN_(\"prefixed path to initial superproject\"), PARSE_OPT_HIDDEN)\n \n #define OPT__COLOR(var, h) \\\n \tOPT_COLOR_FLAG(0, \"color\", (var), (h))\n-#define OPT_COLUMN(s, l, v, h) \\\n-\t{ OPTION_CALLBACK, (s), (l), (v), N_(\"style\"), (h), PARSE_OPT_OPTARG, parseopt_column_callback }\n-#define OPT_PASSTHRU(s, l, v, a, h, f) \\\n-\t{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), parse_opt_passthru }\n-#define OPT_PASSTHRU_ARGV(s, l, v, a, h, f) \\\n-\t{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), parse_opt_passthru_argv }\n-#define _OPT_CONTAINS_OR_WITH(l, v, h, f) \\\n-\t{ OPTION_CALLBACK, 0, (l), (v), N_(\"commit\"), (h), \\\n-\t  PARSE_OPT_LASTARG_DEFAULT | (f), \\\n-\t  parse_opt_commits, (intptr_t) \"HEAD\" \\\n-\t}\n+#define OPT_COLUMN(s, l, v, h) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = N_(\"style\"), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_OPTARG, \\\n+\t.callback = parseopt_column_callback, \\\n+}\n+#define OPT_PASSTHRU(s, l, v, a, h, f) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = (a), \\\n+\t.help = (h), \\\n+\t.flags = (f), \\\n+\t.callback = parse_opt_passthru, \\\n+}\n+#define OPT_PASSTHRU_ARGV(s, l, v, a, h, f) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.short_name = (s), \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = (a), \\\n+\t.help = (h), \\\n+\t.flags = (f), \\\n+\t.callback = parse_opt_passthru_argv, \\\n+}\n+#define _OPT_CONTAINS_OR_WITH(l, v, h, f) { \\\n+\t.type = OPTION_CALLBACK, \\\n+\t.long_name = (l), \\\n+\t.value = (v), \\\n+\t.argh = N_(\"commit\"), \\\n+\t.help = (h), \\\n+\t.flags = PARSE_OPT_LASTARG_DEFAULT | (f), \\\n+\t.callback = parse_opt_commits, \\\n+\t.defval = (intptr_t) \"HEAD\", \\\n+}\n #define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"contains\", v, h, PARSE_OPT_NONEG)\n #define OPT_NO_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"no-contains\", v, h, PARSE_OPT_NONEG)\n #define OPT_WITH(v, h) _OPT_CONTAINS_OR_WITH(\"with\", v, h, PARSE_OPT_HIDDEN | PARSE_OPT_NONEG)\n-- \n2.40.0.499.g88fa0b00d2\n\n"},{"id":"473785","messageId":"CABPp-BGXuQEef1Z2fDeHNJi=RSiTK1Jp1PehCtFvT1nzvJmoYw@mail.gmail.com","threadId":"59418","inReplyTo":"20230319165648.656738-1-szeder.dev@gmail.com","subject":"Re: [PATCH 0/3] parse-options.h: use designated initializers in OPT_* macros","fromName":"Elijah Newren","fromEmail":"newren@gmail.com","sentAt":"2023-03-20T16:53:28Z","receivedAt":"2023-03-20T17:09:38Z","isPatch":true,"sender":{"key":"newren@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5455730?v=4"},"body":"On Sun, Mar 19, 2023 at 10:06 AM SZEDER Gábor <szeder.dev@gmail.com> wrote:\n>\n> Use designated initializers in the expansions of the OPT_* macros to\n> make it more readable which one-letter macro parameter initializes\n> which field in the resulting 'struct option'.\n\nThis series makes the code easier for me to read; thanks for\nsubmitting them.  The series is pretty short and easy to read, and I\ncouldn't find any issues anywhere.\n\nReviewed-by: Elijah Newren <newren@gmail.com>\n"},{"id":"473795","messageId":"xmqqr0tjl24k.fsf@gitster.g","threadId":"59418","inReplyTo":"20230319165648.656738-3-szeder.dev@gmail.com","subject":"Re: [PATCH 2/3] parse-options.h: rename _OPT_CONTAINS_OR_WITH()'s parameters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-03-20T18:16:27Z","receivedAt":"2023-03-20T18:24:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"SZEDER Gábor <szeder.dev@gmail.com> writes:\n\n> Rename the 'help' parameter as it matches one of the fields in 'struct\n> option', and, while at it, rename all other parameters to the usual\n> one-letter name used in similar macro definitions.\n>\n> Furthermore, put all parameters in the replacement list between\n> parentheses, like all other OPT_* macros do.\n\nThis step when taken alone smells like it is going backwards in the\nreadability department by going from a set meaningful names to\nanother set of more cryptic names, but together with 3/3 where the\ndesignated initializers clarify what these cryptic args with short\nnames correspond to, the end result gives us a pleasant read.\n\nThanks.\n\n>\n> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>\n> ---\n>  parse-options.h | 6 +++---\n>  1 file changed, 3 insertions(+), 3 deletions(-)\n>\n> diff --git a/parse-options.h b/parse-options.h\n> index 34f8caf369..7e99322bab 100644\n> --- a/parse-options.h\n> +++ b/parse-options.h\n> @@ -381,9 +381,9 @@ int parse_opt_tracking_mode(const struct option *, const char *, int);\n>  \t{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), parse_opt_passthru }\n>  #define OPT_PASSTHRU_ARGV(s, l, v, a, h, f) \\\n>  \t{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), parse_opt_passthru_argv }\n> -#define _OPT_CONTAINS_OR_WITH(name, variable, help, flag) \\\n> -\t{ OPTION_CALLBACK, 0, name, (variable), N_(\"commit\"), (help), \\\n> -\t  PARSE_OPT_LASTARG_DEFAULT | flag, \\\n> +#define _OPT_CONTAINS_OR_WITH(l, v, h, f) \\\n> +\t{ OPTION_CALLBACK, 0, (l), (v), N_(\"commit\"), (h), \\\n> +\t  PARSE_OPT_LASTARG_DEFAULT | (f), \\\n>  \t  parse_opt_commits, (intptr_t) \"HEAD\" \\\n>  \t}\n>  #define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH(\"contains\", v, h, PARSE_OPT_NONEG)\n"}]}