Skip to content

Commit e90d065

Browse files
adrianjohnsongitster
authored andcommitted
Add userdiff patterns for Ada
Add Ada xfuncname and wordRegex patterns to the list of builtin patterns. Signed-off-by: Adrian Johnson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 889d358 commit e90d065

File tree

7 files changed

+66
-1
lines changed

7 files changed

+66
-1
lines changed

Documentation/gitattributes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ configuration file (you still need to enable this with the
511511
attribute mechanism, via `.gitattributes`). The following built in
512512
patterns are available:
513513

514+
- `ada` suitable for source code in the Ada language.
515+
514516
- `bibtex` suitable for files with BibTeX coded references.
515517

516518
- `cpp` suitable for source code in the C and C++ languages.

t/t4018-diff-funcname.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test_expect_funcname () {
105105
grep "^@@.*@@ $1" diff
106106
}
107107

108-
for p in bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
108+
for p in ada bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
109109
do
110110
test_expect_success "builtin $p pattern compiles" '
111111
echo "*.java diff=$p" >.gitattributes &&

t/t4034-diff-words.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ test_expect_success 'unset default driver' '
298298
test_unconfig diff.wordregex
299299
'
300300
301+
test_language_driver ada
301302
test_language_driver bibtex
302303
test_language_driver cpp
303304
test_language_driver csharp

t/t4034/ada/expect

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<BOLD>diff --git a/pre b/post<RESET>
2+
<BOLD>index d96fdd1..df21bb0 100644<RESET>
3+
<BOLD>--- a/pre<RESET>
4+
<BOLD>+++ b/post<RESET>
5+
<CYAN>@@ -1,13 +1,13 @@<RESET>
6+
Ada.Text_IO.Put_Line("Hello World<RED>!<RESET><GREEN>?<RESET>");
7+
1 1e<RED>-<RESET>10 16#FE12#E2 3.141_592 '<RED>x<RESET><GREEN>y<RESET>'
8+
<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
9+
<RED>a<RESET><GREEN>y<RESET>
10+
<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b<RESET>
11+
<RED>a<RESET><GREEN>y<RESET>
12+
<GREEN>x<RESET>**<RED>b<RESET>
13+
<RED>a<RESET><GREEN>y<RESET>
14+
<GREEN>x<RESET>(<RED>b<RESET><GREEN>y<RESET>)
15+
<RED>a<RESET><GREEN>x<RESET>:=<RED>b<RESET>
16+
<RED>a<RESET><GREEN>y<RESET>
17+
<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>/= <RED>b<RESET>
18+
<RED>a<RESET><GREEN>y<RESET>
19+
<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
20+
<RED>a<RESET><GREEN>y<RESET>
21+
<GREEN>x<RESET>,<RED>b<RESET>
22+
<RED>a<RESET><GREEN>y<RESET>
23+
<GREEN>x<RESET>=><RED>b<RESET>
24+
<RED>a<RESET><GREEN>y<RESET>
25+
<GREEN>x<RESET>..<RED>b<RESET>
26+
<RED>a<RESET><GREEN>y<RESET>
27+
<GREEN>x<RESET><><RED>b<RESET><GREEN>y<RESET>

t/t4034/ada/post

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Ada.Text_IO.Put_Line("Hello World?");
2+
1 1e10 16#FE12#E2 3.141_592 'y'
3+
x+y x-y
4+
x*y x/y
5+
x**y
6+
x(y)
7+
x:=y
8+
x=y x/= y
9+
x<y x<=y x>y x>=y
10+
x,y
11+
x=>y
12+
x..y
13+
x<>y

t/t4034/ada/pre

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Ada.Text_IO.Put_Line("Hello World!");
2+
1 1e-10 16#FE12#E2 3.141_592 'x'
3+
a+b a-b
4+
a*b a/b
5+
a**b
6+
a(b)
7+
a:=b
8+
a=b a/= b
9+
a<b a<=b a>b a>=b
10+
a,b
11+
a=>b
12+
a..b
13+
a<>b

userdiff.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ static int drivers_alloc;
1414
{ name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, \
1515
word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" }
1616
static struct userdiff_driver builtin_drivers[] = {
17+
IPATTERN("ada",
18+
"!^(.*[ \t])?(is new|renames|is separate)([ \t].*)?$\n"
19+
"!^[ \t]*with[ \t].*$\n"
20+
"^[ \t]*((procedure|function)[ \t]+.*)$\n"
21+
"^[ \t]*((package|protected|task)[ \t]+.*)$",
22+
/* -- */
23+
"[a-zA-Z][a-zA-Z0-9_]*"
24+
"|[0-9][-+0-9#_.eE]"
25+
"|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"),
1726
IPATTERN("fortran",
1827
"!^([C*]|[ \t]*!)\n"
1928
"!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"

0 commit comments

Comments
 (0)