Skip to contentSkip to conversation

add documentation for writing config files

PATCH Superseded Tanay Abhra 2 participants 3 messages Jun 15, 2016 Documentation

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add documentation for writing config files

Replace TODO introduced in commit 9c3c22 with documentation explaining Git config API functions for writing configuration files.

---
 Documentation/technical/api-config.txt | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
Documentation/technical/api-config.txt +30 -1
index 230b3a0..df08385 100644
@@ -137,4 +137,33 @@ int read_file_with_include(const char *file, config_fn_t fn, void *data)
 Writing Config Files
 --------------------
 
-TODO
+Git gives multiple entry points in the Config API to write config values to
+files namely `git_config_set_in_file` and `git_config_set`, which write to
+a specific config file or to `.git/config` respectively. They both take a
+key/value pair as parameter.
+In the end they both all call `git_config_set_multivar_in_file` which takes
+four parameters:
+
+- the name of the file, as a string, to which key/value pairs will be written.
+
+- the name of key, as a string. This is in canonical "flat" form: the section,
+  subsection, and variable segments will be separated by dots, and the section
+  and variable segments will be all lowercase.
+  E.g., `core.ignorecase`, `diff.SomeType.textconv`.
+
+- the value of the variable, as a string. If value is equal to NULL, it will
+  remove the matching key from the config file.
+
+- the value regex, as a string. It will disregard key/value pairs where value
+  does not match.
+
+- a multi_replace value, as an int. If value is equal to zero, nothing or only
+  one matching key/value is replaced, else all matching key/values (regardless
+  how many) are removed, before the new pair is written.
+
+It returns 0 on success.
+
+Also, there are functions `git_config_rename_section` and
+`git_config_rename_section_in_file` with parameters `old_name` and `new_name`
+for renaming or removing sections in the config files. If NULL is passed
+through `new_name` parameter, the section will be removed from the config file.
Signature · 1 line
1.9.0.GIT
#1 lore raw

minor nit.
From: "Tanay Abhra" <[email protected]>

Quoted 28 lines

Replace TODO introduced in commit 9c3c22 with documentation explaining Git config API functions for writing configuration files.

---
Documentation/technical/api-config.txt | 31
++++++++++++++++++++++++++++++-

1 file changed, 30 insertions(+), 1 deletion(-)
Documentation/technical/api-config.txt +0 -0
index 230b3a0..df08385 100644
@@ -137,4 +137,33 @@ int read_file_with_include(const char *file, 
 config_fn_t fn, void *data)

Writing Config Files
--------------------

Documentation/technical/api-config.txt +1 -1
-TODO
+Git gives multiple entry points in the Config API to write config 

values to
+files namely git_config_set_in_file and git_config_set, which write to
+a specific config file or to .git/config respectively. They both take a

Documentation/technical/api-config.txt +2 -0
+key/value pair as parameter.
+In the end they both all call `git_config_set_multivar_in_file` which 
Quoted 1 line

takes

s/both // 'both all' is a bit tautological.

Quoted 30 lines
Documentation/technical/api-config.txt +3 -0
+four parameters:
+
+- the name of the file, as a string, to which key/value pairs will be 

written.
+
+- the name of key, as a string. This is in canonical "flat" form: the section,
+ subsection, and variable segments will be separated by dots, and the section

Documentation/technical/api-config.txt +4 -0
+  and variable segments will be all lowercase.
+  E.g., `core.ignorecase`, `diff.SomeType.textconv`.
+
+- the value of the variable, as a string. If value is equal to NULL, 

it will

Documentation/technical/api-config.txt +3 -0
+  remove the matching key from the config file.
+
+- the value regex, as a string. It will disregard key/value pairs 

where value

Documentation/technical/api-config.txt +3 -0
+  does not match.
+
+- a multi_replace value, as an int. If value is equal to zero, 

nothing or only
+ one matching key/value is replaced, else all matching key/values (regardless

Documentation/technical/api-config.txt +6 -0
+  how many) are removed, before the new pair is written.
+
+It returns 0 on success.
+
+Also, there are functions `git_config_rename_section` and
+`git_config_rename_section_in_file` with parameters `old_name` and 
Quoted 9 lines

new_name
+for renaming or removing sections in the config files. If NULL is passed
+through new_name parameter, the section will be removed from the config file.

Signature · 3 lines
1.9.0.GIT

--

Philip

#2 lore raw

PATCH v2 1/1 add documentation for writing config files

Replace TODO introduced in commit 9c3c22 with documentation explaining Git config API functions for writing configuration files.

---
Minor nit corrected. Thanks for the review.

 Documentation/technical/api-config.txt | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)
Documentation/technical/api-config.txt +30 -1
index 230b3a0..edd5018 100644
@@ -137,4 +137,33 @@ int read_file_with_include(const char *file, config_fn_t fn, void *data)
 Writing Config Files
 --------------------
 
-TODO
+Git gives multiple entry points in the Config API to write config values to
+files namely `git_config_set_in_file` and `git_config_set`, which write to
+a specific config file or to `.git/config` respectively. They both take a
+key/value pair as parameter.
+In the end they both call `git_config_set_multivar_in_file` which takes four
+parameters:
+
+- the name of the file, as a string, to which key/value pairs will be written.
+
+- the name of key, as a string. This is in canonical "flat" form: the section,
+  subsection, and variable segments will be separated by dots, and the section
+  and variable segments will be all lowercase.
+  E.g., `core.ignorecase`, `diff.SomeType.textconv`.
+
+- the value of the variable, as a string. If value is equal to NULL, it will
+  remove the matching key from the config file.
+
+- the value regex, as a string. It will disregard key/value pairs where value
+  does not match.
+
+- a multi_replace value, as an int. If value is equal to zero, nothing or only
+  one matching key/value is replaced, else all matching key/values (regardless
+  how many) are removed, before the new pair is written.
+
+It returns 0 on success.
+
+Also, there are functions `git_config_rename_section` and
+`git_config_rename_section_in_file` with parameters `old_name` and `new_name`
+for renaming or removing sections in the config files. If NULL is passed
+through `new_name` parameter, the section will be removed from the config file.
Signature · 1 line
1.9.0.GIT