git-config bugfix + backward compat breakage in usage of 'config'

(1) the backward compat breakage: you can't create empty-valued config
    keys anymore.  That is, you can't do the eqvt of the following shell
    command using gitolite

        git config foo.bar ""

(2) fixed a bug where this:

        repo foo
            config foo.bar =

    when queried using

        gitolite git-config -r foo .

    would return even the empty valued ones, which -- remember! -- are
    not supposed to exist anymore.

    Fixing this bug allows situations like this to not show the admin
    repo in gitweb:

        repo [a-z].*
            config gitweb.owner = P-h B

        repo gitolite-admin
            config gitweb.owner =

----

background...

Somewhere in g3 (well actually in 057506b), we lost the ability to
distinguish
    config foo.bar  =   ""
from
    config foo.bar =

I decided that conflating them is more intuitive for most people,
because a survey [1] revealed that no one seemed to want the equivalent
of the following shell command:

----

[1] ...of a (small prime greater than 1) number of people on #git
This commit is contained in:
Sitaram Chamarty 2012-05-04 16:33:04 +05:30
parent 47a0c44540
commit d8df4a9344
3 changed files with 14 additions and 5 deletions

View file

@ -23,9 +23,9 @@ For example:
config foo.bar = "" config foo.bar = ""
config foo.baz = config foo.baz =
This does either a plain "git config section.key value" (for the first 3 This does either a plain "git config section.key value" (for the first 2
examples above) or "git config --unset-all section.key" (for the last examples above) or "git config --unset-all section.key" (for the last 2
example). Other forms of the `git config` command (`--add`, the examples). Other forms of the `git config` command (`--add`, the
`value_regex`, etc) are not supported. `value_regex`, etc) are not supported.
> ---- > ----

View file

@ -114,7 +114,7 @@ sub access {
} }
sub git_config { sub git_config {
my ( $repo, $key ) = @_; my ( $repo, $key, $empty_values_OK ) = @_;
$key ||= '.'; $key ||= '.';
return {} if repo_missing($repo); return {} if repo_missing($repo);
@ -149,6 +149,15 @@ sub git_config {
# and the final map does this: # and the final map does this:
# 'foo.bar'=>'repo' , 'foodbar'=>'repoD' # 'foo.bar'=>'repo' , 'foodbar'=>'repoD'
# now some of these will have an empty key; we need to delete them unless
# we're told empty values are OK
unless ($empty_values_OK) {
my($k, $v);
while (($k, $v) = each %ret) {
delete $ret{$k} if not $v;
}
}
trace( 3, map { ( "$_" => "-> $ret{$_}" ) } ( sort keys %ret ) ); trace( 3, map { ( "$_" => "-> $ret{$_}" ) } ( sort keys %ret ) );
return \%ret; return \%ret;
} }

View file

@ -37,7 +37,7 @@ for my $pr (@$lpr) {
sub fixup_config { sub fixup_config {
my $pr = shift; my $pr = shift;
my $gc = git_config( $pr, '.' ); my $gc = git_config( $pr, '.', 1 );
while ( my ( $key, $value ) = each( %{$gc} ) ) { while ( my ( $key, $value ) = each( %{$gc} ) ) {
next if $key =~ /^gitolite-options\./; next if $key =~ /^gitolite-options\./;
if ( $value ne "" ) { if ( $value ne "" ) {