3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test custom diff function name patterns'
13 cat > Beer.java << EOF
17 public static void main(String args[])
20 for(int x = 99; x > 0; x--)
22 System.out.print(x + " bottles of beer on the wall "
23 + x + " bottles of beer\n"
24 + "Take one down, pass it around, " + (x - 1)
25 + " bottles of beer on the wall.\n");
27 System.out.print("Go to the store, buy some more,\n"
28 + "99 bottles of beer on the wall.\n");
33 sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
35 builtin_patterns="bibtex cpp csharp fortran html java objc pascal php python ruby tex"
36 for p in $builtin_patterns
38 test_expect_success "builtin $p pattern compiles" '
39 echo "*.java diff=$p" > .gitattributes &&
40 ! { git diff --no-index Beer.java Beer-correct.java 2>&1 |
41 grep "fatal" > /dev/null; }
43 test_expect_success "builtin $p wordRegex pattern compiles" '
44 ! { git diff --no-index --word-diff \
45 Beer.java Beer-correct.java 2>&1 |
46 grep "fatal" > /dev/null; }
50 test_expect_success 'default behaviour' '
51 rm -f .gitattributes &&
52 git diff --no-index Beer.java Beer-correct.java |
53 grep "^@@.*@@ public class Beer"
56 test_expect_success 'preset java pattern' '
57 echo "*.java diff=java" >.gitattributes &&
58 git diff --no-index Beer.java Beer-correct.java |
59 grep "^@@.*@@ public static void main("
62 git config diff.java.funcname '!static
66 test_expect_success 'custom pattern' '
67 git diff --no-index Beer.java Beer-correct.java |
68 grep "^@@.*@@ int special;$"
71 test_expect_success 'last regexp must not be negated' '
72 git config diff.java.funcname "!static" &&
73 git diff --no-index Beer.java Beer-correct.java 2>&1 |
74 grep "fatal: Last expression must not be negated:"
77 test_expect_success 'pattern which matches to end of line' '
78 git config diff.java.funcname "Beer$" &&
79 git diff --no-index Beer.java Beer-correct.java |
83 test_expect_success 'alternation in pattern' '
84 git config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
85 git diff --no-index Beer.java Beer-correct.java |
86 grep "^@@.*@@ public static void main("