Browse Source

Merge branch 'ag/userdiff-go-funcname'

"git diff" and friends learned funcname patterns for Go language
source files.

* ag/userdiff-go-funcname:
  userdiff: add built-in pattern for golang
maint
Junio C Hamano 7 years ago
parent
commit
077cde91d2
  1. 2
      Documentation/gitattributes.txt
  2. 1
      t/t4018-diff-funcname.sh
  3. 8
      t/t4018/golang-complex-function
  4. 4
      t/t4018/golang-func
  5. 4
      t/t4018/golang-interface
  6. 5
      t/t4018/golang-long-func
  7. 4
      t/t4018/golang-struct
  8. 9
      userdiff.c

2
Documentation/gitattributes.txt

@ -714,6 +714,8 @@ patterns are available: @@ -714,6 +714,8 @@ patterns are available:

- `fountain` suitable for Fountain documents.

- `golang` suitable for source code in the Go language.

- `html` suitable for HTML/XHTML documents.

- `java` suitable for source code in the Java language.

1
t/t4018-diff-funcname.sh

@ -33,6 +33,7 @@ diffpatterns=" @@ -33,6 +33,7 @@ diffpatterns="
css
fortran
fountain
golang
html
java
matlab

8
t/t4018/golang-complex-function

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
type Test struct {
a Type
}

func (t *Test) RIGHT(a Type) (Type, error) {
t.a = a
return ChangeMe, nil
}

4
t/t4018/golang-func

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
func RIGHT() {
a := 5
b := ChangeMe
}

4
t/t4018/golang-interface

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
type RIGHT interface {
a() Type
b() ChangeMe
}

5
t/t4018/golang-long-func

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
func RIGHT(aVeryVeryVeryLongVariableName AVeryVeryVeryLongType,
anotherLongVariableName AnotherLongType) {
a := 5
b := ChangeMe
}

4
t/t4018/golang-struct

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
type RIGHT struct {
a Type
b ChangeMe
}

9
userdiff.c

@ -38,6 +38,15 @@ IPATTERN("fortran", @@ -38,6 +38,15 @@ IPATTERN("fortran",
"|//|\\*\\*|::|[/<>=]="),
IPATTERN("fountain", "^((\\.[^.]|(int|ext|est|int\\.?/ext|i/e)[. ]).*)$",
"[^ \t-]+"),
PATTERNS("golang",
/* Functions */
"^[ \t]*(func[ \t]*.*(\\{[ \t]*)?)\n"
/* Structs and interfaces */
"^[ \t]*(type[ \t].*(struct|interface)[ \t]*(\\{[ \t]*)?)",
/* -- */
"[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.eE]+i?|0[xX]?[0-9a-fA-F]+i?"
"|[-+*/<>%&^|=!:]=|--|\\+\\+|<<=?|>>=?|&\\^=?|&&|\\|\\||<-|\\.{3}"),
PATTERNS("html", "^[ \t]*(<[Hh][1-6]([ \t].*)?>.*)$",
"[^<>= \t]+"),
PATTERNS("java",

Loading…
Cancel
Save