From d8df4a93440ef10c28fed8eb92822538ab3d85aa Mon Sep 17 00:00:00 2001 From: Sitaram Chamarty Date: Fri, 4 May 2012 16:33:04 +0530 Subject: [PATCH] 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 --- doc/git-config.mkd | 6 +++--- src/lib/Gitolite/Conf/Load.pm | 11 ++++++++++- src/triggers/post-compile/update-git-configs | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/doc/git-config.mkd b/doc/git-config.mkd index e1c1c00..94487e1 100644 --- a/doc/git-config.mkd +++ b/doc/git-config.mkd @@ -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. > ---- diff --git a/src/lib/Gitolite/Conf/Load.pm b/src/lib/Gitolite/Conf/Load.pm index 8f1ebfe..9f4ddb0 100644 --- a/src/lib/Gitolite/Conf/Load.pm +++ b/src/lib/Gitolite/Conf/Load.pm @@ -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; } diff --git a/src/triggers/post-compile/update-git-configs b/src/triggers/post-compile/update-git-configs index 7f3fb83..bd7ff13 100755 --- a/src/triggers/post-compile/update-git-configs +++ b/src/triggers/post-compile/update-git-configs @@ -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 "" ) {