summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9013192)
raw | patch | inline | side by side (parent: 9013192)
author | Brian Gernhardt <benji@silverinsanity.com> | |
Fri, 15 Dec 2006 12:39:04 +0000 (07:39 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 16 Dec 2006 06:31:01 +0000 (22:31 -0800) |
For multivars, the "git-repo-config name value ^$" is useful but
nonintuitive and troublesome to do repeatedly (since the value is not
at the end of the command line). This commit simply adds an --add
option that adds a new value to a multivar. Particularly useful for
tracking a new branch on a remote:
git-repo-config --add remote.origin.fetch +next:origin/next
Includes documentation and test.
Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
nonintuitive and troublesome to do repeatedly (since the value is not
at the end of the command line). This commit simply adds an --add
option that adds a new value to a multivar. Particularly useful for
tracking a new branch on a remote:
git-repo-config --add remote.origin.fetch +next:origin/next
Includes documentation and test.
Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Documentation/git-repo-config.txt | patch | blob | history | |
builtin-repo-config.c | patch | blob | history | |
t/t1300-repo-config.sh | patch | blob | history |
index 5bede9ac22d260d703c5632f44ffc404013650d0..b379ec5075981347e75d0795e44e57620d89399b 100644 (file)
--------
[verse]
'git-repo-config' [--global] [type] name [value [value_regex]]
+'git-repo-config' [--global] [type] --add name value
'git-repo-config' [--global] [type] --replace-all name [value [value_regex]]
'git-repo-config' [--global] [type] --get name [value_regex]
'git-repo-config' [--global] [type] --get-all name [value_regex]
actually the section and the key separated by a dot, and the value will be
escaped.
-If you want to set/unset an option which can occur on multiple
+Multiple lines can be added to an option by using the '--add' option.
+If you want to update or unset an option which can occur on multiple
lines, a POSIX regexp `value_regex` needs to be given. Only the
existing values that match the regexp are updated or unset. If
you want to handle the lines that do *not* match the regex, just
Default behavior is to replace at most one line. This replaces
all lines matching the key (and optionally the value_regex).
+--add::
+ Adds a new line to the option without altering any existing
+ values. This is the same as providing '^$' as the value_regex.
+
--get::
Get the value for a given key (optionally filtered by a regex
matching the value). Returns error code 1 if the key was not
% git repo-config section.key value '[!]'
------------
+To add a new proxy, without altering any of the existing ones, use
+
+------------
+% git repo-config core.gitproxy '"proxy" for example.com'
+------------
+
include::config.txt[]
diff --git a/builtin-repo-config.c b/builtin-repo-config.c
index 7b6e5725ae6d33350a9648e57139b646ab49696e..64fbdb7b2420203cf1d142e73c5ec579c95cf581 100644 (file)
--- a/builtin-repo-config.c
+++ b/builtin-repo-config.c
#include <regex.h>
static const char git_config_set_usage[] =
-"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list";
+"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --list";
static char *key;
static regex_t *key_regexp;
use_key_regexp = 1;
do_all = 1;
return get_value(argv[2], argv[3]);
- } else if (!strcmp(argv[1], "--replace-all"))
+ } else if (!strcmp(argv[1], "--add"))
+ return git_config_set_multivar(argv[2], argv[3], "^$", 0);
+ else if (!strcmp(argv[1], "--replace-all"))
return git_config_set_multivar(argv[2], argv[3], NULL, 1);
else
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 0de2497746e31f3dce418dbd248ff5d3e7cb939a..16cd6426100c0a58de854d3252a654c7ae28232a 100755 (executable)
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
test_expect_success '--get-regexp' \
'git-repo-config --get-regexp in > output && cmp output expect'
+git-repo-config --add nextsection.nonewline "wow4 for you"
+
+cat > expect << EOF
+wow2 for me
+wow4 for you
+EOF
+
+test_expect_success '--add' \
+ 'git-repo-config --get-all nextsection.nonewline > output && cmp output expect'
+
cat > .git/config << EOF
[novalue]
variable