libgit2/libgit2 — pull request #535 by arrbee (2012-01-17 01:18:01+00:00)
Title: Fix handling of relative paths for attrs

Per issue #533, the handling of relative paths in attribute and ignore files was not right. Fixed this by pre-joining the relative path of the attribute/ignore file onto the match string when a full path match is required.

Unfortunately, fixing this required a bit more code than I would have liked because I had to juggle things around so that the fnmatch parser would have sufficient information to prepend the relative path when it was needed. This basically boils down to three changes:

* allocate `git_attr_file` objects before calling `git_attr__from_file`, etc. (which changes the method signature of those functions)
* store the relative path to the file in the `git_file_attr` (which I really should have been doing in the first place), and
* prepend the directory of the relative path to the match pattern when parsing an `fnmatch`

I also added bunch of other tests that I wrote.

An alternate approach to fixing this would have been to compare files against patterns using the relative path to the source of the rule (which can be done with a simple prefix search), but given the existing implementation, this approach seemed easier to implement and functionally equivalent.