~ubuntu-branches/ubuntu/vivid/gitolite3/vivid-proposed

« back to all changes in this revision

Viewing changes to src/commands/git-config

  • Committer: Package Import Robot
  • Author(s): David Bremner
  • Date: 2014-05-25 20:09:36 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20140525200936-el6hezd1fym50pxh
Tags: 3.6-1
* New upstream release
* Depend on ssh-server instead of openssh-server (Closes: #735176).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
    -q          exit code only (shell truth; 0 is success)
18
18
    -n          suppress trailing newline when used as key (not pattern)
19
19
    -r          treat key as regex pattern (unanchored)
 
20
    -ev         print keys with empty values also (see below)
20
21
 
21
22
Examples:
22
23
    gitolite git-config repo gitweb.owner
23
24
    gitolite git-config -q repo gitweb.owner
24
25
    gitolite git-config -r repo gitweb
25
26
 
26
 
When the key is treated as a pattern, prints:
27
 
 
28
 
    reponame<tab>key<tab>value<newline>
29
 
 
30
 
Otherwise the output is just the value.
31
 
 
32
 
Finally, see the advanced use section of 'gitolite access -h' -- you can do
33
 
something similar here also:
34
 
 
35
 
    gitolite list-phy-repos | gitolite git-config -r % gitweb\\. | cut -f1 > ~/projects.list
 
27
Notes:
 
28
 
 
29
1.  When the key is treated as a pattern, prints:
 
30
 
 
31
        reponame<tab>key<tab>value<newline>
 
32
 
 
33
    Otherwise the output is just the value.
 
34
 
 
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:
 
39
 
 
40
        reponame<tab>key<tab><newline>
 
41
 
 
42
3.  Finally, see the advanced use section of 'gitolite access -h' -- you can
 
43
    do something similar here also:
 
44
 
 
45
        gitolite list-phy-repos | gitolite git-config -r % gitweb\\. | cut -f1 > ~/projects.list
36
46
=cut
37
47
 
38
48
usage() if not @ARGV;
39
49
 
40
 
my ( $help, $nonl, $quiet, $regex ) = (0) x 4;
 
50
my ( $help, $nonl, $quiet, $regex, $ev ) = (0) x 5;
41
51
GetOptions(
42
 
    'n' => \$nonl,
43
 
    'q' => \$quiet,
44
 
    'r' => \$regex,
45
 
    'h' => \$help,
 
52
    'n'  => \$nonl,
 
53
    'q'  => \$quiet,
 
54
    'r'  => \$regex,
 
55
    'h'  => \$help,
 
56
    'ev' => \$ev,
46
57
) or usage();
47
58
 
48
59
my ( $repo, $key ) = @ARGV;
54
65
    # single repo, single key; no STDIN
55
66
    $key = "^\Q$key\E\$" unless $regex;
56
67
 
57
 
    $ret = git_config( $repo, $key );
 
68
    $ret = git_config( $repo, $key, $ev );
58
69
 
59
70
    # if the key is not a regex, it should match at most one item
60
71
    _die "found more than one entry for '$key'" if not $regex and scalar( keys %$ret ) > 1;
71
82
}
72
83
 
73
84
$repo = '' if $repo eq '%';
74
 
$key  = '' if $key  eq '%';
 
85
$key  = '' if $key eq '%';
75
86
 
76
87
_die "'-q' doesn't go with using a pipe" if $quiet;
77
88
@ARGV = ();
80
91
    my $r  = $repo || shift @in;
81
92
    my $k  = $key || shift @in;
82
93
    $k = "^\Q$k\E\$" unless $regex;
83
 
    $ret = git_config( $r, $k );
 
94
    $ret = git_config( $r, $k, $ev );
84
95
    next unless %$ret;
85
96
    map { print "$r\t$_\t" . $ret->{$_} . "\n" } sort keys %$ret;
86
97
}