As an extension of this post: Can git ignore a specific line?, I am trying to ignore multiple lines in the same file type.
Is there a way to either;
- set multiple filters to the same
.gitattributesfilter for the same file or file types? (like below) OR
*.rs filter=filterA
*.rs filter=filterB
// to something like
*.rs filter=filterA + filterB
- add multiple rules to the same filter in
.git/config? (like below)
[filter "filterA"]
clean = sed "/abc/d"
[filter "filterB"]
clean = sed "/def/d"
// to something like
[filter "filterC"]
clean = sed "/abc/d"
clean = sed "/def/d"
The above causes the last filter in .gitattributes to overwrite the changes made from the first filter. I have also attempted something like clean = sed "/abc*def/d", but this did not work.
If you want to ignore entire lines my advice is to use
grep -vinstead ofsed //d. The answers at the linked question usesedbecause they hide only parts of lines, a task for whichsedis exactly suitable.So 1st lets rewrite your two simple filters:
Please be warned that if your placeholders
abcanddefcontain regular expression metacharacters you need to escape them using backslash. Like\*—grepinterprets this as a literal asterisk while*is a metacharacter. Seeman grep.Now to the more complex filter: combine the two expressions into one complex regular expression:
\|separates branches in regular expressions in basic (default)grepsyntax. In case of extended RE the syntax is