git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git checkout --recurse-submodules on initialized but not cloned submodule fails badly
@ 2021-08-08 22:21 Alexey Izbyshev
  0 siblings, 0 replies; only message in thread
From: Alexey Izbyshev @ 2021-08-08 22:21 UTC (permalink / raw)
  To: git

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/


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-08 22:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-08 22:21 [BUG] git checkout --recurse-submodules on initialized but not cloned submodule fails badly Alexey Izbyshev

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