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

Re: [PATCH v5 1/4] implement submodule config API for lookup of .gitmodules values

From
Phil Hord <phil.hord@gmail.com>
Date
Jul 8, 2015, 20:52 UTC
Message-ID
<CABURp0pyYcKvmbEeDSYqm15DtXvH7g_UXASR3utGco+=D95bOA@mail.gmail.com>
In-Reply-To
<ef740bdea9af35564c75efd2a6daae65f3108df5.1434400625.git.hvoigt@hvoigt.net>
On Mon, Jun 15, 2015 at 5:06 PM, Heiko Voigt <hvoigt@hvoigt.net> wrote:
Show 55 quoted lines
> In a superproject some commands need to interact with submodules. They
> need to query values from the .gitmodules file either from the worktree
> of from certain revisions. At the moment this is quite hard since a
> caller would need to read the .gitmodules file from the history and then
> parse the values. We want to provide an API for this so we have one
> place to get values from .gitmodules from any revision (including the
> worktree).
>
> The API is realized as a cache which allows us to lazily read
> .gitmodules configurations by commit into a runtime cache which can then
> be used to easily lookup values from it. Currently only the values for
> path or name are stored but it can be extended for any value needed.
>
> It is expected that .gitmodules files do not change often between
> commits. Thats why we lookup the .gitmodules sha1 from a commit and then
> either lookup an already parsed configuration or parse and cache an
> unknown one for each sha1. The cache is lazily build on demand for each
> requested commit.
>
> This cache can be used for all purposes which need knowledge about
> submodule configurations. Example use cases are:
>
>  * Recursive submodule checkout needs to lookup a submodule name from
>    its path when a submodule first appears. This needs be done before
>    this configuration exists in the worktree.
>
>  * The implementation of submodule support for 'git archive' needs to
>    lookup the submodule name to generate the archive when given a
>    revision that is not checked out.
>
>  * 'git fetch' when given the --recurse-submodules=on-demand option (or
>    configuration) needs to lookup submodule names by path from the
>    database rather than reading from the worktree. For new submodule it
>    needs to lookup the name from its path to allow cloning new
>    submodules into the .git folder so they can be checked out without
>    any network interaction when the user does a checkout of that
>    revision.
>
> Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
> ---
>  .gitignore                                       |   1 +
>  Documentation/technical/api-submodule-config.txt |  46 +++
>  Makefile                                         |   2 +
>  submodule-config.c                               | 445 +++++++++++++++++++++++
>  submodule-config.h                               |  27 ++
>  submodule.c                                      |   1 +
>  submodule.h                                      |   1 +
>  t/t7411-submodule-config.sh                      |  85 +++++
>  test-submodule-config.c                          |  66 ++++
>  9 files changed, 674 insertions(+)
>  create mode 100644 Documentation/technical/api-submodule-config.txt
>  create mode 100644 submodule-config.c
>  create mode 100644 submodule-config.h
>  create mode 100755 t/t7411-submodule-config.sh
>  create mode 100644 test-submodule-config.c

Instead of test-submodule-config.c to test this new module, it could be useful to implement these as extensions to rev-parse:

    git rev-parse --submodule-name [<ref>:]<path>
    git rev-parse --submodule-path [<ref>:]<name>
    git rev-parse --submodule-url [<ref>:]<name>
    git rev-parse --submodule-ignore [<ref>:]<name>
    git rev-parse --submodule-recurse [<ref>:]<name>
Has this already been considered and rejected for some reason?
Previous: Heiko VoigtNext: Heiko Voigt
Message 4 of 16 in “submodule config lookup API”
  1. 0/4 submodule config lookup APIHeiko Voigt, Jun 15, 2015
  2. 1/4 implement submodule config API for lookup of .gitmodules valuesHeiko Voigt, Jun 15, 2015
  3. Heiko VoigtJun 16, 2015
  4. Phil HordJul 8, 2015
  5. Heiko VoigtJul 9, 2015
  6. Jeff KingJul 9, 2015
  7. Jens LehmannJul 9, 2015
  8. Junio C HamanoJul 9, 2015
  9. Heiko VoigtJul 13, 2015
  10. Junio C HamanoJul 13, 2015
  11. 2/4 extract functions for submodule config set and lookupHeiko Voigt, Jun 15, 2015
  12. 3/4 use new config API for worktree configurations of submodulesHeiko Voigt, Jun 15, 2015
  13. 4/4 do not die on error of parsing fetchrecursesubmodules optionHeiko Voigt, Jun 15, 2015
  14. Junio C HamanoJun 15, 2015
  15. Stefan BellerAug 10, 2015
  16. Junio C HamanoAug 12, 2015

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.