@matheusbsbs / matheus-bagliano / commits / de791f15a1
Fork 0

git-repo-config --list support

This adds git-repo-config --list (or git-repo-config -l) support, similar to what git-var -l does now (to be phased out so that we have a single sane interface to the config file instead of fragmented and confused API). Signed-off-by: Petr Baudis <pasky@suse.cz>

Petr Baudis committed Apr 25, 2006 at 00:59 UTC de791f15a1b01e63f3c870c8497c594c47452fab
2 files changed +18 -2
Documentation/git-repo-config.txt
+4
@@ -15,6 +15,7 @@ SYNOPSIS
15 'git-repo-config' [type] --get-all name [value_regex]
16 'git-repo-config' [type] --unset name [value_regex]
17 'git-repo-config' [type] --unset-all name [value_regex]
18 +'git-repo-config' -l | --list
19
20 DESCRIPTION
21 -----------
@@ -64,6 +65,9 @@ OPTIONS
65 --unset-all::
66 Remove all matching lines from .git/config.
67
68 +-l, --list::
69 + List all variables set in .git/config.
70 +
71
72 EXAMPLE
73 -------
repo-config.c
+14 -2
@@ -2,7 +2,7 @@
2 #include <regex.h>
3
4 static const char git_config_set_usage[] =
5 -"git-repo-config [ --bool | --int ] [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]]";
5 +"git-repo-config [ --bool | --int ] [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list";
6
7 static char* key = NULL;
8 static char* value = NULL;
@@ -12,6 +12,15 @@ static int do_not_match = 0;
12 static int seen = 0;
13 static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;
14
15 +static int show_all_config(const char *key_, const char *value_)
16 +{
17 + if (value_)
18 + printf("%s=%s\n", key_, value_);
19 + else
20 + printf("%s\n", key_);
21 + return 0;
22 +}
23 +
24 static int show_config(const char* key_, const char* value_)
25 {
26 if (value_ == NULL)
@@ -67,7 +76,7 @@ static int get_value(const char* key_, const char* regex_)
76 }
77 }
78
70 - i = git_config(show_config);
79 + git_config(show_config);
80 if (value) {
81 printf("%s\n", value);
82 free(value);
@@ -99,6 +108,9 @@ int main(int argc, const char **argv)
108 argv++;
109 }
110
111 + if (!strcmp(argv[1], "--list") || !strcmp(argv[1], "-l"))
112 + return git_config(show_all_config);
113 +
114 switch (argc) {
115 case 2:
116 return get_value(argv[1], NULL);