git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* `*' gitignores and nested ignores
@ 2011-03-24 10:10 Eli Barzilay
  2011-03-25  8:18 ` Johannes Sixt
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Barzilay @ 2011-03-24 10:10 UTC (permalink / raw)
  To: git

According to the man page, a .gitignore file that is deeper has higher
precedence, and a `!' line overrides lower precedence ignores.  I
tried that, and it works in cases like the last "vmlinux*" example.

But it doesn't work if the lower precedence directory has a "*"
pattern.  If the last example from the man page is changed to:

               $ cat .gitignore
               *
               $ ls arch/foo/kernel/vm*
               arch/foo/kernel/vmlinux.lds.S
               $ echo ´!/vmlinux*´ >arch/foo/kernel/.gitignore

then -- IIUC -- the second ignore should work the same, but it
doesn't.  This also happens if the first pattern is "/*".

Is this a bug?


BTW, my use case is to track random stuff in a directory that has lots
of junk.  I wanted to do this by having a toplevel "/*" ignore and add
files explicitly when I want to.  But there are some directories that
should be tracked, and I was trying to achieve this effect by adding a
"!/*" pattern in them.  Is there a more convenient (or saner) way of
doing this?

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

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

* Re: `*' gitignores and nested ignores
  2011-03-24 10:10 `*' gitignores and nested ignores Eli Barzilay
@ 2011-03-25  8:18 ` Johannes Sixt
  2011-03-25  9:37   ` Eli Barzilay
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Sixt @ 2011-03-25  8:18 UTC (permalink / raw)
  To: Eli Barzilay; +Cc: git

Am 3/24/2011 11:10, schrieb Eli Barzilay:
> According to the man page, a .gitignore file that is deeper has higher
> precedence, and a `!' line overrides lower precedence ignores.  I
> tried that, and it works in cases like the last "vmlinux*" example.
> 
> But it doesn't work if the lower precedence directory has a "*"
> pattern.  If the last example from the man page is changed to:
> 
>                $ cat .gitignore
>                *
>                $ ls arch/foo/kernel/vm*
>                arch/foo/kernel/vmlinux.lds.S
>                $ echo ´!/vmlinux*´ >arch/foo/kernel/.gitignore
> 
> then -- IIUC -- the second ignore should work the same, but it
> doesn't.  This also happens if the first pattern is "/*".
> 
> Is this a bug?

This has been discussed before, and IMNSHO, this is not a bug:

http://thread.gmane.org/gmane.comp.version-control.git/157190

-- Hannes

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

* Re: `*' gitignores and nested ignores
  2011-03-25  8:18 ` Johannes Sixt
@ 2011-03-25  9:37   ` Eli Barzilay
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Barzilay @ 2011-03-25  9:37 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git

An hour ago, Johannes Sixt wrote:
> Am 3/24/2011 11:10, schrieb Eli Barzilay:
> > According to the man page, a .gitignore file that is deeper has
> > higher precedence, and a `!' line overrides lower precedence
> > ignores.  I tried that, and it works in cases like the last
> > "vmlinux*" example.
> > 
> > But it doesn't work if the lower precedence directory has a "*"
> > pattern.  [...]
> > 
> > Is this a bug?
> 
> This has been discussed before, and IMNSHO, this is not a bug:
> 
> http://thread.gmane.org/gmane.comp.version-control.git/157190

To reply to what you wrote there:

> You should update your expectations to match what you got.

That kind of an answer is a thick hint that something is not
documented right.  As things stand, I don't see anything in the man
page that describes the actual algorithm that is used.  I also found a
similar weirdness now -- the man page says

  within one level of precedence, the last matching pattern decides
  the outcome

but this is not true for nested files in this case:

  *
  !foo

So some description of what's going on is needed.  Perhaps it's
exactly what Seth's suggested patch describes.


In any case, it seems possible to do something that works more as
expected.  As suggested in that thread -- scanning only directories
that have committed files would not make things slow, since the files
need to be checked anyway.  This is not even hard to describe in a man
page.  It seems like some arbitrariness that buys performance, but its
less so than the current situation.

There's also the option of scanning only .gitignore files that are
checked in, but that will probably be too confusing when the files are
created and/or modified.

Yet another alternative is to say that an ignored .gitignore file is
ignored, and making this:

  /*
  !.gitignore

an idiom for doing the slow thing in case you really want it.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

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

end of thread, other threads:[~2011-03-25  9:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-24 10:10 `*' gitignores and nested ignores Eli Barzilay
2011-03-25  8:18 ` Johannes Sixt
2011-03-25  9:37   ` Eli Barzilay

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