Merge branch 'ml/userdiff-rust'
authorJunio C Hamano <gitster@pobox.com>
Fri, 21 Jun 2019 18:24:08 +0000 (11:24 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Jun 2019 18:24:08 +0000 (11:24 -0700)
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

1  2 
Documentation/gitattributes.txt
userdiff.c
index e387cc6dda128542d819b661ca92f2ae3316ce58,07da08fb275ad346cb637052f94699ddadd27642..2796dfc83bb15174c2657f90ded09b6d6af80e41
@@@ -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.
  
  
  - `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 04270fb4d7e598522cc2ebfc898d537496f44939,2bcf105caf75f72584d6dc65046a41ade20a4263..e74a6d402255b0eaf1022863ba30305930d29b6f
@@@ -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}\\{.*)$",