{"thread":{"id":"3288","subject":"Re: Git 1.1.6.g4d44 make test FAILURE report","startedAt":"2006-02-10T21:19:36Z","lastAt":"2006-02-12T03:14:48Z","messageCount":10,"participants":["Junio C Hamano","A Large Angry SCM","Johannes Schindelin","Petr Baudis"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"15872","messageId":"43ED0368.7020204@gmail.com","threadId":"3288","inReplyTo":null,"subject":"Git 1.1.6.g4d44 make test FAILURE report","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2006-02-10T21:19:36Z","receivedAt":"2006-02-10T21:19:36Z","isPatch":false,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Running \"make test\" from an account with an empty gcos field fails test \n6 of t1200-tutorial.sh.\n\nIf the gcos field is a single space character, \"make test\" fails test 3 \nof t3500-cherry.sh.\n"},{"id":"15865","messageId":"7vhd76vqrg.fsf@assigned-by-dhcp.cox.net","threadId":"3288","inReplyTo":"43ED0368.7020204@gmail.com","subject":"Re: Git 1.1.6.g4d44 make test FAILURE report","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-10T21:38:11Z","receivedAt":"2006-02-10T21:38:11Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; good catch.  I think we should export GIT_*_{NAME,EMAIL}\nvariables explicitly for this particular problem.  We probably\ndo _not_ want to do the same for GIT_*_DATE though.\n"},{"id":"15889","messageId":"43ED3FD3.7020005@gmail.com","threadId":"3288","inReplyTo":"7vhd76vqrg.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git 1.1.6.g4d44 make test FAILURE report","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2006-02-11T01:37:23Z","receivedAt":"2006-02-11T01:37:23Z","isPatch":false,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> Thanks; good catch.  I think we should export GIT_*_{NAME,EMAIL}\n> variables explicitly for this particular problem.  We probably\n> do _not_ want to do the same for GIT_*_DATE though.\n\nAlso, git-var complains when used by an account with an empty gcos \nfield; thereby, breaking all the non-C git commands even when the user \nis not committing.\n\nIf the _intent_ was to force commiters and author names in commits, why \nwas the test not placed only in commit-tree.c?\n"},{"id":"15892","messageId":"7vvevmtza4.fsf@assigned-by-dhcp.cox.net","threadId":"3288","inReplyTo":"43ED3FD3.7020005@gmail.com","subject":"Re: Git 1.1.6.g4d44 make test FAILURE report","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-11T02:17:07Z","receivedAt":"2006-02-11T02:17:07Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"A Large Angry SCM <gitzilla@gmail.com> writes:\n\n> Also, git-var complains when used by an account with an empty gcos\n> field; thereby, breaking all the non-C git commands even when the user\n> is not committing.\n>\n> If the _intent_ was to force commiters and author names in commits,\n> why was the test not placed only in commit-tree.c?\n\ngit-var was more or less intentional.  Scripts such as\ngit-applypatch, git-commit and git-tag use the command to grab\nCOMMITTER_IDENT to generate sign-off line and tagger information\nwhen asked, and commit-tree.c changes alone would not catch\nthem.\n\nA user eventually would make commit so it may not be a too bad\nto _strongly_ encourage setting up these environment variables,\nby being nasty ;-).  I agree it would be _very_ annoying until\nyou either fix your gecos and/or environment.\n\nIdeas welcome.\n"},{"id":"15897","messageId":"43ED5F60.1010408@gmail.com","threadId":"3288","inReplyTo":"7vvevmtza4.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git 1.1.6.g4d44 make test FAILURE report","fromName":"A Large Angry SCM","fromEmail":"gitzilla@gmail.com","sentAt":"2006-02-11T03:52:00Z","receivedAt":"2006-02-11T03:52:00Z","isPatch":false,"sender":{"key":"gitzilla@gmail.com","avatar":"https://gravatar.com/avatar/354625c442439908ff3dd99757dee330e29e9df7847472384faf7a00add247fb?d=mp&s=160"},"body":"Junio C Hamano wrote:\n> A Large Angry SCM <gitzilla@gmail.com> writes:\n> \n>>Also, git-var complains when used by an account with an empty gcos\n>>field; thereby, breaking all the non-C git commands even when the user\n>>is not committing.\n>>\n>>If the _intent_ was to force commiters and author names in commits,\n>>why was the test not placed only in commit-tree.c?\n> \n> git-var was more or less intentional.  Scripts such as\n> git-applypatch, git-commit and git-tag use the command to grab\n> COMMITTER_IDENT to generate sign-off line and tagger information\n> when asked, and commit-tree.c changes alone would not catch\n> them.\n> \n> A user eventually would make commit so it may not be a too bad\n> to _strongly_ encourage setting up these environment variables,\n> by being nasty ;-).  I agree it would be _very_ annoying until\n> you either fix your gecos and/or environment.\n> \n> Ideas welcome.\n\nIt also breaks a lot of commands not related to making commits; \ngit-fetch for one.\n"},{"id":"15899","messageId":"7v1wyasfam.fsf@assigned-by-dhcp.cox.net","threadId":"3288","inReplyTo":"43ED5F60.1010408@gmail.com","subject":"Re: Git 1.1.6.g4d44 make test FAILURE report","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-11T04:14:09Z","receivedAt":"2006-02-11T04:14:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"A Large Angry SCM <gitzilla@gmail.com> writes:\n\n> It also breaks a lot of commands not related to making commits;\n> git-fetch for one.\n\ngit-sh-setup one is easy to fix.  We could say something equally\nsilly like this instead:\n\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 1e638e4..157c7e4 100755\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -41,7 +41,11 @@ then\n \t: ${GIT_OBJECT_DIRECTORY=\"$GIT_DIR/objects\"}\n \n \t# Make sure we are in a valid repository of a vintage we understand.\n-\tGIT_DIR=\"$GIT_DIR\" git-var GIT_AUTHOR_IDENT >/dev/null || exit\n+\tGIT_DIR=\"$GIT_DIR\" git repo-config --get core.nosuch >/dev/null\n+\tif test $? == 128\n+\tthen\n+\t    exit\n+\tfi\n else\n \tGIT_DIR=$(git-rev-parse --git-dir) || exit\n fi\n\nThe only thing that code cares about is to use a relatively\ncheap command to examine \"$GIT_DIR/config\" to make sure that the\nrespository format version recorded in the file is of old enough\nvintage we understand; the command to cause .git/config to be\nread does not have to be git-var.\n\nSo after nixing that one, the remaining users all look like they\ndo want something reasonable from the user anyway, so for them\ngit-var that fails when the user has not fixed the unusable\ngecos is a desirable thing.\n\n\tgit grep -n git-var '*.sh'\n\nshows:\n\ngit-am, git-applypatch, git-format-patch::\n\tuse it to add sign-off by the user.\n\ngit-commit, git-tag::\n\tuse it to record the user identity.\n\ngit-pull::\n\tthis uses git-var-l which is unfortunate.  We should\n\tbe able to use git-repo-config instead.  Patches\n\twelcome.\n"},{"id":"15902","messageId":"7vwtg2pkt2.fsf@assigned-by-dhcp.cox.net","threadId":"3288","inReplyTo":"7v1wyasfam.fsf@assigned-by-dhcp.cox.net","subject":"Re: Git 1.1.6.g4d44 make test FAILURE report","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-11T04:43:21Z","receivedAt":"2006-02-11T04:43:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> git-sh-setup one is easy to fix.  We could say something equally\n> silly like this instead:\n\nBTW, the reason I initially did this one and git-pull with\ngit-var was there was no way to extract values from the config\nfile easily from the command line back then. git-repo-config was\ninitially called git-config-set and was about setting values.\n\nIMHO the configuration mechanism, and git-var in particular, is\nquite broken, and nobody bothered to fix it.\n\n (1) git-var -l can show all defined variables in the config\n     file, but you cannot ask about specific variable it does\n     not know about.  You have to use git-repo-config for that:\n\n\t$ git var -l | head -n 4\n        core.filemode=true\n        core.gitproxy=none for kernel.org\n        pull.twohead=resolve\n        pull.octopus=octopus\n\t$ git var core.filemode ;# it does not know\n        usage: git-var [-l | <variable>]\n\t$ git repo-config core.filemode\n\ttrue\n\n (2) git-repo-config does not have a way to list all the\n     configuration items like \"git-var -l\".\n\n (3) neither of these commands know list of all the possible\n     configuration items, nor types of them, so core.filename\n     can be spelled as \"1\" or \"true\" to mean the same thing to\n     our C code, but repo-config faithfully returns how the\n     value is literally spelled in the configuration file.  The\n     following two means the same thing to the C layer, so the\n     calling script needs to further interpret the output from\n     git-repo-config:\n\n\t$ git repo-config core.filemode ;# [core] filemode=1\n\t1\n\t$ git repo-config core.filemode ;# [core] filemode=true\n\ttrue\n\n (4) worse, boolean 'true' can be specified by just having the\n     configuration item in the file, but repo-config dumps core\n     on that:\n\n\t$ git repo-config core.filemode ;# [core] filemode\n        segmentation fault\n\nAbove problems are not the only problems with git-var and\ngit-repo-config, but these are not entirely these programs'\nfaults.  They come from the way the configuration file mechanism\nworks.  To allow different classes of configuration items to be\ndefined by commands that know about them, there is no central\nregistry of all the supported configuration items in the code.\nFor example, \"diff.*\" configuration items can be interpreted only\nby C level programs that call git_config(git_diff_config).\n\nWith the current structure, it is very hard for these commands\nto sensibly list all the configuration values (e.g. lack of\n\"[core] filemode\" in the configuration file ought to mean that\nthe executable bit is unreliable i.e. core.filemode=false, but\nthey cannot report it), or report the values taking into account\ntheir types.  I do not think they even attempt to do so.\n"},{"id":"15915","messageId":"Pine.LNX.4.63.0602111306450.25997@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3288","inReplyTo":"7vwtg2pkt2.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Teach repo-config the -l and --get-regexp options","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-02-11T12:10:19Z","receivedAt":"2006-02-11T12:10:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nNow you can say \"git-repo-config -l\" and it will output the same as\n\"git-var -l\", except that the keys are separated from the values by\na space instead of an equal sign.\n\nIf you want to match only \"core\" lines, just do\n\n\tgit-repo-config --get-regexp ^core\n\nand if you want to be more specific, you can say\n\n\tgit-repo-config --get-regexp \"^core.*mode\"\n\nto match any keys in section [core] which end in \"mode\".\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tOn Fri, 10 Feb 2006, Junio C Hamano wrote:\n\n\t> Junio C Hamano <junkio@cox.net> writes:\n\t> \n\t> > git-sh-setup one is easy to fix.  We could say something equally\n\t> > silly like this instead:\n\t> \n\t> BTW, the reason I initially did this one and git-pull with\n\t> git-var was there was no way to extract values from the config\n\t> file easily from the command line back then. git-repo-config was\n\t> initially called git-config-set and was about setting values.\n\n\tHappier?\n\n Documentation/git-repo-config.txt |   10 ++++-\n repo-config.c                     |   77 ++++++++++++++++++++++++++++---------\n 2 files changed, 68 insertions(+), 19 deletions(-)\n\naef2834ec6dfbdcca79879b4b749bbe9d3c2b63f\ndiff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt\nindex 3069464..b7e0c23 100644\n--- a/Documentation/git-repo-config.txt\n+++ b/Documentation/git-repo-config.txt\n@@ -8,10 +8,12 @@ git-repo-config - Get and set options in\n \n SYNOPSIS\n --------\n+'git-repo-config' -l\n 'git-repo-config' name [value [value_regex]]\n 'git-repo-config' --replace-all name [value [value_regex]]\n 'git-repo-config' --get name [value_regex]\n 'git-repo-config' --get-all name [value_regex]\n+'git-repo-config' --get-regexp name\n 'git-repo-config' --unset name [value_regex]\n 'git-repo-config' --unset-all name [value_regex]\n \n@@ -39,9 +41,12 @@ This command will fail if\n OPTIONS\n -------\n \n+-l::\n+\tList all key/value pairs.\n+\n --replace-all::\n \tDefault behaviour is to replace at most one line. This replaces\n-\tall lines matching the key (and optionally the value_regex)\n+\tall lines matching the key (and optionally the value_regex).\n \n --get::\n \tGet the value for a given key (optionally filtered by a regex\n@@ -51,6 +56,9 @@ OPTIONS\n \tLike get, but does not fail if the number of values for the key\n \tis not exactly one.\n \n+--get-regexp::\n+\tLike --get-all, but interprets the name as a regular expression.\n+\n --unset::\n \tRemove the line matching the key from .git/config.\n \ndiff --git a/repo-config.c b/repo-config.c\nindex c31e441..80f370e 100644\n--- a/repo-config.c\n+++ b/repo-config.c\n@@ -2,32 +2,42 @@\n #include <regex.h>\n \n static const char git_config_set_usage[] =\n-\"git-repo-config [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]]\";\n+\"git-repo-config [-l | --get | --get-all | --get-regexp | --replace-all | --unset | --unset-all] name [value [value_regex]]\";\n \n static char* key = NULL;\n static char* value = NULL;\n+static regex_t* key_regexp = NULL;\n static regex_t* regexp = NULL;\n+static int show_keys = 0;\n+static int use_key_regexp = 0;\n static int do_all = 0;\n static int do_not_match = 0;\n static int seen = 0;\n \n static int show_config(const char* key_, const char* value_)\n {\n-\tif (!strcmp(key_, key) &&\n-\t\t\t(regexp == NULL ||\n-\t\t\t (do_not_match ^\n-\t\t\t  !regexec(regexp, value_, 0, NULL, 0)))) {\n-\t\tif (do_all) {\n-\t\t\tprintf(\"%s\\n\", value_);\n+\tif (key && strcmp(key_, key))\n \t\t\treturn 0;\n-\t\t}\n-\t\tif (seen > 0) {\n-\t\t\tfprintf(stderr, \"More than one value: %s\\n\", value);\n-\t\t\tfree(value);\n-\t\t}\n-\t\tvalue = strdup(value_);\n-\t\tseen++;\n+\tif (key_regexp && regexec(key_regexp, key_, 0, NULL, 0))\n+\t\treturn 0;\n+\n+\tif (regexp && (do_not_match ^\n+\t\t\t  !!regexec(regexp, value_, 0, NULL, 0)))\n+\t\treturn 0;\n+\n+\tif (show_keys)\n+\t\tprintf(\"%s \", key_);\n+\n+\tif (do_all) {\n+\t\tprintf(\"%s\\n\", value_);\n+\t\treturn 0;\n+\t}\n+\tif (seen > 0) {\n+\t\tfprintf(stderr, \": More than one value: %s\\n\", value);\n+\t\tfree(value);\n \t}\n+\tvalue = strdup(value_);\n+\tseen++;\n \treturn 0;\n }\n \n@@ -35,10 +45,22 @@ static int get_value(const char* key_, c\n {\n \tint i;\n \n-\tkey = malloc(strlen(key_)+1);\n-\tfor (i = 0; key_[i]; i++)\n-\t\tkey[i] = tolower(key_[i]);\n-\tkey[i] = 0;\n+\tif (key_) {\n+\t\tif (use_key_regexp) {\n+\t\t\tkey_regexp = (regex_t*)malloc(sizeof(regex_t));\n+\t\t\tif (regcomp(key_regexp, key_, REG_EXTENDED)) {\n+\t\t\t\tfprintf(stderr, \"Invalid key pattern: %s\\n\",\n+\t\t\t\t\t\tregex_);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tkey = malloc(strlen(key_)+1);\n+\t\t\tfor (i = 0; key_[i]; i++)\n+\t\t\t\tkey[i] = tolower(key_[i]);\n+\t\t\tkey[i] = 0;\n+\t\t}\n+\t} else\n+\t\tkey = NULL;\n \n \tif (regex_) {\n \t\tif (regex_[0] == '!') {\n@@ -73,6 +95,15 @@ static int get_value(const char* key_, c\n int main(int argc, const char **argv)\n {\n \tsetup_git_directory();\n+\n+\tif (!strcmp(argv[1], \"-l\")) {\n+\t\tif (argc > 2)\n+\t\t\tusage(git_config_set_usage);\n+\t\tshow_keys = 1;\n+\t\tdo_all = 1;\n+\t\treturn get_value(NULL, NULL);\n+\t}\n+\n \tswitch (argc) {\n \tcase 2:\n \t\treturn get_value(argv[1], NULL);\n@@ -86,6 +117,11 @@ int main(int argc, const char **argv)\n \t\telse if (!strcmp(argv[1], \"--get-all\")) {\n \t\t\tdo_all = 1;\n \t\t\treturn get_value(argv[2], NULL);\n+\t\t} else if (!strcmp(argv[1], \"--get-regexp\")) {\n+\t\t\tshow_keys = 1;\n+\t\t\tuse_key_regexp = 1;\n+\t\t\tdo_all = 1;\n+\t\t\treturn get_value(argv[2], NULL);\n \t\t} else\n \n \t\t\treturn git_config_set(argv[1], argv[2]);\n@@ -99,6 +135,11 @@ int main(int argc, const char **argv)\n \t\telse if (!strcmp(argv[1], \"--get-all\")) {\n \t\t\tdo_all = 1;\n \t\t\treturn get_value(argv[2], argv[3]);\n+\t\t} else if (!strcmp(argv[1], \"--get-regexp\")) {\n+\t\t\tshow_keys = 1;\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 \n \t\t\treturn git_config_set_multivar(argv[2], argv[3], NULL, 1);\n-- \n1.1.4.g3d3a-dirty\n"},{"id":"15951","messageId":"7vlkwhgtua.fsf@assigned-by-dhcp.cox.net","threadId":"3288","inReplyTo":"Pine.LNX.4.63.0602111306450.25997@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Teach repo-config the -l and --get-regexp options","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-12T03:05:17Z","receivedAt":"2006-02-12T03:05:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> \tHappier?\n\nNot really.\n\nIt still dumps core with:\n\n\t[core]\n        \tboolvarsaretrueiftheirnamesarelisted\n\nThe patch does not address any of the more important issues I\nlisted with git-var and git-repo-config in that message.\n"},{"id":"15952","messageId":"20060212031448.GU31278@pasky.or.cz","threadId":"3288","inReplyTo":"7vwtg2pkt2.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Add support for explicit type specifiers when calling git-repo-config","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-02-12T03:14:48Z","receivedAt":"2006-02-12T03:14:48Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sat, Feb 11, 2006 at 05:43:21AM CET, I got a letter\nwhere Junio C Hamano <junkio@cox.net> said that...\n>  (3) neither of these commands know list of all the possible\n>      configuration items, nor types of them, so core.filename\n>      can be spelled as \"1\" or \"true\" to mean the same thing to\n>      our C code, but repo-config faithfully returns how the\n>      value is literally spelled in the configuration file.  The\n>      following two means the same thing to the C layer, so the\n>      calling script needs to further interpret the output from\n>      git-repo-config:\n> \n> \t$ git repo-config core.filemode ;# [core] filemode=1\n> \t1\n> \t$ git repo-config core.filemode ;# [core] filemode=true\n> \ttrue\n> \n>  (4) worse, boolean 'true' can be specified by just having the\n>      configuration item in the file, but repo-config dumps core\n>      on that:\n> \n> \t$ git repo-config core.filemode ;# [core] filemode\n>         segmentation fault\n\nThis patch provides a partial solution - if you query only for variables\nof the same type (or just a single variable), this adds type-checking\nand transformation to the given type.\n\nIt is basically what Cogito would like to see - centralized variables\ndatabase in GIT won't help us, but we would like to have custom but\nstill typed variables in the config file.\n\n---\n\n[PATCH] Add support for explicit type specifiers when calling git-repo-config\n\nCurrently, git-repo-config will just return the raw value of option\nas specified in the config file; this makes things difficult for scripts\ncalling it, especially if the value is supposed to be boolean.\n\nThis patch makes it possible to ask git-repo-config to check if the option\nis of the given type (int or bool) and write out the value in its\ncanonical form. If you do not pass --int or --bool, the behaviour stays\nunchanged and the raw value is emitted.\n\nThis also incidentally fixes the segfault when option with no value is\nencountered.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n\n---\ncommit 8dcc626cd144b2c6eae2a299242bbbe905cb0059\ntree 0d4dcc3a44eb318ef52c3d64dda11768745f7583\nparent 29e55cd5ad9e17d2ff8a1a37b7ee45d18d1e59d6\nauthor Petr Baudis <pasky@suse.cz> Sun, 12 Feb 2006 04:09:01 +0100\ncommitter Petr Baudis <xpasky@machine.or.cz> Sun, 12 Feb 2006 04:09:01 +0100\n\n Documentation/git-repo-config.txt |   18 ++++++--\n repo-config.c                     |   80 +++++++++++++++++++++++--------------\n 2 files changed, 62 insertions(+), 36 deletions(-)\n\ndiff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt\nindex 3069464..33fcde4 100644\n--- a/Documentation/git-repo-config.txt\n+++ b/Documentation/git-repo-config.txt\n@@ -8,12 +8,12 @@ git-repo-config - Get and set options in\n \n SYNOPSIS\n --------\n-'git-repo-config' name [value [value_regex]]\n-'git-repo-config' --replace-all name [value [value_regex]]\n-'git-repo-config' --get name [value_regex]\n-'git-repo-config' --get-all name [value_regex]\n-'git-repo-config' --unset name [value_regex]\n-'git-repo-config' --unset-all name [value_regex]\n+'git-repo-config' [type] name [value [value_regex]]\n+'git-repo-config' [type] --replace-all name [value [value_regex]]\n+'git-repo-config' [type] --get name [value_regex]\n+'git-repo-config' [type] --get-all name [value_regex]\n+'git-repo-config' [type] --unset name [value_regex]\n+'git-repo-config' [type] --unset-all name [value_regex]\n \n DESCRIPTION\n -----------\n@@ -26,6 +26,12 @@ should provide a POSIX regex for the val\n *not* matching the regex, just prepend a single exclamation mark in front\n (see EXAMPLES).\n \n+The type specifier can be either '--int' or '--bool', which will make\n+'git-repo-config' ensure that the variable(s) are of the given type and\n+convert the value to the canonical form (simple decimal number for int,\n+a \"true\" or \"false\" string for bool). If no type specifier is passed,\n+no checks or transformations are performed on the value.\n+\n This command will fail if\n \n . .git/config is invalid,\ndiff --git a/repo-config.c b/repo-config.c\nindex c31e441..ccdee3c 100644\n--- a/repo-config.c\n+++ b/repo-config.c\n@@ -2,7 +2,7 @@\n #include <regex.h>\n \n static const char git_config_set_usage[] =\n-\"git-repo-config [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]]\";\n+\"git-repo-config [ --bool | --int ] [--get | --get-all | --replace-all | --unset | --unset-all] name [value [value_regex]]\";\n \n static char* key = NULL;\n static char* value = NULL;\n@@ -10,6 +10,7 @@ static regex_t* regexp = NULL;\n static int do_all = 0;\n static int do_not_match = 0;\n static int seen = 0;\n+static enum { T_RAW, T_INT, T_BOOL } type = T_RAW;\n \n static int show_config(const char* key_, const char* value_)\n {\n@@ -25,7 +26,17 @@ static int show_config(const char* key_,\n \t\t\tfprintf(stderr, \"More than one value: %s\\n\", value);\n \t\t\tfree(value);\n \t\t}\n-\t\tvalue = strdup(value_);\n+\n+\t\tif (type == T_INT) {\n+\t\t\tvalue = malloc(256);\n+\t\t\tsprintf(value, \"%d\", git_config_int(key_, value_));\n+\t\t} else if (type == T_BOOL) {\n+\t\t\tvalue = malloc(256);\n+\t\t\tsprintf(value, \"%s\", git_config_bool(key_, value_)\n+\t\t\t\t\t     ? \"true\" : \"false\");\n+\t\t} else {\n+\t\t\tvalue = strdup(value_ ? : \"\");\n+\t\t}\n \t\tseen++;\n \t}\n \treturn 0;\n@@ -72,43 +83,52 @@ static int get_value(const char* key_, c\n \n int main(int argc, const char **argv)\n {\n+\tint i;\n \tsetup_git_directory();\n-\tswitch (argc) {\n+\tfor (i = 1; i < argc; i++) {\n+\t\tif (!strcmp(argv[i], \"--int\"))\n+\t\t\ttype = T_INT;\n+\t\telse if (!strcmp(argv[i], \"--bool\"))\n+\t\t\ttype = T_BOOL;\n+\t\telse\n+\t\t\tbreak;\n+\t}\n+\tswitch (argc-i) {\n+\tcase 1:\n+\t\treturn get_value(argv[i], NULL);\n \tcase 2:\n-\t\treturn get_value(argv[1], NULL);\n-\tcase 3:\n-\t\tif (!strcmp(argv[1], \"--unset\"))\n-\t\t\treturn git_config_set(argv[2], NULL);\n-\t\telse if (!strcmp(argv[1], \"--unset-all\"))\n-\t\t\treturn git_config_set_multivar(argv[2], NULL, NULL, 1);\n-\t\telse if (!strcmp(argv[1], \"--get\"))\n-\t\t\treturn get_value(argv[2], NULL);\n-\t\telse if (!strcmp(argv[1], \"--get-all\")) {\n+\t\tif (!strcmp(argv[i], \"--unset\"))\n+\t\t\treturn git_config_set(argv[i+1], NULL);\n+\t\telse if (!strcmp(argv[i], \"--unset-all\"))\n+\t\t\treturn git_config_set_multivar(argv[i+1], NULL, NULL, 1);\n+\t\telse if (!strcmp(argv[i], \"--get\"))\n+\t\t\treturn get_value(argv[i+1], NULL);\n+\t\telse if (!strcmp(argv[i], \"--get-all\")) {\n \t\t\tdo_all = 1;\n-\t\t\treturn get_value(argv[2], NULL);\n+\t\t\treturn get_value(argv[i+1], NULL);\n \t\t} else\n \n-\t\t\treturn git_config_set(argv[1], argv[2]);\n-\tcase 4:\n-\t\tif (!strcmp(argv[1], \"--unset\"))\n-\t\t\treturn git_config_set_multivar(argv[2], NULL, argv[3], 0);\n-\t\telse if (!strcmp(argv[1], \"--unset-all\"))\n-\t\t\treturn git_config_set_multivar(argv[2], NULL, argv[3], 1);\n-\t\telse if (!strcmp(argv[1], \"--get\"))\n-\t\t\treturn get_value(argv[2], argv[3]);\n-\t\telse if (!strcmp(argv[1], \"--get-all\")) {\n+\t\t\treturn git_config_set(argv[i], argv[i+1]);\n+\tcase 3:\n+\t\tif (!strcmp(argv[i], \"--unset\"))\n+\t\t\treturn git_config_set_multivar(argv[i+1], NULL, argv[i+2], 0);\n+\t\telse if (!strcmp(argv[i], \"--unset-all\"))\n+\t\t\treturn git_config_set_multivar(argv[i+1], NULL, argv[i+2], 1);\n+\t\telse if (!strcmp(argv[i], \"--get\"))\n+\t\t\treturn get_value(argv[i+1], argv[i+2]);\n+\t\telse if (!strcmp(argv[i], \"--get-all\")) {\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\treturn get_value(argv[i+1], argv[i+2]);\n+\t\t} else if (!strcmp(argv[i], \"--replace-all\"))\n \n-\t\t\treturn git_config_set_multivar(argv[2], argv[3], NULL, 1);\n+\t\t\treturn git_config_set_multivar(argv[i+1], argv[i+2], NULL, 1);\n \t\telse\n \n-\t\t\treturn git_config_set_multivar(argv[1], argv[2], argv[3], 0);\n-\tcase 5:\n-\t\tif (!strcmp(argv[1], \"--replace-all\"))\n-\t\t\treturn git_config_set_multivar(argv[2], argv[3], argv[4], 1);\n-\tcase 1:\n+\t\t\treturn git_config_set_multivar(argv[i], argv[i+1], argv[i+2], 0);\n+\tcase 4:\n+\t\tif (!strcmp(argv[i], \"--replace-all\"))\n+\t\t\treturn git_config_set_multivar(argv[i+1], argv[i+2], argv[i+3], 1);\n+\tcase 0:\n \tdefault:\n \t\tusage(git_config_set_usage);\n \t}\n\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nOf the 3 great composers Mozart tells us what it's like to be human,\nBeethoven tells us what it's like to be Beethoven and Bach tells us\nwhat it's like to be the universe.  -- Douglas Adams\n"}]}