{"thread":{"id":"37226","subject":"[PATCH v2] add documentation for writing config files","startedAt":"2014-07-28T10:42:26Z","lastAt":"2014-07-29T07:46:01Z","messageCount":2,"participants":["Tanay Abhra","Matthieu Moy"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"246778","messageId":"1406544146-19404-1-git-send-email-tanayabh@gmail.com","threadId":"37226","inReplyTo":null,"subject":"[PATCH v2] add documentation for writing config files","fromName":"Tanay Abhra","fromEmail":"tanayabh@gmail.com","sentAt":"2014-07-28T10:42:26Z","receivedAt":"2014-07-28T10:42:26Z","isPatch":true,"sender":{"key":"tanayabh@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2097229?v=4"},"body":"Replace TODO introduced in commit 9c3c22 with documentation\nexplaining Git config API functions for writing configuration\nfiles.\n\nSigned-off-by: Tanay Abhra <tanayabh@gmail.com>\n---\n Documentation/technical/api-config.txt | 31 ++++++++++++++++++++++++++++++-\n 1 file changed, 30 insertions(+), 1 deletion(-)\n\ndiff --git a/Documentation/technical/api-config.txt b/Documentation/technical/api-config.txt\nindex 230b3a0..edd5018 100644\n--- a/Documentation/technical/api-config.txt\n+++ b/Documentation/technical/api-config.txt\n@@ -137,4 +137,33 @@ int read_file_with_include(const char *file, config_fn_t fn, void *data)\n Writing Config Files\n --------------------\n \n-TODO\n+Git gives multiple entry points in the Config API to write config values to\n+files namely `git_config_set_in_file` and `git_config_set`, which write to\n+a specific config file or to `.git/config` respectively. They both take a\n+key/value pair as parameter.\n+In the end they both call `git_config_set_multivar_in_file` which takes four\n+parameters:\n+\n+- the name of the file, as a string, to which key/value pairs will be written.\n+\n+- the name of key, as a string. This is in canonical \"flat\" form: the section,\n+  subsection, and variable segments will be separated by dots, and the section\n+  and variable segments will be all lowercase.\n+  E.g., `core.ignorecase`, `diff.SomeType.textconv`.\n+\n+- the value of the variable, as a string. If value is equal to NULL, it will\n+  remove the matching key from the config file.\n+\n+- the value regex, as a string. It will disregard key/value pairs where value\n+  does not match.\n+\n+- a multi_replace value, as an int. If value is equal to zero, nothing or only\n+  one matching key/value is replaced, else all matching key/values (regardless\n+  how many) are removed, before the new pair is written.\n+\n+It returns 0 on success.\n+\n+Also, there are functions `git_config_rename_section` and\n+`git_config_rename_section_in_file` with parameters `old_name` and `new_name`\n+for renaming or removing sections in the config files. If NULL is passed\n+through `new_name` parameter, the section will be removed from the config file.\n-- \n1.9.0.GIT\n"},{"id":"246876","messageId":"vpqha20ip52.fsf@anie.imag.fr","threadId":"37226","inReplyTo":"1406544146-19404-1-git-send-email-tanayabh@gmail.com","subject":"Re: [PATCH v2] add documentation for writing config files","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2014-07-29T07:46:01Z","receivedAt":"2014-07-29T07:46:01Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Tanay Abhra <tanayabh@gmail.com> writes:\n\n> Replace TODO introduced in commit 9c3c22 with documentation\n> explaining Git config API functions for writing configuration\n> files.\n>\n> Signed-off-by: Tanay Abhra <tanayabh@gmail.com>\n> ---\n>  Documentation/technical/api-config.txt | 31 ++++++++++++++++++++++++++++++-\n\nSounds good to me, thanks.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}