summaryrefslogtreecommitdiff
path: root/tests/attr/macro.c
Commit message (Collapse)AuthorAgeFilesLines
* attr: Update definition of binary macroLaurence McGlashan2019-12-121-4/+6
|
* attr_file: ignore macros defined in subdirectoriesPatrick Steinhardt2019-07-121-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, we are unconditionally applying all macros found in a gitatttributes file. But quoting gitattributes(5): Custom macro attributes can be defined only in top-level gitattributes files ($GIT_DIR/info/attributes, the .gitattributes file at the top level of the working tree, or the global or system-wide gitattributes files), not in .gitattributes files in working tree subdirectories. The built-in macro attribute "binary" is equivalent to: So gitattribute files in subdirectories of the working tree may explicitly _not_ contain macro definitions, but we do not currently enforce this limitation. This patch introduces a new parameter to the gitattributes parser that tells whether macros are allowed in the current file or not. If set to `false`, we will still parse macros, but silently ignore them instead of adding them to the list of defined macros. Update all callers to correctly determine whether the to-be-parsed file may contain macros or not. Most importantly, when walking up the directory hierarchy, we will only set it to `true` once it reaches the root directory of the repo itself. Add a test that verifies that we are indeed not applying macros from subdirectories. Previous to these changes, the test would've failed.
* tests: attr: verify that in-memory macros are respectedPatrick Steinhardt2019-07-121-0/+55
| | | | | Add some tests to ensure that the `git_attr_add_macro` function works as expected.
* tests: attr: implement tests to verify attribute rewriting behaviourPatrick Steinhardt2019-07-121-0/+33
| | | | | Implement some tests that verify that we are correctly updating gitattributes when rewriting or unlinking the corresponding files.
* tests: attr: extract macro tests into their own suitePatrick Steinhardt2019-07-121-0/+91
As macros are a specific functionality in the gitattributes code, it makes sense to extract them into their own test suite, too. This makes finding macro-related tests easier.