git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC/PATCH v2 2/2] config: Add new query functions to the api docs

From
Tanay Abhra <tanayabh@gmail.com>
Date
Jun 2, 2014, 14:47 UTC
Message-ID
<1401720460-6525-3-git-send-email-tanayabh@gmail.com>
In-Reply-To
<1401720460-6525-1-git-send-email-tanayabh@gmail.com>

Add explanations for `git_config_get_string_multi` and `git_config_get_string` which utilize the config hash table for querying in a non-callback manner for a specific variable.

Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
---
 Documentation/technical/api-config.txt | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff --git a/Documentation/technical/api-config.txt b/Documentation/technical/api-config.txt
index 230b3a0..8f1a37e 100644
--- a/Documentation/technical/api-config.txt
+++ b/Documentation/technical/api-config.txt
@@ -77,6 +77,24 @@ To read a specific file in git-config format, use
 `git_config_from_file`. This takes the same callback and data parameters
 as `git_config`.
 
+Querying For Specific Variables
+-------------------------------
+
+For programs wanting to query for specific variables in a non-callback
+manner, the config API provides two functions `git_config_get_string`
+and `git_config_get_string_multi`. They both take a single parameter,
+
+- a key string in canonical flat form for which the corresponding values
+  will be retrieved and returned.
+
+They both read values from an internal cache generated previously from
+reading the config files. `git_config_get_string` returns the value with
+the highest priority(i.e. value in the repo config will be preferred over
+value in user wide config for the same variable).
+
+`git_config_get_string_multi` returns a `string_list` containing all the
+values for that particular key, sorted in order of increasing priority.
+
 Value Parsing Helpers
 ---------------------
 
-- 
1.9.0.GIT
Previous: Eric SunshineNext: Matthieu Moy
Message 6 of 7 in “Git config cache & special querying api utilizing the cache”
  1. 0/2 Git config cache & special querying api utilizing the cacheTanay Abhra, Jun 2, 2014
  2. 1/2 config: Add hashtable for config parsing & retrievalTanay Abhra, Jun 2, 2014
  3. Torsten BögershausenJun 2, 2014
  4. Jeff KingJun 3, 2014
  5. Eric SunshineJun 9, 2014
  6. 2/2 config: Add new query functions to the api docsTanay Abhra, Jun 2, 2014
  7. Matthieu MoyJun 3, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.