git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Prathamesh <pc44800@gmail.com>
Cc: git <git@vger.kernel.org>,
	Christian Couder <christian.couder@gmail.com>,
	Brandon Williams <bmwill@google.com>,
	Valery Tolstov <me@vtolstov.org>
Subject: Re: GSoC Project | Submodules related work
Date: Wed, 15 Mar 2017 15:13:00 -0700	[thread overview]
Message-ID: <CAGZ79kbV9oJp0ewp8=qz1Yts_RTDPsRW9LYcuNBQr5EFzK+VYA@mail.gmail.com> (raw)
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:
>> 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.

>> 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 */

>> 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

      reply	other threads:[~2017-03-15 22:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-15  9:33 GSoC Project | Submodules related work Prathamesh Chavan
2017-03-15 18:12 ` Stefan Beller
2017-03-15 21:28   ` Prathamesh
2017-03-15 22:13     ` Stefan Beller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGZ79kbV9oJp0ewp8=qz1Yts_RTDPsRW9LYcuNBQr5EFzK+VYA@mail.gmail.com' \
    --to=sbeller@google.com \
    --cc=bmwill@google.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=me@vtolstov.org \
    --cc=pc44800@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).