Re: [BUG] git clean -d is too greedy

2017-11-02 Thread Hermanni Suominen
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


[BUG] git clean -d is too greedy

2017-11-02 Thread Hermanni Suominen

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


Re: BUG - git clean

2013-10-12 Thread Di Xu
> mkdir test
> cd test
> git init .
> mkdir ba
> mkdir ba/ca
> 
> # So far so good.
> # Should clean directory "ba/ca"
> git clean -dn -- ba/ca
> 
> # Should clean "ba/ca" and ignore non-existent "j"
> # Instead, it wants to delete "ba" totally.
> git clean -dn -- ba/ca j

actually, my git will also do it wrong when 'j' exist, do
these after your script:

$ git clean -dn ba/ca j
Would remove ba/
$ mkdir j
$ git clean -dn ba/ca j
Would remove ba/ #here missing 'ca'
Would remove j/

I think it's the problem of directory path manipulation.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


BUG - git clean

2013-10-11 Thread jones.noamle
Passing to git clean wrong (non-existent) paths together with valid 
ones, causes it to delete stuff that it shouldn't.

Am I right?
Script to reproduce:

mkdir test
cd test
git init .
mkdir ba
mkdir ba/ca

# So far so good.
# Should clean directory "ba/ca"
git clean -dn -- ba/ca

# Should clean "ba/ca" and ignore non-existent "j"
# Instead, it wants to delete "ba" totally.
git clean -dn -- ba/ca j

git --version

-
Output:

+ mkdir test
+ cd test
+ git init .
Initialized empty Git repository in /home/notroot/test/.git/
+ mkdir ba
+ mkdir ba/ca
+ git clean -dn -- ba/ca
Would remove ba/ca/
+ git clean -dn -- ba/ca j
Would remove ba/
+ git --version
git version 1.7.9.5

-

Thanks!
Noam
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [BUG] git clean does not remove certain directories

2012-11-20 Thread Soren Brinkmann
> Hi,
>
> this use case may be a little awkward but this is the behavior I see:
>
> I have a repository which has a couple of untracked directories which can also
> include git repositories. No submodules, though.
> I used 'git clean -xdf' on the top level of this repo to remove everything
> untracked in it - including the git repositories in sub-directories.
>
> Since using git 1.8.0 the clean operation seems to be 'broken', as output
> indicates all those questionable sub directories are removed - just as in 
> prior
> git versions - but in fact they remain untouched and are _not_ removed.
>
> I attached a shell script creating a hierarchy to reproduce the issue.
> Executing the script creates the git repo 'repo.git' with a couple of tracked
> and untracked dirs/files and two more git repositories within the first one.
>
> If you cd into repo.git and execute 'git clean -xdf' I see the following 
> output:
>   Removing repo2.git/
>   Removing untracked_dir/
>
> But the directories remain intact when using git 1.8.0.
> With git 1.6.3.2 it works as I expected and removes the
> directories. I'm pretty
> sure the 1.7.x versions did the same, but it's no longer
> installed here.

As additional data point: With git 1.7.9.5 the 'untracked_dir' is deleted, while
'repo2.git' is kept. Output is the same as always, indicating both were deleted.

So, three different git versions gain three different results...

Soren


This email and any attachments are intended for the sole use of the named 
recipient(s) and contain(s) confidential information that may be proprietary, 
privileged or copyrighted under applicable law. If you are not the intended 
recipient, do not read, copy, or forward this email message or any attachments. 
Delete this email message and any attachments immediately.


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[BUG] git clean does not remove certain directories

2012-11-20 Thread Soren Brinkmann
Hi,

this use case may be a little awkward but this is the behavior I see:

I have a repository which has a couple of untracked directories which can also
include git repositories. No submodules, though.
I used 'git clean -xdf' on the top level of this repo to remove everything
untracked in it - including the git repositories in sub-directories.

Since using git 1.8.0 the clean operation seems to be 'broken', as output
indicates all those questionable sub directories are removed - just as in prior
git versions - but in fact they remain untouched and are _not_ removed.

I attached a shell script creating a hierarchy to reproduce the issue.
Executing the script creates the git repo 'repo.git' with a couple of tracked
and untracked dirs/files and two more git repositories within the first one.

If you cd into repo.git and execute 'git clean -xdf' I see the following output:
Removing repo2.git/
Removing untracked_dir/

But the directories remain intact when using git 1.8.0.
With git 1.6.3.2 it works as I expected and removes the directories. I'm pretty
sure the 1.7.x versions did the same, but it's no longer installed here.

I can see that this behavior may partially be intended, but the tool output
should match its actions. So, either the directories should be removed, or the
output should state, that they are not removed for what reason whatsoever, IMHO

Thanks,
Soren

#!/bin/sh
mkdir repo.git
cd repo.git
git init
echo foo > tracked_file1
git add tracked_file1
mkdir tracked_dir
echo foo > tracked_dir/tracked_file2
git add tracked_dir/tracked_file2
git commit -m "Adding tracked files"
mkdir repo2.git
echo foo > repo2.git/tracked_file3
mkdir -p untracked_dir/repo3.git
echo foo > untracked_dir/repo3.git/tracked_file4
cd repo2.git
git init
git add tracked_file3
git commit -m "Adding file to subrepo1"
cd ../untracked_dir/repo3.git
git init
git add tracked_file4
git commit -m "Adding file to subrepo2"
cd ../..