git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git clean -X skips a directory containing only ignored files
@ 2012-01-30 23:36 Paul Berry
  2012-01-31 14:47 ` Michael Schubert
  2012-01-31 16:20 ` Andrew Wong
  0 siblings, 2 replies; 5+ messages in thread
From: Paul Berry @ 2012-01-30 23:36 UTC (permalink / raw)
  To: git

I am trying to use "git clean -X" to remove object files (which
are gitignored) from my source tree, but it appears to miss
object files that are in a subdirectory without any git-tracked
files:

$ git init test
Initialized empty Git repository in /home/pberry/tmp/test/.git/
$ cd test
$ mkdir foo
$ touch foo/bar.o
$ echo '*.o' > .gitignore
$ git add .gitignore
$ git commit -mgitignore
[master (root-commit) 6b5ffcb] gitignore
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
$ git status
# On branch master
nothing to commit (working directory clean)
$ git clean -d -X -f
$ ls foo
bar.o

It seems to me that bar.o should have been removed, because
according to the git-clean docs, -X means "Remove only files
ignored by git", and bar.o is definitely being ignored by git.


It looks like a very similar bug was reported back in 2010, but
not fixed:
http://git.661346.n2.nabble.com/BUG-git-clean-X-behaviour-when-gitignore-has-sub-directory-entries-td5575307.html.
I've confirmed that the workaround mentioned by Jonathan Nieder
in that thread fixes my problem too (removing "dir.flags |=
DIR_SHOW_OTHER_DIRECTORIES;" from builtin/clean.c).  However I'm
guessing from Jonathan's comments that it would be better to fix
this bug elsewhere (somewhere in dir.c perhaps).

Is anyone interested in following up on this old bug?
Alternatively, if someone could give me some guidance as to the
best way to go about fixing this bug, I would be glad to submit a
patch.

Thanks,

Paul

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-02-01 12:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-30 23:36 [BUG] git clean -X skips a directory containing only ignored files Paul Berry
2012-01-31 14:47 ` Michael Schubert
2012-01-31 17:39   ` Paul Berry
2012-01-31 16:20 ` Andrew Wong
2012-02-01 12:18   ` Michael Schubert

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