Skip to content

Commit

Permalink
Merge branch 'pb/config'
Browse files Browse the repository at this point in the history
* pb/config:
  git-cvsserver: typofixes
  Deprecate usage of git-var -l for getting config vars list
  git-repo-config --list support
  • Loading branch information
Junio C Hamano committed Apr 27, 2006
2 parents bd4bd22 + 5348b6e commit e5de2c5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
4 changes: 4 additions & 0 deletions Documentation/git-repo-config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SYNOPSIS
'git-repo-config' [type] --get-all name [value_regex]
'git-repo-config' [type] --unset name [value_regex]
'git-repo-config' [type] --unset-all name [value_regex]
'git-repo-config' -l | --list

DESCRIPTION
-----------
Expand Down Expand Up @@ -64,6 +65,9 @@ OPTIONS
--unset-all::
Remove all matching lines from .git/config.

-l, --list::
List all variables set in .git/config.


EXAMPLE
-------
Expand Down
3 changes: 2 additions & 1 deletion Documentation/git-var.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ OPTIONS
-l::
Cause the logical variables to be listed. In addition, all the
variables of the git configuration file .git/config are listed
as well.
as well. (However, the configuration variables listing functionality
is deprecated in favor of `git-repo-config -l`.)

EXAMPLE
--------
Expand Down
20 changes: 10 additions & 10 deletions git-cvsserver.perl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
$log->debug("Temporary directory is '$TEMP_DIR'");

# if we are called with a pserver argument,
# deal with the authentication cat before entereing the
# deal with the authentication cat before entering the
# main loop
if (@ARGV && $ARGV[0] eq 'pserver') {
my $line = <STDIN>; chomp $line;
Expand Down Expand Up @@ -117,7 +117,7 @@
{
chomp;

# Check to see if we've seen this method, and call appropiate function.
# Check to see if we've seen this method, and call appropriate function.
if ( /^([\w-]+)(?:\s+(.*))?$/ and defined($methods->{$1}) )
{
# use the $methods hash to call the appropriate sub for this command
Expand Down Expand Up @@ -171,11 +171,11 @@ sub req_Root
return 0;
}

my @gitvars = `git-var -l`;
my @gitvars = `git-repo-config -l`;
if ($?) {
print "E problems executing git-var on the server -- this is not a git repository or the PATH is not set correcly.\n";
print "E problems executing git-repo-config on the server -- this is not a git repository or the PATH is not set correctly.\n";
print "E \n";
print "error 1 - problem executing git-var\n";
print "error 1 - problem executing git-repo-config\n";
return 0;
}
foreach my $line ( @gitvars )
Expand Down Expand Up @@ -224,7 +224,7 @@ sub req_Globaloption
sub req_Validresponses
{
my ( $cmd, $data ) = @_;
$log->debug("req_Validrepsonses : $data");
$log->debug("req_Validresponses : $data");

# TODO : re-enable this, currently it's not particularly useful
#$state->{validresponses} = [ split /\s+/, $data ];
Expand Down Expand Up @@ -733,7 +733,7 @@ sub req_update
argsplit("update");

#
# It may just be a client exploring the available heads/modukles
# It may just be a client exploring the available heads/modules
# in that case, list them as top level directories and leave it
# at that. Eclipse uses this technique to offer you a list of
# projects (heads in this case) to checkout.
Expand Down Expand Up @@ -1731,7 +1731,7 @@ sub transmitfile
}

# This method takes a file name, and returns ( $dirpart, $filepart ) which
# refers to the directory porition and the file portion of the filename
# refers to the directory portion and the file portion of the filename
# respectively
sub filenamesplit
{
Expand Down Expand Up @@ -1790,7 +1790,7 @@ =head1 METHODS
=head2 new
Creates a new log object, optionally you can specify a filename here to
indicate the file to log to. If no log file is specified, you can specifiy one
indicate the file to log to. If no log file is specified, you can specify one
later with method setfile, or indicate you no longer want logging with method
nofile.
Expand Down Expand Up @@ -2595,7 +2595,7 @@ sub in_array

=head2 safe_pipe_capture
an alterative to `command` that allows input to be passed as an array
an alternative to `command` that allows input to be passed as an array
to work around shell problems with weird characters in arguments
=cut
Expand Down
16 changes: 14 additions & 2 deletions repo-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <regex.h>

static const char git_config_set_usage[] =
"git-repo-config [ --bool | --int ] [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]]";
"git-repo-config [ --bool | --int ] [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list";

static char* key = NULL;
static char* value = NULL;
Expand All @@ -12,6 +12,15 @@ static int do_not_match = 0;
static int seen = 0;
static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;

static int show_all_config(const char *key_, const char *value_)
{
if (value_)
printf("%s=%s\n", key_, value_);
else
printf("%s\n", key_);
return 0;
}

static int show_config(const char* key_, const char* value_)
{
if (value_ == NULL)
Expand Down Expand Up @@ -67,7 +76,7 @@ static int get_value(const char* key_, const char* regex_)
}
}

i = git_config(show_config);
git_config(show_config);
if (value) {
printf("%s\n", value);
free(value);
Expand Down Expand Up @@ -99,6 +108,9 @@ int main(int argc, const char **argv)
argv++;
}

if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
return git_config(show_all_config);

switch (argc) {
case 2:
return get_value(argv[1], NULL);
Expand Down

0 comments on commit e5de2c5

Please sign in to comment.