Re: Unexpected "clean -Xd" behavior
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Jan 19, 2012, 07:31 UTC
- Message-ID
- <CACsJy8AE+rwmOVUZez5GRXRHJsTy+W8ekzr59NTd7_C+gB0Byw@mail.gmail.com>
- In-Reply-To
- <20120119002904.GA14107@burratino>
2012/1/19 Jonathan Nieder <jrnieder@gmail.com>:
Show 21 quoted lines
> Pete Harlan wrote: > >> When a directory contains nothing but an ignored subdirectory, that >> subdirectory does not get removed by "git clean -Xdf". >> >> For example, in a new directory: >> >> # git init >> Initialized empty Git repository in /tmp/foo/.git/ >> # echo a/ >.gitignore >> # git add .gitignore >> # git commit -m "Initial commit" >> [master (root-commit) c3af24c] Initial commit >> 1 files changed, 1 insertions(+), 0 deletions(-) >> create mode 100644 .gitignore >> # mkdir -p foo/a >> # touch foo/a/junk.o >> # git status >> # On branch master >> nothing to commit (working directory clean) >> # git clean -Xdn # <--- DOES NOT MENTION foo/a
-X is to remove ignored files _only_ (DIR_SHOW_IGNORED flag). And "foo" is not ignored according to .gitignore, so it cuts short there and never gets to "foo/a". -x works. May be intentional, may be not (we hit a corner case). I don't know. Commit message b991625 might help:
dir.c: Omit non-excluded directories with dir->show_ignored
This makes "git-ls-files --others --directory --ignored" behave
as documented and consequently also fixes "git-clean -d -X".
Previously, git-clean would remove non-excluded directories
even when using the -X option.-- Duy