Subject: Re: git ls-files -o under .git/ prints all repository files

From: Yasushi SHOJI <[email-masked]>
Date: Fri, 19 Jan 2007 16:41:56 +0900

At Thu, 18 Jan 2007 22:47:47 -0800,
Junio C Hamano wrote:
> 
> Yasushi SHOJI <[email-masked]> writes:
> 
> > ls-files -o prints all files under .git if you are in the .git
> > directory.  this is pretty dangerous since we now have git clean to
> > delete files marked others.
> >
> > sure in UNIX env., you can easily shoot yourself in the foot. but it'd
> > might be nice to help newbies.
> 
> It's amusing to see that people can find obscure ways to shoot
> themselves in the foot.
> 
> Amusing problems deserve an equally amusing solution.

Unfortunately, the amusing ;-) solution doesn't prevent them all.

$ cd .git/objects
$ git ls-fiels -o
0f/902e4635d4d7b8e532b485eeeb6399d0910710
bc/2d2dcb34e8313627d45ad6ef38beddf560501d
ce/013625030ba8dba906f756967f9e9ca394464a
$ git clean -d -x
Removing 0f/
Removing bc/
Removing ce/
Removing info/
Removing pack/

I presume that if the cwd is the direct decedent of the current
GIT_DIR, ls-files should print error saying "you are not in the
working dir".

or, just ignore '.git/*' all the time.

$ git ls-files -o
HEAD
config
 :
$ git ls-files -o --exclude='.git/*'
$ 

What do you think?
-- 
         yashi