3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description
='Test custom diff function name patterns'
16 public static void main
(String args
[])
19 for(int x
= 99; x
> 0; x--
)
21 System.out.print
(x
+ " bottles of beer on the wall "
22 + x
+ " bottles of beer\n"
23 + "Take one down, pass it around, " + (x
- 1)
24 + " bottles of beer on the wall.\n");
26 System.out.print
("Go to the store, buy some more,\n"
27 + "99 bottles of beer on the wall.\n");
31 sed 's/beer\\/beer,\\/' <Beer.java
>Beer-correct.java
33 test_expect_success
'setup' '
34 # a non-trivial custom pattern
35 git config diff.custom1.funcname "!static
39 # a custom pattern which matches to end of line
40 git config diff.custom2.funcname "......Beer\$" &&
42 # alternation in pattern
43 git config diff.custom3.funcname "Beer$" &&
44 git config diff.custom3.xfuncname "^[ ]*((public|static).*)$"
68 for p
in $diffpatterns
70 test_expect_success
"builtin $p pattern compiles" '
71 echo "*.java diff=$p" >.gitattributes &&
72 test_expect_code 1 git diff --no-index \
73 Beer.java Beer-correct.java 2>msg &&
77 test_expect_success
"builtin $p wordRegex pattern compiles" '
78 echo "*.java diff=$p" >.gitattributes &&
79 test_expect_code 1 git diff --no-index --word-diff \
80 Beer.java Beer-correct.java 2>msg &&
86 test_expect_success
'set up .gitattributes declaring drivers to test' '
87 cat >.gitattributes <<-\EOF
92 test_expect_success
'last regexp must not be negated' '
93 test_config diff.java.funcname "!static" &&
94 test_expect_code 128 git diff --no-index Beer.java Beer-correct.java 2>msg &&
95 grep ": Last expression must not be negated:" msg
98 test_expect_success
'setup hunk header tests' '
99 for i in $diffpatterns
102 done > .gitattributes &&
104 # add all test files to the index
106 cd "$TEST_DIRECTORY"/t4018 &&
107 git --git-dir="$TRASH_DIRECTORY/.git" add .
110 # place modified files in the worktree
111 for i in $(git ls-files)
113 sed -e "s/ChangeMe/IWasChanged/" <"$TEST_DIRECTORY/t4018/$i" >"$i" || return 1
117 # check each individual file
118 for i
in $
(git ls-files
)
120 if grep broken
"$i" >/dev
/null
2>&1
126 test_expect_
$result "hunk header: $i" "
127 test_when_finished 'cat actual' && # for debugging only
128 git diff -U1 $i >actual &&
129 grep '@@ .* @@.*RIGHT' actual