]> Lady’s Gitweb - Gitweb/commit
gitweb: make gitweb_check_feature a boolean wrapper
authorGiuseppe Bilotta <redacted>
Sat, 29 Nov 2008 21:07:29 +0000 (13:07 -0800)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:38 +0000 (00:50 -0400)
commit29f972e8bd3db1874af42a83a81f8865c40e9b99187c9176385642e41aa8a45b
treecdca9416e50aa6f0a0497efa1b2dfc7d8876b8e7e6b3854bc277f6782e100c47
parentd3e08ba9e617ee5744f1550d5cf6bcb863bc40ee13cb5f14b91983a0602dad17
gitweb: make gitweb_check_feature a boolean wrapper

The gitweb_get_feature() function retrieves the configuration parameters
for the feature (such as the list of snapshot formats or the list of
additional actions), but it is very often used to see if feature is
enabled (which is returned as the first element in the list).

Because accepting the returned list in the scalar context by mistake
yields the number of elements in the array, which is non-zero in all
cases, such a mistake would result in a bug for the latter use, with
disabled features appearing enabled.  All existing callers that call the
function for this purpose assign the return value in the list context to
retrieve the first element, but that is only because we fixed careless
callers recently.

This adds gitweb_check_feature() as a wrapper to gitweb_get_feature() that
can be called safely in the scalar context to see if a feature is enabled
to reduce the risk of future bugs.  Callers of "get" that use the call
only to see if the feature is enabled are updated to call this wrapper.

Signed-off-by: Giuseppe Bilotta <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl
This page took 0.110221 seconds and 4 git commands to generate.