git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Izbyshev <izbyshev@ispras.ru>
To: git@vger.kernel.org
Subject: [BUG] git checkout --recurse-submodules on initialized but not cloned submodule fails badly
Date: Mon, 09 Aug 2021 01:21:38 +0300	[thread overview]
Message-ID: <85faefc0b1e23ee942b11087089ccc4f@ispras.ru> (raw)

Hi,

On a fresh clone of a repo with submodules, running `git checkout 
--recurse-submodules` after `git submodule init` but without `git 
submodule update` fails (as expected), but leaves the working tree in a 
bad state:

git init repo
git -C repo commit --allow-empty -m "initial"
git -C repo submodule add "$PWD"/repo
git -C repo commit -m "add sm"
git clone repo repo-clone
git -C repo-clone submodule init repo
git -C repo-clone checkout --recurse-submodules repo
fatal: not a git repository: ../.git/modules/repo
fatal: could not reset submodule index

(Tested on git 2.17.1 and v2.33.0-rc1)

`git checkout` creates a gitlink in the submodule directory even though 
its target is not a valid git dir (it contains only `config`). In the 
resulting state, many git commands (like `status` and even `submodule 
deinit`) fail, so while trying to checkout a submodule before `submodule 
update` isn't supposed to work, I think it still shouldn't leave the 
repo in such a state.

It seems that related issues have already been reported, though those 
that I've found[1,2,3] describe more complex scenarios, while mine is 
very basic.

Hope it helps,
Alexey

[1] 
https://public-inbox.org/git/20200501005432.h62dnpkx7feb7rto@glandium.org/
[2] 
https://public-inbox.org/git/dab7128d-5ea7-5d7c-1ae1-1d71be316326@gmail.com/
[3] 
https://public-inbox.org/git/CABVQXt5E-R22G62W-tQieA7XiZKZiOA8Hp2xewYhwwOS8wFh0Q@mail.gmail.com/


                 reply	other threads:[~2021-08-08 22:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=85faefc0b1e23ee942b11087089ccc4f@ispras.ru \
    --to=izbyshev@ispras.ru \
    --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).