* Unexpected "clean -Xd" behavior
@ 2012-01-16 2:00 Pete Harlan
2012-01-19 0:29 ` Jonathan Nieder
0 siblings, 1 reply; 5+ messages in thread
From: Pete Harlan @ 2012-01-16 2:00 UTC (permalink / raw)
To: Git Mailing List
Hi,
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
# touch foo/x.c
# git clean -Xdn # <--- DITTO WITH UNTRACKED IN foo
# git add foo/x.c
# git clean -Xdn # <--- WITH TRACKED IN foo, WILL REMOVE a/
Would remove foo/a/
#
Is this intentional? It's interfering with my using "git clean" to
remove built objects, which happen to be in a dedicated temporary
subdirectory.
Thanks,
--Pete Harlan
pgit@pcharlan.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Unexpected "clean -Xd" behavior
2012-01-16 2:00 Unexpected "clean -Xd" behavior Pete Harlan
@ 2012-01-19 0:29 ` Jonathan Nieder
2012-01-19 7:31 ` Nguyen Thai Ngoc Duy
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Nieder @ 2012-01-19 0:29 UTC (permalink / raw)
To: Pete Harlan
Cc: Git Mailing List, Nguyễn Thái Ngọc Duy,
Shawn Bohrer
(+cc: Duy, Shawn)
Hi,
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
> # touch foo/x.c
> # git clean -Xdn # <--- DITTO WITH UNTRACKED IN foo
> # git add foo/x.c
> # git clean -Xdn # <--- WITH TRACKED IN foo, WILL REMOVE a/
> Would remove foo/a/
> #
>
> Is this intentional? It's interfering with my using "git clean" to
> remove built objects, which happen to be in a dedicated temporary
> subdirectory.
Sounds like a bug. Duy, Shawn, any hints?
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Unexpected "clean -Xd" behavior
2012-01-19 0:29 ` Jonathan Nieder
@ 2012-01-19 7:31 ` Nguyen Thai Ngoc Duy
2012-01-19 10:03 ` Jonathan Nieder
2012-01-19 22:12 ` pgit
0 siblings, 2 replies; 5+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2012-01-19 7:31 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Pete Harlan, Git Mailing List, Shawn Bohrer
2012/1/19 Jonathan Nieder <jrnieder@gmail.com>:
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Unexpected "clean -Xd" behavior
2012-01-19 7:31 ` Nguyen Thai Ngoc Duy
@ 2012-01-19 10:03 ` Jonathan Nieder
2012-01-19 22:12 ` pgit
1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Nieder @ 2012-01-19 10:03 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: Pete Harlan, Git Mailing List, Shawn Bohrer
Nguyen Thai Ngoc Duy wrote:
> -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.
Makes sense.
I guess the internal logic is that "git clean -fdX" cleans up files
that "git clean -fd" would miss, and this is not such a file ("git
clean -fd" removes it). But as Pete mentioned, in this edge case the
behavior renders "git clean -fdX" less effective than expected at its
primary task as poor man's "make clean".
I'd be happy to see a patch that moves to a different set of semantics
or an addition to t/t7300-clean.sh and BUGS section in
Documentation/git-clean.txt explaining the current limitations, if
someone wants to work on that.
Thanks, both.
Jonathan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Unexpected "clean -Xd" behavior
2012-01-19 7:31 ` Nguyen Thai Ngoc Duy
2012-01-19 10:03 ` Jonathan Nieder
@ 2012-01-19 22:12 ` pgit
1 sibling, 0 replies; 5+ messages in thread
From: pgit @ 2012-01-19 22:12 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy
Cc: Jonathan Nieder, Pete Harlan, Git Mailing List, Shawn Bohrer
Thank you very much for looking at this.
2012/1/19 "Nguyen Thai Ngoc Duy" <pclouds@gmail.com>:
> 2012/1/19 Jonathan Nieder <jrnieder@gmail.com>:
>> 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.
But the presence of a tracked file in foo makes it not cut short there, so
the logic seems a bit off. (If we're interested in removing ignored files
only, then the ignored files (not a tracked file) should trigger us
looking into foo. I don't know Git internals but I'm guessing it's not
quite that simple.)
> 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.
It can (and does) leave foo behind (because it's not ignored), but it
would conform better to the -X documentation if the ignored files were
removed.
BTW the above commit doesn't affect the behavior in this example.
If a fix isn't desirable then as Jonathan said updating the documentation
makes sense. (And those of us using it as a poor man's "make clean" can
just fix our Makefiles instead...)
Thanks,
--Pete
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-01-19 22:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-16 2:00 Unexpected "clean -Xd" behavior Pete Harlan
2012-01-19 0:29 ` Jonathan Nieder
2012-01-19 7:31 ` Nguyen Thai Ngoc Duy
2012-01-19 10:03 ` Jonathan Nieder
2012-01-19 22:12 ` pgit
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).