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

Re: [PATCH v3 3/5] config: correctly read worktree configs in submodules

From
Matheus Tavares Bernardino <matheus.bernardino@usp.br>
Date
Jun 1, 2020, 04:38 UTC
Message-ID
<CAHd-oW7==zM5goS6ZrHNYADDgdkYdXLqZgKxCL2UwFAacvVsNg@mail.gmail.com>
In-Reply-To
<CABPp-BGVaMM9Naiu3HeO6n2aOxsHwiuc813MF-hFWezSFa9CsA@mail.gmail.com>
On Sat, May 30, 2020 at 11:49 AM Elijah Newren <newren@gmail.com> wrote:
Show 19 quoted lines
>
> On Wed, May 27, 2020 at 6:13 PM Matheus Tavares
> <matheus.bernardino@usp.br> wrote:
> >
> > One of the steps in do_git_config_sequence() is to load the
> > worktree-specific config file. Although the function receives a git_dir
> > string, it relies on git_pathdup(), which uses the_repository->git_dir,
> > to make the path to the file. Furthermore, it also checks that
> > extensions.worktreeConfig is set through the
> > repository_format_worktree_config variable, which refers to
> > the_repository only. Thus, when a submodule has worktree settings, a
> > command executed in the superproject that recurses into the submodule
> > won't find the said settings.
> >
> > Such a scenario might not be needed now, but it will be in the following
>
> It's not needed?  Are there not other config values that affect grep's
> behavior, such as smudge filters of the submodule that might be
> important if doing a 'git grep --recurse-submodules $REVISION'?

Hmm, I haven't used smudge filters before, but it seems to me that `git grep $REVISION` does not honor them.

> Also, is there a similar issue here for .gitattributes?  (e.g. if the
> submodule declares certain files to be binary?)

Declaring files as binary in the submodule works fine. But I noticed that textconv filter specifications in the submodule's config are currently ignored. To be honest, I wasn't aware of this issue before.

> I don't actually know if these are issues but I'm just surprised to
> hear that this would be the first case that would need to look at
> submodule-specific configuration.

Hmm, not to submodule-specific configuration but to worktree-specific configuration of a submodule, right? I.e. a config.worktree file from within a submodule. Reconsidering this now, we could indeed have a diff.<driver>.textconv or core.quotePath settings specified in the worktree scope of a submodule. And we should honor them when recursing in grep. I guess I thought the "most natural" place for these settings, in a submodule, would be in the standard .git/config file (as opposed to the sparse-checkout ones, which are normally at config.worktree). That's probably why I wrote "Such scenario might not be needed now". But we should indeed support reading diff.<driver>.textconv from config.worktree as well (although grep currently ignores this setting in submodules, both in the local and worktree scopes). So the said sentence doesn't make much sense, indeed. I will remove it. Thanks!

Show 22 quoted lines
> > diff --git a/t/helper/test-config.c b/t/helper/test-config.c
> > index 1c8e965840..284f83a921 100644
> > --- a/t/helper/test-config.c
> > +++ b/t/helper/test-config.c
> > @@ -84,33 +91,63 @@ int cmd__config(int argc, const char **argv)
> >         int i, val;
> >         const char *v;
> >         const struct string_list *strptr;
> > -       struct config_set cs;
> > +       struct config_set cs = { .hash_initialized = 0 };
> >         enum test_config_exit_code ret = TC_SUCCESS;
> > +       struct repository *repo = the_repository;
> > +       const char *subrepo_path = NULL;
> > +
> > +       argc--; /* skip over "config" */
>
> This line alone is responsible for a fairly big set of changes
> throughout this file, just decrementing indices everywhere.  It might
> be nice for review purposes if this and the other changes it caused
> were pulled out into a separate step, so we can more easily
> concentrate on the primary additions and changes you are making to
> this file.
OK, will do.
Previous: Elijah NewrenNext: Matheus Tavares
Message 5 of 31 in “grep: honor sparse checkout and add option to ignore it”
  1. 0/5 grep: honor sparse checkout and add option to ignore itMatheus Tavares, May 28, 2020
  2. 1/5 doc: grep: unify info on configuration variablesMatheus Tavares, May 28, 2020
  3. 3/5 config: correctly read worktree configs in submodulesMatheus Tavares, May 28, 2020
  4. Elijah NewrenMay 30, 2020
  5. Matheus Tavares BernardinoJun 1, 2020
  6. 2/5 t/helper/test-config: return exit codes consistentlyMatheus Tavares, May 28, 2020
  7. Elijah NewrenMay 30, 2020
  8. Matheus Tavares BernardinoJun 1, 2020
  9. 4/5 grep: honor sparse checkout patternsMatheus Tavares, May 28, 2020
  10. Elijah NewrenMay 30, 2020
  11. Matheus Tavares BernardinoJun 1, 2020
  12. Elijah NewrenJun 3, 2020
  13. Matheus Tavares BernardinoJun 10, 2020
  14. 5/5 config: add setting to ignore sparsity patterns in some cmdsMatheus Tavares, May 28, 2020
  15. Elijah NewrenMay 30, 2020
  16. Matheus Tavares BernardinoJun 1, 2020
  17. Elijah NewrenJun 3, 2020
  18. Matheus Tavares BernardinoJun 10, 2020
  19. Elijah NewrenJun 11, 2020
  20. 0/6 grep: honor sparse checkout and add option to ignore itMatheus Tavares, Jun 12, 2020
  21. 2/6 t/helper/test-config: return exit codes consistentlyMatheus Tavares, Jun 12, 2020
  22. 1/6 doc: grep: unify info on configuration variablesMatheus Tavares, Jun 12, 2020
  23. 3/6 t/helper/test-config: facilitate addition of new cli optionsMatheus Tavares, Jun 12, 2020
  24. 4/6 config: correctly read worktree configs in submodulesMatheus Tavares, Jun 12, 2020
  25. Elijah NewrenJun 16, 2020
  26. Matheus Tavares BernardinoJun 21, 2020
  27. Jonathan NiederSep 1, 2020
  28. Matheus Tavares BernardinoSep 1, 2020
  29. 5/6 grep: honor sparse checkout patternsMatheus Tavares, Jun 12, 2020
  30. 6/6 config: add setting to ignore sparsity patterns in some cmdsMatheus Tavares, Jun 12, 2020
  31. Elijah NewrenJun 16, 2020

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.