Re: [PATCH] t7300-clean: demonstrate deleting nested repo with an ignored file breakage
- From
SZEDER Gábor <szeder.dev@gmail.com>
- Date
- Aug 25, 2019, 20:34 UTC
- Message-ID
- <20190825203452.GO20404@szeder.dev>
- In-Reply-To
- <20190825185918.3909-1-szeder.dev@gmail.com>
On Sun, Aug 25, 2019 at 08:59:18PM +0200, SZEDER Gábor wrote:
Show 19 quoted lines
> 'git clean -fd' must not delete an untracked directory if it belongs > to a different Git repository or worktree. Unfortunately, if a > '.gitignore' rule in the outer repository happens to match a file in a > nested repository or worktree, then something goes awry and 'git clean > -fd' does delete the content of the nested repository's worktree > except that ignored file, potentially leading to data loss. > > Add a test to 't7300-clean.sh' to demonstrate this breakage. > > This issue is a regression introduced in 6b1db43109 (clean: teach > clean -d to preserve ignored paths, 2017-05-23). > > Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> > --- > > BEWARE: Our toplevel '.gitignore' currently contains the '*.manifest' > rule [1], which ignores the file 'compat/win32/git.manifest' [2], so > if you use nested worktrees in your git repo, then a 'git clean -fd' > will delete them.
OK, singling out that manifest file is just nonsense, any object file, etc... in the nested worktree/repo can trigger the same issue just as well.
(It just so happened that when I ran 'git clean -fd' I had a nested worktree where I haven't build anything yet, and besides the .git file only that 'git.manifest' file survived in the nested worktree, and then I got misled by it.)