Permalink
Browse files

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
  • Loading branch information...
1 parent 47a0c44 commit d8df4a93440ef10c28fed8eb92822538ab3d85aa @sitaramc committed May 4, 2012
Showing with 14 additions and 5 deletions.
  1. +3 −3 doc/git-config.mkd
  2. +10 −1 src/lib/Gitolite/Conf/Load.pm
  3. +1 −1 src/triggers/post-compile/update-git-configs
View
@@ -23,9 +23,9 @@ For example:
config foo.bar = ""
config foo.baz =
-This does either a plain "git config section.key value" (for the first 3
-examples above) or "git config --unset-all section.key" (for the last
-example). Other forms of the `git config` command (`--add`, the
+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 2
+examples). Other forms of the `git config` command (`--add`, the
`value_regex`, etc) are not supported.
> ----
@@ -114,7 +114,7 @@ sub access {
}
sub git_config {
- my ( $repo, $key ) = @_;
+ my ( $repo, $key, $empty_values_OK ) = @_;
$key ||= '.';
return {} if repo_missing($repo);
@@ -149,6 +149,15 @@ sub git_config {
# and the final map does this:
# '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 ) );
return \%ret;
}
@@ -37,7 +37,7 @@ for my $pr (@$lpr) {
sub fixup_config {
my $pr = shift;
- my $gc = git_config( $pr, '.' );
+ my $gc = git_config( $pr, '.', 1 );
while ( my ( $key, $value ) = each( %{$gc} ) ) {
next if $key =~ /^gitolite-options\./;
if ( $value ne "" ) {

0 comments on commit d8df4a9

Please sign in to comment.