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

Re: GSoC Project | Submodules related work

From
Stefan Beller <sbeller@google.com>
Date
Mar 15, 2017, 22:13 UTC
Message-ID
<CAGZ79kbV9oJp0ewp8=qz1Yts_RTDPsRW9LYcuNBQr5EFzK+VYA@mail.gmail.com>
In-Reply-To
<CAME+mvX6EH+R6xRiCCYAg_gaguv4yeFD1T765+q7F8YMppeOhw@mail.gmail.com>
On Wed, Mar 15, 2017 at 2:28 PM, Prathamesh <pc44800@gmail.com> wrote:
Show 5 quoted lines
>> What do you mean by catch here?
>
> By catching commands, I meant that we identify that the user has entered
> the command in an unpopulated or uninitialized submodule and respond
> to the user accordingly.
Well in that sense, we do not do that, yet. I see what you mean.
Show 11 quoted lines
>> However to detect if there is a submodule, we can to check two
>> things: if there is a .gitmodules entry and if there is a gitlink entry
>> recorded in the tree. Depending on the command we'd want to
>> do one before the other. e.g. git-add most likely doesn't need to
>> load .gitmodules, but may have the objects already loaded.
>> So checking if a given path is a submodule is cheap compared
>> to loading the .gitmodules file, so we'd probably want to do the
>> cheap thing first.
>
> Adding to this, we may use here this functions is_submodule_populated()
> and is_submodule_initialized() from submodule.c
Not quite, IMO.

is_submodule_initialized checks for the existence of submodule.<name>.URL in .git/config; but it sounds as if we want to check for the existence of submodule.<any name>.path in .gitmodules instead. So we'd end up using only

    module = submodule_from_path(null_sha1, path);
only from that function.

is_submodule_populated checks if there is a .git file/directory at the given path, which at this point we would know is not the case, already?

We'd roughly need to module_list_compute(... prefix = "", pathspec = prefix, ...), i.e.

    struct cache_entry *ce = lookup_cache_entry_for(prefix);
    if (ce && S_ISGITLINK(ce->ce_mode))
        /* this is an uninitialized submodule */
    else
        /* this is just a normal prefix */
Show 7 quoted lines
>> I think even when the .gitmodules file is missing, we want to have
>> some sort of warning here, as it is a confusing state to run git
>> from an uninitialized gitlink'd repository. The user may assume they
>> run the command in the gitlink'd repo, so it may be better to bail out.
>
> Can you please give an example of such situation ? I would like to
> reproduce it and think further.
I think you can create such a situation via
    git init tmp
    cd tmp
    git init gitlink
    git -C gitlink commit --allow-empty -m "initial commit"
->  git add gitlink
    git commit -m "add 'gitlink' as a gitlink"
    rm -rf gitlink
    mkdir gitlink
    git -C gitlink status

Note that we used "git add" instead of "git submodule add". git-add doesn't care about submodule, i.e. doesn't create a .gitmodules entry for you (unlike "git submodule add").

Also note that the "rm -rf && mkdir" is just a placeholder to produce this state. An alternative ending after the commit could have been

    cd ..
    git clone tmp tmp2
    cd tmp2
    git -C gitlink status
> (As even in the case where the superproject is initialized using gitlink,
> .gitmodules is in the same folder as that of the .git file containing
> GIT_DIR path)
I do not understand this?
> Also if it possible, I would like to
> work on a smaller task related to my project first, as it will help me
> understand about the project more, and which also will help me write
> my proposal for the project.

Heh, that is the beauty of open source, you don't have to ask permission. ;) But I guess this is meant as a question, on what this smaller project could be? Well as this proposal is heavy on path computation, I'd look for pathspec related leftovers at https://git-blame.blogspot.com/p/leftover-bits.html

Thanks, Stefan

Previous: Prathamesh
Message 4 of 4 in “GSoC Project | Submodules related work”
  1. Prathamesh ChavanMar 15, 2017
  2. Stefan BellerMar 15, 2017
  3. PrathameshMar 15, 2017
  4. Stefan BellerMar 15, 2017

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.