git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git clean -d is too greedy
@ 2017-11-02 17:13 Hermanni Suominen
  2017-11-02 18:04 ` Hermanni Suominen
  0 siblings, 1 reply; 2+ messages in thread
From: Hermanni Suominen @ 2017-11-02 17:13 UTC (permalink / raw)
  To: git

Hi all,

Since commit 6b1db4310 it is possible to make git clean -d to remove 
nested git repositories if

   1) .gitignore exists in nested repo (either tracked or untracked)
   2) .gitignore is excluded

Regarding to 2) it doesn't matter if .gitignore is excluded from 
(another) .gitignore or from command-line (but I assume they populate 
same ignore list so that's just stating the obvious).

To demonstrate this I can run the following commands:

# git init -q foo && cd foo
# git init -q bar && cd bar
# touch .gitignore bar
# git add bar && git commit -qm asd && cd ..
# git clean -e .gitignore -dn
Would remove bar/bar

Pre 6b1db4310, and if .gitignore isn't exclued, nested repo is correctly 
skipped:

# git clean -dn
Would skip repository bar/ 


It probably isn't very common use case to exclude .gitignore but 
nevertheless this has been broken for a while, and to make things worse 
it can wipe out lots of uncommitted changes.

-- 
Hermanni

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

* Re: [BUG] git clean -d is too greedy
  2017-11-02 17:13 [BUG] git clean -d is too greedy Hermanni Suominen
@ 2017-11-02 18:04 ` Hermanni Suominen
  0 siblings, 0 replies; 2+ messages in thread
From: Hermanni Suominen @ 2017-11-02 18:04 UTC (permalink / raw)
  To: git

I was a bit trigger happy posting this, after digging a bit more this is 
a way more serious than I originally thought.

>    1) .gitignore exists in nested repo (either tracked or untracked)
>    2) .gitignore is excluded

This can be any file, including those commonly excluded such as *~.

Demonstrating this in a way that looks a lot more likely use case which 
will potentially wipe out lots of uncommitted work:

# git init -q foo && cd foo
# git init -q bar && cd bar
# touch bar bar~
# git add bar && git commit -qm asd && cd ..
# git clean -e \*~ -dn
Would remove bar/bar

If there were more tracked files in nested repo they'd be removed as 
well as long as there is at least one excluded file in nested repo.

-- 
Hermanni

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

end of thread, other threads:[~2017-11-02 18:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-02 17:13 [BUG] git clean -d is too greedy Hermanni Suominen
2017-11-02 18:04 ` Hermanni Suominen

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