t1405: sort reflog entries in a hash-independent way
[alt-git.git] / t / t4018-diff-funcname.sh
blob22f9f88f0afc54f1dfeebbea623a4c41fde709f6
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 fortran
35 fountain
36 golang
37 html
38 java
39 matlab
40 objc
41 pascal
42 perl
43 php
44 python
45 ruby
46 tex
47 custom1
48 custom2
49 custom3
52 for p in $diffpatterns
54 test_expect_success "builtin $p pattern compiles" '
55 echo "*.java diff=$p" >.gitattributes &&
56 test_expect_code 1 git diff --no-index \
57 A.java B.java 2>msg &&
58 test_i18ngrep ! fatal msg &&
59 test_i18ngrep ! error msg
61 test_expect_success "builtin $p wordRegex pattern compiles" '
62 echo "*.java diff=$p" >.gitattributes &&
63 test_expect_code 1 git diff --no-index --word-diff \
64 A.java B.java 2>msg &&
65 test_i18ngrep ! fatal msg &&
66 test_i18ngrep ! error msg
68 done
70 test_expect_success 'last regexp must not be negated' '
71 echo "*.java diff=java" >.gitattributes &&
72 test_config diff.java.funcname "!static" &&
73 test_expect_code 128 git diff --no-index A.java B.java 2>msg &&
74 test_i18ngrep ": Last expression must not be negated:" msg
77 test_expect_success 'setup hunk header tests' '
78 for i in $diffpatterns
80 echo "$i-* diff=$i"
81 done > .gitattributes &&
83 # add all test files to the index
85 cd "$TEST_DIRECTORY"/t4018 &&
86 git --git-dir="$TRASH_DIRECTORY/.git" add .
87 ) &&
89 # place modified files in the worktree
90 for i in $(git ls-files)
92 sed -e "s/ChangeMe/IWasChanged/" <"$TEST_DIRECTORY/t4018/$i" >"$i" || return 1
93 done
96 # check each individual file
97 for i in $(git ls-files)
99 if grep broken "$i" >/dev/null 2>&1
100 then
101 result=failure
102 else
103 result=success
105 test_expect_$result "hunk header: $i" "
106 test_when_finished 'cat actual' && # for debugging only
107 git diff -U1 $i >actual &&
108 grep '@@ .* @@.*RIGHT' actual
110 done
112 test_done