Re: [RFC/PATCH 7/9] parse-options.h: add macros for '--contains' option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 8, 2015, 19:32 UTC
- Message-ID
- <xmqqr3pm9et4.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1433621052-5588-7-git-send-email-karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 10 quoted lines
> +#define OPT_CONTAINS(filter, h) \
> + { OPTION_CALLBACK, 0, "contains", (filter), N_("commit"), (h), \
> + PARSE_OPT_LASTARG_DEFAULT, \
> + parse_opt_with_commit, (intptr_t) "HEAD" \
> + }
> +#define OPT_WITH(filter, h) \
> + { OPTION_CALLBACK, 0, "with", (filter), N_("commit"), (h), \
> + PARSE_OPT_LASTARG_DEFAULT, \
> + parse_opt_with_commit, (intptr_t) "HEAD" \
> + }The redundancy bothers me. Can't we do a bit better than that, perhaps like this?
#define _OPT_CONTAINS_OR_WITH(name, variable, help) \
{ OPTION_CALLBACK, 0, name, (variable), N_("commit"), (help), \
PARSE_OPT_LASTARG_DEFAULT, \
parse_opt_with_commit, (intptr_t) "HEAD" \
}
#define OPT_CONTAINS(v, h) _OPT_CONTAINS_OR_WITH("contains", v, h)