Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve UX around missing submodules and '--recurse-submodules' for clone and checkout #752

Open
phil-blain opened this issue Oct 12, 2020 · 1 comment

Comments

@phil-blain
Copy link

When a user clones a repo with --recurse-submodules, clone writes the pathspec . to the config submodule.active.

If this repo at some point in its history had a submodule, but this submodule was then removed, then checking out an older commit where the submodule is still present fails if the checkout uses --recurse-submodules.

Reproducer:

git init checkout-removed-submodule &&
cd checkout-removed-submodule/ &&
echo "Hello, world" >foo &&
git add foo && git commit -m "Initial commit" &&
git init ../submodule &&
cd ../submodule/ &&
echo "Foo bar" >foobar.txt &&
git add foobar.txt && git commit -m "Foo bar baz" &&
cd ../checkout-removed-submodule/ &&
git submodule add ../submodule/ foobar &&
git commit -m "Add foobar submodule" &&
git rm foobar/ &&
git commit -m "Remove foobar submodule" &&
cd ../ &&
git clone --recurse-submodules checkout-removed-submodule cloned-repo  &&
cd cloned-repo && 
git co --recurse-submodules HEAD~
  fatal: not a git repository: ../.git/modules/foobar
  fatal: could not reset submodule index

Cf:
https://lore.kernel.org/git/[email protected]/T/#u
https://lore.kernel.org/git/CAE5ih78zCR0ZdHAjoxguUb3Y6KFkZcoxJjhS7rkbtZpr+d1n=g@mail.gmail.com/

A lot of improvements could be made here.

@phil-blain phil-blain changed the title Improve UX around removed submodules and '--recurse-submodules' for clone and checkout Improve UX around missing submodules and '--recurse-submodules' for clone and checkout Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant