git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Luke Diamand <luke@diamand.org>
Cc: Git mailing list <git@vger.kernel.org>,
	Jens Lehmann <Jens.Lehmann@web.de>,
	kaartic.sivaraam@gmail.com
Subject: Re: How to checkout a revision that contains a deleted submodule?
Date: Mon, 21 Sep 2020 18:46:13 -0400	[thread overview]
Message-ID: <0B191753-C1AD-499C-B8B2-122F49CF6F14@gmail.com> (raw)
In-Reply-To: <CAE5ih79puooMA1v8jOkqKaO9xPmYqtkT9kXHq2L6YODJJ8oGEQ@mail.gmail.com>

Hi Luke, 

> Le 20 sept. 2020 à 05:44, Luke Diamand <luke@diamand.org> a écrit :
> 
> On Sat, 19 Sep 2020 at 10:03, Luke Diamand <luke@diamand.org> wrote:
>> 
>> Maybe this is a FAQ, but I couldn't figure it out!
>> 
>> I have a repo which has a couple of submodules.
>> 
>> At some point in the past I deleted one of those submodules:
>> 
>>    git rm sub2
>>    git add -u
>>    git commit -m 'Deleting sub2'
>>    git push origin
>>    ...
>>    ... more commits and pushes...
>> 
>> Now I go and clone the head revision. This gives me a clone which has
>> nothing present in .git/modules/sub2.
>>    login on some other machine
>>    git clone git@my.repo:thing
>>    cd thing
>>    ls .git/modules
>>    <sub2 not present>
>> 
>> So when I go and checkout an old revision where sub2 is still around I get:
>>    git checkout oldrevision
>>    fatal: not a git repository: sub2/../.git/modules/sub2
>> 
>> What am I doing wrong?
>> What set of commands do I need to use to ensure that this will always
>> do the right thing?
>> 
>> Thanks
>> Luke
> 
> Replying to myself, adding Jens who added the section below.
> 
> This is a known bug:
> 
> https://git-scm.com/docs/git-rm
> 
>> BUGS
>> ----
>> Each time a superproject update removes a populated submodule
>> (e.g. when switching between commits before and after the removal) a
>> stale submodule checkout will remain in the old location. Removing the
>> old directory is only safe when it uses a gitfile, as otherwise the
>> history of the submodule will be deleted too. This step will be
>> obsolete when recursive submodule update has been implemented.
> 
> I'm wondering what "recursive submodule update" is. If I do:
> 
>    git submodule update --checkout --force --remote --recursive
> 
> then those stale repos are still left lying around. I guess that's a
> different kind of recursive?
> 

I think Jens was referring to this project :
https://github.com/jlehmann/git-submod-enhancements/wiki/Recursive-submodule-checkout

of which some parts were implemented over the years,
a lot of them by Stefan Beller. 

In fact this part of the doc is stale and should be removed since `git checkout` now 
understands `--recurse-submodules` and will
automatically transform "old-style" subdmodules (i.e. with an embeded .git repository)
into "new style" submodules (with a gitfile) (see gitsubmodules(7), at [1], for more info)
when switching to a commit where the submodule is not present.

Cheers,
Philippe.

      parent reply	other threads:[~2020-09-21 22:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-19  9:03 How to checkout a revision that contains a deleted submodule? Luke Diamand
2020-09-20  9:44 ` Luke Diamand
2020-09-20 18:02   ` Kaartic Sivaraam
2020-09-20 20:52     ` Luke Diamand
2020-09-21 23:14     ` Philippe Blain
2020-09-22  4:32       ` Luke Diamand
2020-09-21 22:46   ` Philippe Blain [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=0B191753-C1AD-499C-B8B2-122F49CF6F14@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=Jens.Lehmann@web.de \
    --cc=git@vger.kernel.org \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=luke@diamand.org \
    /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).