summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 36932ea)
raw | patch | inline | side by side (parent: 36932ea)
author | Petr Baudis <pasky@suse.cz> | |
Mon, 24 Apr 2006 22:59:25 +0000 (00:59 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 25 Apr 2006 05:29:33 +0000 (22:29 -0700) |
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>
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>
Documentation/git-repo-config.txt | patch | blob | history | |
repo-config.c | patch | blob | history |
index 71f96bdd10d31b28a4c280dc33c97d69a51bbf42..566cfa183640a629ee6dcfca714169ec48f28948 100644 (file)
'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
-----------
--unset-all::
Remove all matching lines from .git/config.
+-l, --list::
+ List all variables set in .git/config.
+
EXAMPLE
-------
diff --git a/repo-config.c b/repo-config.c
index c5ebb7668a2632ef94cc798552ddd3f6f173e4f4..fa8aba7a1b8760f0316ef0d47c40b0078316ff57 100644 (file)
--- a/repo-config.c
+++ b/repo-config.c
#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;
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)
}
}
- i = git_config(show_config);
+ git_config(show_config);
if (value) {
printf("%s\n", value);
free(value);
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);