dir: fix treatment of negated pathspecs
[git/raj.git] / t / t4018-diff-funcname.sh
blob02255a08bf1718659f9815e37644c07a196ab850
1 #!/bin/sh
3 # Copyright (c) 2007 Johannes E. Schindelin
6 test_description='Test custom diff function name patterns'
8 . ./test-lib.sh
10 test_expect_success 'setup' '
11 # a non-trivial custom pattern
12 git config diff.custom1.funcname "!static
13 !String
14 [^ ].*s.*" &&
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
24 echo A >A.java &&
25 echo B >B.java
28 diffpatterns="
29 ada
30 bibtex
31 cpp
32 csharp
33 css
34 dts
35 elixir
36 fortran
37 fountain
38 golang
39 html
40 java
41 matlab
42 objc
43 pascal
44 perl
45 php
46 python
47 ruby
48 rust
49 tex
50 custom1
51 custom2
52 custom3
55 for p in $diffpatterns
57 test_expect_success "builtin $p pattern compiles" '
58 echo "*.java diff=$p" >.gitattributes &&
59 test_expect_code 1 git diff --no-index \
60 A.java B.java 2>msg &&
61 test_i18ngrep ! fatal msg &&
62 test_i18ngrep ! error msg
64 test_expect_success "builtin $p wordRegex pattern compiles" '
65 echo "*.java diff=$p" >.gitattributes &&
66 test_expect_code 1 git diff --no-index --word-diff \
67 A.java B.java 2>msg &&
68 test_i18ngrep ! fatal msg &&
69 test_i18ngrep ! error msg
71 done
73 test_expect_success 'last regexp must not be negated' '
74 echo "*.java diff=java" >.gitattributes &&
75 test_config diff.java.funcname "!static" &&
76 test_expect_code 128 git diff --no-index A.java B.java 2>msg &&
77 test_i18ngrep ": Last expression must not be negated:" msg
80 test_expect_success 'setup hunk header tests' '
81 for i in $diffpatterns
83 echo "$i-* diff=$i"
84 done > .gitattributes &&
86 # add all test files to the index
88 cd "$TEST_DIRECTORY"/t4018 &&
89 git --git-dir="$TRASH_DIRECTORY/.git" add .
90 ) &&
92 # place modified files in the worktree
93 for i in $(git ls-files)
95 sed -e "s/ChangeMe/IWasChanged/" <"$TEST_DIRECTORY/t4018/$i" >"$i" || return 1
96 done
99 # check each individual file
100 for i in $(git ls-files)
102 if grep broken "$i" >/dev/null 2>&1
103 then
104 result=failure
105 else
106 result=success
108 test_expect_$result "hunk header: $i" "
109 git diff -U1 $i >actual &&
110 grep '@@ .* @@.*RIGHT' actual
112 done
114 test_done