[Feature Request] Negated non-wildcard patterns in excluded directories in `.gitignore`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Git Community,

I have the somewhat unusual use-case and use negated patterns somewhat
regularly. If I have a path `foo/bar/baz` which I want to track with
git, but don't want any other files in `foo`. I would have to write the
following in the `.gitignore`:

	foo/*
	!foo/bar
	foo/bar/*
	!foo/bar/baz

Instead of the simpler:

	foo
	!foo/bar/baz

In `gitignore(5)` you mention:

> It is not possible to re-include a file if a parent directory of that
> file is excluded. Git doesn’t list excluded directories for
> performance reasons, so any patterns on contained files have no
> effect, no matter where they are defined.

This is (I think) due to patterns like `!*.c`.
So I propose changing it so exact-matching pattern parts like `foo` or
`bar` to always work. This could be done by expanding it to the form
mentioned above.

This change wouldn't affect performance I would argue, since writing
`!foo/bar/baz` is pretty unambiguous in what the user intended.
Depending on the implementation it may even improve performance,
since we would only require listing of `foo/bar/baz` and not all of it's
parents (though I am simply guessing the implementation for
`<something>/*` here).

Joschua




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux