Re: [PATCH v5 2/2] submodule: pass on http.extraheader config settings
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 28, 2016, 19:41 UTC
- Message-ID
- <xmqqshy54j2h.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <89d0024450b0e6e9997ad9e3d681248bde1bafc0.1461837783.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> - if (starts_with(var, "credential.")) > + if (starts_with(var, "credential.") || > + (starts_with(var, "http.") && > + ends_with(var, ".extraheader")))
I know you are fond of indenting with HT without aligning things, but this is going too far in the quest of making the code unreadable.
if (starts_with(var, "credential.") ||
(starts_with(var, "http.") && ends_with(var, ".extraheader")))would make iteasier to see what are the top-level items (there are two) and how they are related (just one of them needs to be satisfied).
Assuming that we will discover more variables that can be safely passed, I'd rather see the above written like this, though:
if (starts_with(var, "credential."))
return 1;
if (starts_with(var, "http.") && ends_with(var, ".extraheader"))
return 1;return 0;
Or even something along this line:
struct whitelist {
const char *prefix;
const char *suffix;
} whitelist[] = {
{ "credential.", NULL },
{ "http.", ".extraheader" },
}; for (i = 0; i < ARRAY_SIZE(whitelist); i++) {
struct whitelist *w = &whitelist[i];
if ((!w->prefix || starts_with(var, w->prefix)) &&
(!w->suffix || ends_with(var, w->suffix)))
return 1;
}
return 0;