gitweb: make remote_heads config setting work

Git configuration items can not contain underscores in their section and bottom-level variable name; the 'remote_heads' feature can not be enabled on a per-repository basis with that name. This changes the git-config option to be `gitweb.remoteheads` but does not change the gitweb.conf option, to avoid backwards compatibility issues. We strip underscores from keys before looking through git-config output for them. An existing check on keynames was overly eager to reject non-word letters, but if we ever start using three-level names, the middle level string can contain almost anything, so fix that as well while we are in the vicinity. Signed-off-by: Phil Pennock <phil@apcera.com> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phil Pennock committed Nov 5, 2012 at 18:50 UTC af507944a22a3dabe2041fe629b2178abb5c642f
1 file changed +5 -2
gitweb/gitweb.perl
+5 -2
@@ -541,7 +541,7 @@ our %feature = (
541 # $feature{'remote_heads'}{'default'} = [1];
542 # To have project specific config enable override in $GITWEB_CONFIG
543 # $feature{'remote_heads'}{'override'} = 1;
544 - # and in project config gitweb.remote_heads = 0|1;
544 + # and in project config gitweb.remoteheads = 0|1;
545 'remote_heads' => {
546 'sub' => sub { feature_bool('remote_heads', @_) },
547 'override' => 0,
@@ -2697,12 +2697,15 @@ sub git_get_project_config {
2697 # only subsection, if exists, is case sensitive,
2698 # and not lowercased by 'git config -z -l'
2699 if (my ($hi, $mi, $lo) = ($key =~ /^([^.]*)\.(.*)\.([^.]*)$/)) {
2700 + $lo =~ s/_//g;
2701 $key = join(".", lc($hi), $mi, lc($lo));
2702 + return if ($lo =~ /\W/ || $hi =~ /\W/);
2703 } else {
2704 $key = lc($key);
2705 + $key =~ s/_//g;
2706 + return if ($key =~ /\W/);
2707 }
2708 $key =~ s/^gitweb\.//;
2705 - return if ($key =~ m/\W/);
2709
2710 # type sanity check
2711 if (defined $type) {