Closed
Description
This has been around for a while but #76356 will exacerbate the issue.
Steps to replicate:
$ head -n 3 .git/hooks/pre-commit
#!/usr/bin/env bash
cd "$(git rev-parse --show-toplevel)"
./x.py test tidy --bless
$ git worktree add ~/rustc-worktree
Preparing worktree (new branch 'rustc-worktree')
Updating files: 100% (25306/25306), done.
HEAD is now at 8932bb68755 tmp
$ cd ~/rustc-worktree
$ git commit
# spends a long time cloning submodules
extracting /home/joshua/rustc-worktree/build/cache/2020-07-12/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.gz
error: failed to read `/home/joshua/rustc-worktree/src/tools/miri/cargo-miri/Cargo.toml`
Caused by:
No such file or directory (os error 2)
failed to run: /home/joshua/rustc-worktree/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /home/joshua/rustc-worktree/src/bootstrap/Cargo.toml
Build completed unsuccessfully in 0:04:52
$ git status
Refresh index: 100% (25306/25306), done.
On branch rustc-worktree
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)
modified: library/backtrace (modified content, untracked content)
modified: library/stdarch (modified content, untracked content)
modified: src/doc/book (modified content, untracked content)
modified: src/doc/edition-guide (modified content, untracked content)
modified: src/doc/embedded-book (modified content, untracked content)
modified: src/doc/nomicon (modified content, untracked content)
modified: src/doc/reference (modified content, untracked content)
modified: src/doc/rust-by-example (modified content, untracked content)
modified: src/doc/rustc-dev-guide (modified content, untracked content)
modified: src/llvm-project (modified content, untracked content)
modified: src/tools/cargo (modified content, untracked content)
modified: src/tools/miri (modified content, untracked content)
modified: src/tools/rls (modified content, untracked content)
modified: src/tools/rust-analyzer (modified content, untracked content)
modified: src/tools/rust-installer (modified content, untracked content)
modified: src/tools/rustfmt (modified content, untracked content)
no changes added to commit (use "git add" and/or "git commit -a")