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

Re: [RFC 02/10] submodule: fix getting custom gitmodule file in fetch command

From
Antonio Ospite <ao2@ao2.it>
Date
Apr 16, 2018, 20:46 UTC
Message-ID
<20180416224645.f5d2f49702ad647cabd8c98d@ao2.it>
In-Reply-To
<CAGZ79kZMXjEAHewkwBR4R91c46+jEL5s9rX2D+2gXo2X6dcozA@mail.gmail.com>

On Mon, 16 Apr 2018 12:23:59 -0700 Stefan Beller <sbeller@google.com> wrote:

Show 8 quoted lines
> On Mon, Apr 16, 2018 at 9:18 AM, Antonio Ospite <ao2@ao2.it> wrote:
> 
> >
> > Is there an API to just load one config setting?
> 
> Do you mean to
> 
>   git -c key=value foo-command --options ...
I meant, instead of:
  git_config(git_fetch_config, NULL);

which updates a series of config settings, something which loads _in_the_code_ just the one value for 'core.submodulesFile' previously set either via "git -c" or "git config".

It turns out what I was looking for is git_config_get_string_const().
The new patch will be simply this:
diff --git a/config.c b/config.c
index 6ffb1d501..1ef9801d3 100644
--- a/config.c
+++ b/config.c
@@ -2087,6 +2087,7 @@ int git_config_get_pathname(const char *key, const char **dest)
  */
 void config_from_gitmodules(config_fn_t fn, void *data)
 {
+       git_config_get_string_const("core.submodulesFile", &submodules_file);
        if (the_repository->worktree) {
                char *file = repo_worktree_path(the_repository, submodules_file);
                git_config_from_file(fn, file, data);


Which covers my use case without changing the fetch behavior for previous
users, as "core.submodulesFile" is a new option.

Thanks,
   Antonio
-- 
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
Previous: Stefan BellerNext: Antonio Ospite
Message 7 of 28 in “[RFC 00/10] Make .the gitmodules file path configurable”
  1. Antonio OspiteApr 12, 2018
  2. 03/10 submodule: use the 'submodules_file' variable in output messagesAntonio Ospite, Apr 12, 2018
  3. 02/10 submodule: fix getting custom gitmodule file in fetch commandAntonio Ospite, Apr 12, 2018
  4. Stefan BellerApr 12, 2018
  5. Antonio OspiteApr 16, 2018
  6. Stefan BellerApr 16, 2018
  7. Antonio OspiteApr 16, 2018
  8. 01/10 submodule: add 'core.submodulesFile' to override the '.gitmodules' pathAntonio Ospite, Apr 12, 2018
  9. Stefan BellerApr 12, 2018
  10. Antonio OspiteApr 16, 2018
  11. Stefan BellerApr 16, 2018
  12. Antonio OspiteApr 18, 2018
  13. Stefan BellerApr 18, 2018
  14. 04/10 submodule: document 'core.submodulesFile' and fix references to '.gitmodules'Antonio Ospite, Apr 12, 2018
  15. 05/10 submodule: adjust references to '.gitmodules' in commentsAntonio Ospite, Apr 12, 2018
  16. 06/10 completion: add 'core.submodulesfile' to the git-completion.bash fileAntonio Ospite, Apr 12, 2018
  17. Stefan BellerApr 12, 2018
  18. Antonio OspiteApr 16, 2018
  19. Stefan BellerApr 16, 2018
  20. Antonio OspiteApr 13, 2018
  21. 07/10 FIXME: wrap-for-bin.sh: set 'core.submodulesFile' for each git invocationAntonio Ospite, Apr 13, 2018
  22. 09/10 FIXME: submodule: pass custom gitmodules file to 'test-tool submodule-config'Antonio Ospite, Apr 13, 2018
  23. 10/10 FIXME: add a hacky script to test the changes with a patched test suiteAntonio Ospite, Apr 13, 2018
  24. 08/10 FIXME: submodule: fix t1300-repo-config.sh to take into account the new configAntonio Ospite, Apr 13, 2018
  25. Stefan BellerApr 13, 2018
  26. Antonio OspiteApr 16, 2018
  27. Jonathan NiederApr 23, 2018
  28. Antonio OspiteApr 30, 2018

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.