From: Junio C Hamano Date: Fri, 21 Jun 2019 18:24:08 +0000 (-0700) Subject: Merge branch 'ml/userdiff-rust' X-Git-Tag: v2.23.0-rc0~105 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/a41dad4330c8291893b5c5b013457499855ec9b5?ds=inline;hp=-c Merge branch 'ml/userdiff-rust' The pattern "git diff/grep" use to extract funcname and words boundary for Rust has been added. * ml/userdiff-rust: userdiff: two simplifications of patterns for rust userdiff: add built-in pattern for rust --- a41dad4330c8291893b5c5b013457499855ec9b5 diff --combined Documentation/gitattributes.txt index e387cc6dda,07da08fb27..2796dfc83b --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@@ -819,7 -819,7 +819,7 @@@ patterns are available - `java` suitable for source code in the Java language. -- `matlab` suitable for source code in the MATLAB language. +- `matlab` suitable for source code in the MATLAB and Octave languages. - `objc` suitable for source code in the Objective-C language. @@@ -833,6 -833,8 +833,8 @@@ - `ruby` suitable for source code in the Ruby language. + - `rust` suitable for source code in the Rust language. + - `tex` suitable for source code for LaTeX documents. diff --combined userdiff.c index 04270fb4d7,2bcf105caf..e74a6d4022 --- a/userdiff.c +++ b/userdiff.c @@@ -58,12 -58,7 +58,12 @@@ PATTERNS("java" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), PATTERNS("matlab", - "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$", + /* + * Octave pattern is mostly the same as matlab, except that '%%%' and + * '##' can also be used to begin code sections, in addition to '%%' + * that is understood by both. + */ + "^[[:space:]]*((classdef|function)[[:space:]].*)$|^(%%%?|##)[[:space:]].*$", "[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"), PATTERNS("objc", /* Negate C statements that can look like functions */ @@@ -135,6 -130,12 +135,12 @@@ PATTERNS("ruby", "^[ \t]*((class|module "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), + PATTERNS("rust", + "^[\t ]*((pub(\\([^\\)]+\\))?[\t ]+)?((async|const|unsafe|extern([\t ]+\"[^\"]+\"))[\t ]+)?(struct|enum|union|mod|trait|fn|impl)[< \t]+[^;]*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + "|[0-9][0-9_a-fA-Fiosuxz]*(\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?" + "|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"), PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", "[={}\"]|[^={}\" \t]+"), PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",