3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test custom diff function name patterns'
10 test_expect_success 'setup' '
11 # a non-trivial custom pattern
12 git config diff.custom1.funcname "!static
16 # a custom pattern which matches to end of line
17 git config diff.custom2.funcname "......Beer\$" &&
19 # alternation in pattern
20 git config diff.custom3.funcname "Beer$" &&
21 git config diff.custom3.xfuncname "^[ ]*((public|static).*)$" &&
23 # for regexp compilation tests
51 for p in $diffpatterns
53 test_expect_success "builtin $p pattern compiles" '
54 echo "*.java diff=$p" >.gitattributes &&
55 test_expect_code 1 git diff --no-index \
56 A.java B.java 2>msg &&
57 test_i18ngrep ! fatal msg &&
58 test_i18ngrep ! error msg
60 test_expect_success "builtin $p wordRegex pattern compiles" '
61 echo "*.java diff=$p" >.gitattributes &&
62 test_expect_code 1 git diff --no-index --word-diff \
63 A.java B.java 2>msg &&
64 test_i18ngrep ! fatal msg &&
65 test_i18ngrep ! error msg
69 test_expect_success 'last regexp must not be negated' '
70 echo "*.java diff=java" >.gitattributes &&
71 test_config diff.java.funcname "!static" &&
72 test_expect_code 128 git diff --no-index A.java B.java 2>msg &&
73 test_i18ngrep ": Last expression must not be negated:" msg
76 test_expect_success 'setup hunk header tests' '
77 for i in $diffpatterns
80 done > .gitattributes &&
82 # add all test files to the index
84 cd "$TEST_DIRECTORY"/t4018 &&
85 git --git-dir="$TRASH_DIRECTORY/.git" add .
88 # place modified files in the worktree
89 for i in $(git ls-files)
91 sed -e "s/ChangeMe/IWasChanged/" <"$TEST_DIRECTORY/t4018/$i" >"$i" || return 1
95 # check each individual file
96 for i in $(git ls-files)
98 if grep broken "$i" >/dev/null 2>&1
104 test_expect_$result "hunk header: $i" "
105 test_when_finished 'cat actual' && # for debugging only
106 git diff -U1 $i >actual &&
107 grep '@@ .* @@.*RIGHT' actual