{"thread":{"id":"43649","subject":"[PATCH] Add --add option to git-repo-config","startedAt":"2006-12-15T12:39:04Z","lastAt":"2006-12-15T12:39:04Z","messageCount":1,"participants":["Brian Gernhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"296319","messageId":"20061215123904.GA21322@162.242.249.10.in-addr.arpa","threadId":"43649","inReplyTo":null,"subject":"[PATCH] Add --add option to git-repo-config","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2006-12-15T12:39:04Z","receivedAt":"2006-12-15T12:39:04Z","isPatch":true,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"For multivars, the \"git-repo-config name value ^$\" is useful but\nnonintuitive and troublesome to do repeatedly (since the value is not\nat the end of the command line).  This commit simply adds an --add\noption that adds a new value to a multivar.  Particularly useful for\ntracking a new branch on a remote:\n\ngit-repo-config --add remote.origin.fetch +next:origin/next\n\nIncludes documentation and test.\n\nSigned-off-by: Brian Gernhardt <benji@silverinsanity.com>\n---\n\nThis is unchanged from my last patch, but not mangled by OS X's\nclipboard or Mail.app.\n\n Documentation/git-repo-config.txt |   14 +++++++++++++-\n builtin-repo-config.c             |    6 ++++--\n t/t1300-repo-config.sh            |   10 ++++++++++\n 3 files changed, 27 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt\nindex 5bede9a..b379ec5 100644\n--- a/Documentation/git-repo-config.txt\n+++ b/Documentation/git-repo-config.txt\n@@ -10,6 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git-repo-config' [--global] [type] name [value [value_regex]]\n+'git-repo-config' [--global] [type] --add name value\n 'git-repo-config' [--global] [type] --replace-all name [value [value_regex]]\n 'git-repo-config' [--global] [type] --get name [value_regex]\n 'git-repo-config' [--global] [type] --get-all name [value_regex]\n@@ -23,7 +24,8 @@ You can query/set/replace/unset options with this command. The name is\n actually the section and the key separated by a dot, and the value will be\n escaped.\n \n-If you want to set/unset an option which can occur on multiple\n+Multiple lines can be added to an option by using the '--add' option.\n+If you want to update or unset an option which can occur on multiple\n lines, a POSIX regexp `value_regex` needs to be given.  Only the\n existing values that match the regexp are updated or unset.  If\n you want to handle the lines that do *not* match the regex, just\n@@ -53,6 +55,10 @@ OPTIONS\n \tDefault behavior is to replace at most one line. This replaces\n \tall lines matching the key (and optionally the value_regex).\n \n+--add::\n+\tAdds a new line to the option without altering any existing\n+\tvalues.  This is the same as providing '^$' as the value_regex.\n+\n --get::\n \tGet the value for a given key (optionally filtered by a regex\n \tmatching the value). Returns error code 1 if the key was not\n@@ -194,6 +200,12 @@ To actually match only values with an exclamation mark, you have to\n % git repo-config section.key value '[!]'\n ------------\n \n+To add a new proxy, without altering any of the existing ones, use\n+\n+------------\n+% git repo-config core.gitproxy '\"proxy\" for example.com'\n+------------\n+\n \n include::config.txt[]\n \ndiff --git a/builtin-repo-config.c b/builtin-repo-config.c\nindex 7b6e572..64fbdb7 100644\n--- a/builtin-repo-config.c\n+++ b/builtin-repo-config.c\n@@ -3,7 +3,7 @@\n #include <regex.h>\n \n static const char git_config_set_usage[] =\n-\"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]] | --list\";\n+\"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all | --get-regexp | --replace-all | --add | --unset | --unset-all] name [value [value_regex]] | --list\";\n \n static char *key;\n static regex_t *key_regexp;\n@@ -190,7 +190,9 @@ int cmd_repo_config(int argc, const char **argv, const char *prefix)\n \t\t\tuse_key_regexp = 1;\n \t\t\tdo_all = 1;\n \t\t\treturn get_value(argv[2], argv[3]);\n-\t\t} else if (!strcmp(argv[1], \"--replace-all\"))\n+\t\t} else if (!strcmp(argv[1], \"--add\"))\n+\t\t\treturn git_config_set_multivar(argv[2], argv[3], \"^$\", 0);\n+\t\telse if (!strcmp(argv[1], \"--replace-all\"))\n \n \t\t\treturn git_config_set_multivar(argv[2], argv[3], NULL, 1);\n \t\telse\ndiff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh\nindex 0de2497..16cd642 100755\n--- a/t/t1300-repo-config.sh\n+++ b/t/t1300-repo-config.sh\n@@ -265,6 +265,16 @@ EOF\n test_expect_success '--get-regexp' \\\n \t'git-repo-config --get-regexp in > output && cmp output expect'\n \n+git-repo-config --add nextsection.nonewline \"wow4 for you\"\n+\n+cat > expect << EOF\n+wow2 for me\n+wow4 for you\n+EOF\n+\n+test_expect_success '--add' \\\n+\t'git-repo-config --get-all nextsection.nonewline > output && cmp output expect'\n+\n cat > .git/config << EOF\n [novalue]\n \tvariable\n-- \n1.4.4.1.GIT\n"}]}