Thread (1 message) 1 message, 1 author, 2016-06-16

Re: [PATCHv4] pathspec: allow escaped query values

From: Junio C Hamano <hidden>
Date: 2016-06-16 02:19:44

Stefan Beller [off-list ref] writes:
In our own .gitattributes file we have attributes such as:

    *.[ch] whitespace=indent,trail,space

When querying for attributes we want to be able to ask for the exact
value, i.e.

    git ls-files :(attr:whitespace=indent,trail,space)

should work, but the commas are used in the attr magic to introduce
the next attr, such that this query currently fails with

fatal: Invalid pathspec magic 'trail' in ':(attr:whitespace=indent,trail,space)'

This change allows escaping characters by a backslash, such that the query

    git ls-files :(attr:whitespace=indent\,trail\,space)

will match all path that have the value "indent,trail,space" for the
whitespace attribute. To accomplish this, we need to modify two places.
First `eat_long_magic` needs to not stop early upon seeing a comma or
closing paren that is escaped. As a second step we need to remove any
escaping from the attr value.

Helped-by: Junio C Hamano [off-list ref]
Signed-off-by: Stefan Beller <redacted>
---

differences to v3 (http://thread.gmane.org/gmane.comp.version-control.git/296259):
* lose the *src check before invalid_value_char
* remove a stray new line in parse_pathspec_attr_match

Thanks,
Stefan
Excellent.  Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help