git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philippe Blain <levraiphilippeblain@gmail.com>
To: Carlos Gonzalez <carlos.gonzalez@codeplay.com>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Bug report: checkout --recurse-submodules failing
Date: Fri, 13 Jan 2023 08:58:48 -0500	[thread overview]
Message-ID: <c587b501-494a-bb9c-4789-dc78f4ad655b@gmail.com> (raw)
In-Reply-To: <CWXP265MB3688191D75A56F27A0C4DDB69CFD9@CWXP265MB3688.GBRP265.PROD.OUTLOOK.COM>

Hi Carlos,

Le 2023-01-12 à 07:17, Carlos Gonzalez a écrit :
> What did you do before the bug happened? 
> 
> Checking out a custom commit or tag using `--recurse-submodules`, where the specific commit contained a submodule
> not included in the main branch. The checkout command failed. (Detailed steps below)
> 
> What did you expect to happen? 
> 
> The repository should be checked out to the specified commit and submodules updated, and the one missing in the main 
> branch, cloned.

It's a reasonable expectation, but the current 'checkout' code does not
know how to clone missing submodules.

> 
> What happened instead? 
> 
> git checkout --recurse-submodules submodule
> fatal: not a git repository: ../.git/modules/sycl-blas
> fatal: could not reset submodule index
> 
> What's different between what you expected and what actually happened?
> 
> This only fails when the repository was cloned with --recursive flag.
> 
> Anything else you want to add:
> 
> I wrote these simple steps to reproduce:
> 
> mkdir repo1 && cd repo1
> git init
> git submodule add --name sycl-blas  https://github.com/codeplaysoftware/sycl-blas.git
> git commit -m "Adding submodule"
> git tag -a submodule -m submodule
> git submodule deinit sycl-blas
> truncate -s 0 .gitmodules
> rm -rf sycl-blas/
> git add .gitmodules
> git rm sycl-blas
> git commit -m "Remove submodule"
> cd ../
> 
> # When repository is cloned without `--recursive`, checkout works
> git clone repo1 cloned-repo1
> cd cloned-repo1
> git checkout --recurse-submodules submodule # ok
> cd ../
> # When repository is cloned with `--recursive`, checkout fails
> git clone --recursive repo1 cloned-repo2
> cd cloned-repo2
> git checkout --recurse-submodules submodule
> fatal: not a git repository: ../.git/modules/sycl-blas
> fatal: could not reset submodule index

Thanks for a complete reproducer. This has been reported before,
see the threads linked at [1].

I was working on that issue last month, so that at least the checkout fails
in a clean way, but have not gone back to it yet.

In the meantime, as you've discovered, a workaround is to clone without
'--recurse-submodules', then manually run 'git submodule update --init --recursive'
after switching branches.

Cheers,

Philippe.

[1] https://github.com/gitgitgadget/git/issues/752

      reply	other threads:[~2023-01-13 14:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 12:17 Bug report: checkout --recurse-submodules failing Carlos Gonzalez
2023-01-13 13:58 ` 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

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

  git send-email \
    --in-reply-to=c587b501-494a-bb9c-4789-dc78f4ad655b@gmail.com \
    --to=levraiphilippeblain@gmail.com \
    --cc=carlos.gonzalez@codeplay.com \
    --cc=git@vger.kernel.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.
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 NNTP newsgroup(s).