proposal for improving gitignore syntax

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

 



I'm facing a common problem with gitignore, see
https://stackoverflow.com/questions/61381438/how-to-gitignore-extension-less-files-without-breaking-a-global-gitignore
It doesn't seem to be possible to gitignore extension-less files (eg
posix binaries) without negative side effects, eg:
```
*
!/**/
!*.*
```
It's more complicated than it should and also doesn't work well, as it
will render a global gitignore useless.

This is just one of the problems with gitignore.

Such a common task should have an easy solution, and I'm wondering
whether gitignore can be improved to make this easy/possible.

Here's a concrete proposal. If 1st line contains `#
gitignore-syntax:v2`, it uses a new syntax, otherwise it uses existing
syntax, to ensure backward compatibility.
With the new syntax, strings enclosed inside parenthesis, eg (\w+)
denote regular expressions matching a single path component, with ^$
implied for each path component to match the entire component.

Regular expressions are forbidden to span across path components.
(\w+\.(md|txt))
Examples:
```
# gitignore-syntax:v2
# the line above enables the new syntax for this file

# this gitignores all extension-less files anywhere (:
([^.]+)
# this un-ignores files called README
!README

# this will gitignore for example /abc/foo.md
/*/((foo|bar)\.md)

# this will gitignore directories (bc trailing /) like ab/cd/foo/123/
**/(\w+)/(\d+)/
```

old tools like grep support regex so I'm assuming git could too, but
if for some reason that can't work (why?), some simplified version
could be supported to at least enable common cases without a full
blown regex engine, for example */([^.]+)



[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