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

Re: [PATCH v9r2 1/2] add `config_set` API for caching config-like files

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Jul 17, 2014, 11:34 UTC
Message-ID
<vpqiomwmd5t.fsf@anie.imag.fr>
In-Reply-To
<53C7AE43.5080402@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
> I am searching for a more elegant solution to this problem.

The "efficient" (not sure about elegant) solution would be to keep one configset per file, and re-parse only the files needed.

I find the solution I posted in the other thread relatively "elegant": invalidate the config cache when things change.

The last test failure seems more tricky. This (dirty) patch fixes the failure:

--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -255,6 +255,8 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
        return run_diff_files(revs, options);
 }
 
+int git_config_raw(config_fn_t fn, void *data);
+
 int cmd_diff(int argc, const char **argv, const char *prefix)
 {
        int i;
@@ -317,7 +319,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 
        if (!no_index)
                gitmodules_config();
-       git_config(git_diff_ui_config, NULL);
+       git_config_raw(git_diff_ui_config, NULL);
 
        init_revisions(&rev, prefix);
 

But this one does not:

diff --git a/builtin/diff.c b/builtin/diff.c
index 0f247d2..2012e81 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -317,7 +317,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 
        if (!no_index)
                gitmodules_config();
+       git_config_clear();
        git_config(git_diff_ui_config, NULL);
+       git_config_clear();
 
        init_revisions(&rev, prefix);
 

So it's not just a matter of invalid cache not cleared, it's a real
difference between git_config() and git_config_raw(). The guilty part is
probably userdiff_config(const char *k, const char *v) in userdiff.c,
that parses the xfuncname config option.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Tanay AbhraNext: Matthieu Moy
Message 24 of 26 in “git config cache & special querying api utilizing the cache”
  1. 0/3 git config cache & special querying api utilizing the cacheTanay Abhra, Jul 15, 2014
  2. 1/2 add `config_set` API for caching config-like filesTanay Abhra, Jul 15, 2014
  3. Junio C HamanoJul 15, 2014
  4. Tanay AbhraJul 15, 2014
  5. 1/2 add `config_set` API for caching config-like filesTanay Abhra, Jul 16, 2014
  6. 2/2 test-config: add tests for the config_set APITanay Abhra, Jul 15, 2014
  7. Junio C HamanoJul 15, 2014
  8. Tanay AbhraJul 15, 2014
  9. Junio C HamanoJul 15, 2014
  10. 2/2 test-config: add tests for the config_set APITanay Abhra, Jul 16, 2014
  11. Matthieu MoyJul 16, 2014
  12. 1/2 add `config_set` API for caching config-like filesTanay Abhra, Jul 16, 2014
  13. Matthieu MoyJul 16, 2014
  14. 1/3 fixup for patch 2: minor style fixMatthieu Moy, Jul 16, 2014
  15. 2/3 fixup for patch 2: actually check the return valueMatthieu Moy, Jul 16, 2014
  16. Tanay AbhraJul 16, 2014
  17. Matthieu MoyJul 16, 2014
  18. 3/3 fixup for patch 1: typoMatthieu Moy, Jul 16, 2014
  19. Tanay AbhraJul 16, 2014
  20. Matthieu MoyJul 16, 2014
  21. 2/2 test-config: add tests for the config_set APITanay Abhra, Jul 16, 2014
  22. Matthieu MoyJul 17, 2014
  23. Tanay AbhraJul 17, 2014
  24. Matthieu MoyJul 17, 2014
  25. Matthieu MoyJul 17, 2014
  26. Junio C HamanoJul 17, 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.