gitlabhq/grit — pull request #40 by GeorgeDewar (2014-03-18 22:38:06+00:00)
Title: Advanced search syntax

Datacom requires the ability in GitLab to be able to perform advanced searches, for example a search for files containing "def index" and "email", but not containing "cats".

To achieve this I have modified grit to add an advanced_grep method. This supports search queries such as ```email "def index" -cats```.

The intention is that gitlab_git and then ultimately gitlabhq can take advantage of this new method, which would supersede the original grep method. The only reason it's a separate method is to ensure that the behaviour of callers to this library are unaffected until they deliberately use the new method. However, of course we are after the community's input regarding the optimal structure for this change.

There are two areas of incompatibility with the existing grep method:

1. This advanced_grep method requires the search input NOT to be escaped by the caller, but rather it does the shell escaping itself. This is because quote marks are now important syntactical user input.
2. The default behaviour would no longer be an exact string match, but rather all terms appearing anywhere in a given file. An exact string match search would require quotation marks to be used.

We hope that this work is useful and that the new behaviour is desirable for most or all GitLab users.