3 ms·
How can this be uses with PHP?
by chiefalchemist 3y ago
How can this be uses with PHP?
- mschuster91 3y agoAccording to `man gitattributes` [1] a `*.php diff=php` should be enough. [1] https://git-scm.com/docs/gitattributes https://git-scm.com/docs/gitattributes
- OJFord 3y agoIt's just a regex to match the line you want to see the history of. Function would be a common case, but it's completely arbitrary. For example, `git log -L:members:Cargo.toml` will show the history of constituent rust projects in a Cargo workspace.
- staunton 3y agoIt's a regex? Is it even guaranteed to work then? I would think you have to parse non-regular languages to always find the end of a function in a some languages? Indeed, it does not always work correctly for Julia, as an arbitrary example I tried. Seems like it goes by indentation? Still nice though and worked out of the box!
- OJFord 3y agoIt's just to match the (starting) line. I assume the +n context uses the same method diffs do anywhere else, however that works (and sometimes doesn't).
- simonw 3y agoThere's a comment about that here: https://github.com/git/git/blob/bc5204569f7db44d22477485afd52ea410d83743/userdiff.c#L36-L39 https://github.com/git/git/blob/bc5204569f7db44d22477485afd5... When writing or updating patterns, assume that the contents these patterns are applied to are syntactically correct. The patterns can be simple without implementing all syntactical corner cases, as long as they are sufficiently permissive.
- staunton 3y agoWow, that file must be paradise for regex nerds, assuming there are any such...
- tessierashpool 3y agothere are, I am, and it's not (sorry). some languages have the ability to comment regexes, and that would be very useful here.
- staunton 3y agoIt has lots of comments inside the regexes. How would this better comment support look like?
- sundarurfriend 3y agoThese are not technically "comments inside the regexes", that would be something like the "Delete (most) C comments." regex here: https://perldoc.perl.org/perlre#/x-and-/xx https://perldoc.perl.org/perlre#/x-and-/xx Here, instead, they've used string juxtaposition cleverly to write comments between parts of the regex/string. It effectively serves the same purpose though.
- sundarurfriend 3y agothere are, I am, and it is. (Except for the proliferation of backslashes due to C not having "raw" strings.)