6 use lib
$ENV{GL_LIBDIR
};
9 use Gitolite
::Conf
::Load
;
12 Usage: gitolite git-config [-n] [-q] [-r] <repo> <key|pattern>
14 Print git config keys and values for the given repo. The key is either a full
15 key, or, if '-r' is supplied, a regex that is applied to all available keys.
17 -q exit code only (shell truth; 0 is success)
18 -n suppress trailing newline when used as key (not pattern)
19 -r treat key as regex pattern (unanchored)
20 -ev print keys with empty values also (see below)
23 gitolite git-config repo gitweb.owner
24 gitolite git-config -q repo gitweb.owner
25 gitolite git-config -r repo gitweb
29 1. When the key is treated as a pattern, prints:
31 reponame<tab>key<tab>value<newline>
33 Otherwise the output is just the value.
35 2. By default, keys with empty values (specified as "" in the conf file) are
36 treated as non-existant. Using '-ev' will print those keys also. Note
37 that this only makes sense when the key is treated as a pattern, where
38 such keys are printed as:
40 reponame<tab>key<tab><newline>
42 3. Finally, see the advanced use section of 'gitolite access -h' -- you can
43 do something similar here also:
45 gitolite list-phy-repos | gitolite git-config -r % gitweb\\. | cut -f1 > ~/projects.list
50 my ( $help, $nonl, $quiet, $regex, $ev ) = (0) x
5;
59 my ( $repo, $key ) = @ARGV;
64 if ( $repo ne '%' and $key ne '%' ) {
65 # single repo, single key; no STDIN
66 $key = "^\Q$key\E\$" unless $regex;
68 $ret = git_config
( $repo, $key, $ev );
70 # if the key is not a regex, it should match at most one item
71 _die
"found more than one entry for '$key'" if not $regex and scalar( keys %$ret ) > 1;
73 # unlike access, there's nothing to print if we don't find any matching keys
77 map { print "$repo\t$_\t" . $ret->{$_} . "\n" } sort keys %$ret unless $quiet;
79 map { print $ret->{$_} . ( $nonl ?
"" : "\n" ) } sort keys %$ret unless $quiet;
84 $repo = '' if $repo eq '%';
85 $key = '' if $key eq '%';
87 _die
"'-q' doesn't go with using a pipe" if $quiet;
91 my $r = $repo || shift @in;
92 my $k = $key || shift @in;
93 $k = "^\Q$k\E\$" unless $regex;
94 $ret = git_config
( $r, $k, $ev );
96 map { print "$r\t$_\t" . $ret->{$_} . "\n" } sort keys %$ret;