From: Elijah Newren Date: Thu, 27 Aug 2026 01:19:22 GMT Subject: Re: [PATCH 2/2] die_for_incompatible_opts(): accept more than four options Message-ID: In-Reply-To: <20260826233152.1703497-3-gitster@pobox.com> On Wed, Aug 26, 2026 at 4:32 PM Junio C Hamano wrote: > [...] > +void die_for_incompatible_opts(const char *opt1_name, int opt1, ...) > { > - int count = 0; > + unsigned count = 0; > const char *options[4]; > + va_list ap; > + > + va_start(ap, opt1); > > if (opt1) > options[count++] = opt1_name; > - if (opt2) > - options[count++] = opt2_name; > - if (opt3) > - options[count++] = opt3_name; > - if (opt4) > - options[count++] = opt4_name; > + while (count < ARRAY_SIZE(options)) { > + const char *name = va_arg(ap, const char *); > + if (!name) > + break; > + if (va_arg(ap, int)) > + options[count++] = name; > + } > + > switch (count) { > case 4: > die(_("options '%s', '%s', '%s', and '%s' cannot be used together"), > - opt1_name, opt2_name, opt3_name, opt4_name); > + options[0], options[1], options[2], options[3]); > break; > case 3: > die(_("options '%s', '%s', and '%s' cannot be used together"), > diff --git a/parse-options.h b/parse-options.h va_start() without a va_end()?