{"thread":{"id":"43724","subject":"Re: [PATCH] Add --add option to git-repo-config","startedAt":"2006-12-14T13:46:23Z","lastAt":"2006-12-15T11:44:42Z","messageCount":3,"participants":["Brian Gernhardt","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"298523","messageId":"75CF19E7-7953-4C0A-B4CE-E9BB6822E062@silverinsanity.com","threadId":"43724","inReplyTo":null,"subject":"[PATCH] Add --add option to git-repo-config","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2006-12-14T13:46:23Z","receivedAt":"2006-12-14T13:46:23Z","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 so new users can find it and and a test to\nmake sure it works.\n\nSigned-off-by: Brian Gernhardt <benji@silverinsanity.com>\n---\n\nFound myself wanting this so decided to code it myself instead of\njust complaining.\n\nDocumentation/git-repo-config.txt |   14 +++++++++++++-\nbuiltin-repo-config.c             |    6 ++++--\nt/t1300-repo-config.sh            |   10 ++++++++++\n3 files changed, 27 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-repo-config.txt b/Documentation/git- \nrepo-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  \n[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  \ncommand. The name is\n  actually the section and the key separated by a dot, and the value  \nwill be\n  escaped.\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+--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  \nexclamation mark, you have to\n  % git repo-config section.key value '[!]'\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+\ninclude::config.txt[]\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  static const char git_config_set_usage[] =\n-\"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all  \n| --get-regexp | --replace-all | --unset | --unset-all] name [value  \n[value_regex]] | --list\";\n+\"git-repo-config [ --global ] [ --bool | --int ] [--get | --get-all  \n| --get-regexp | --replace-all | --add | --unset | --unset-all] name  \n[value [value_regex]] | --list\";\n  static char *key;\n  static regex_t *key_regexp;\n@@ -190,7 +190,9 @@ int cmd_repo_config(int argc, const char **argv,  \nconst 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  \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+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  \noutput expect'\n+\n  cat > .git/config << EOF\n  [novalue]\n  \tvariable\n--\n1.4.4.1.GIT\n"},{"id":"297846","messageId":"eltno8$vos$1@sea.gmane.org","threadId":"43724","inReplyTo":"75CF19E7-7953-4C0A-B4CE-E9BB6822E062@silverinsanity.com","subject":"Re: [PATCH] Add --add option to git-repo-config","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-12-15T08:54:53Z","receivedAt":"2006-12-15T08:54:53Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Brian Gernhardt wrote:\n\n>   'git-repo-config' [--global] [type] name [value [value_regex]]\n> +'git-repo-config' [--global] [type] --add name value\n\nIn few places it seems that original has one space at beginning of line,\nand added value lacks this space.\n\nOtherwise, very nice patch. Thanks!\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"297381","messageId":"A2C282DE-30E3-401C-AE46-777F3DDDFA86@silverinsanity.com","threadId":"43724","inReplyTo":"eltno8$vos$1@sea.gmane.org","subject":"Re: [PATCH] Add --add option to git-repo-config","fromName":"Brian Gernhardt","fromEmail":"benji@silverinsanity.com","sentAt":"2006-12-15T11:44:42Z","receivedAt":"2006-12-15T11:44:42Z","isPatch":true,"sender":{"key":"benji@silverinsanity.com","avatar":"https://gravatar.com/avatar/e06c101dbc25c68114d859b4a9ec7cf8a2c52fd2b0270ef0eac0e2e63ff22311?d=mp&s=160"},"body":"\nOn Dec 15, 2006, at 3:54 AM, Jakub Narebski wrote:\n\n> Brian Gernhardt wrote:\n>\n>>   'git-repo-config' [--global] [type] name [value [value_regex]]\n>> +'git-repo-config' [--global] [type] --add name value\n>\n> In few places it seems that original has one space at beginning of  \n> line,\n> and added value lacks this space.\n>\n> Otherwise, very nice patch. Thanks!\n\nNone of the originals have spaces at the beginning of the lines in my  \nrepo.  I think that's an artifact of Mail.app mangling whitespace at  \nthe beginning of the line when copy/pasting patches.  I thought it  \nonly happened in a couple places and tried to fix it by hand.   \nApparently that didn't work, and I need to install mutt or something  \nto send things from the command line.  In the meantime, I can re-send  \nthe patch as an attachment, if that'll help.\n\n"}]}