Merge branch 'maint'
[git/mingw/4msysgit/kblees.git] / t / t4032-diff-inter-hunk-context.sh
blobe4e3e28fc788fd16c73298a0c385f1b39994941e
1 #!/bin/sh
3 test_description='diff hunk fusing'
5 . ./test-lib.sh
7 f() {
8 echo $1
9 i=1
10 while test $i -le $2
12 echo $i
13 i=$(expr $i + 1)
14 done
15 echo $3
18 t() {
19 case $# in
20 4) hunks=$4; cmd="diff -U$3";;
21 5) hunks=$5; cmd="diff -U$3 --inter-hunk-context=$4";;
22 esac
23 label="$cmd, $1 common $2"
24 file=f$1
25 expected=expected.$file.$3.$hunks
27 if ! test -f $file
28 then
29 f A $1 B >$file
30 git add $file
31 git commit -q -m. $file
32 f X $1 Y >$file
35 test_expect_success "$label: count hunks ($hunks)" "
36 test $(git $cmd $file | grep '^@@ ' | wc -l) = $hunks
39 test -f $expected &&
40 test_expect_success "$label: check output" "
41 git $cmd $file | grep -v '^index ' >actual &&
42 test_cmp $expected actual
46 cat <<EOF >expected.f1.0.1 || exit 1
47 diff --git a/f1 b/f1
48 --- a/f1
49 +++ b/f1
50 @@ -1,3 +1,3 @@
56 EOF
58 cat <<EOF >expected.f1.0.2 || exit 1
59 diff --git a/f1 b/f1
60 --- a/f1
61 +++ b/f1
62 @@ -1 +1 @@
65 @@ -3 +3 @@ A
68 EOF
70 # common lines ctx intrctx hunks
71 t 1 line 0 2
72 t 1 line 0 0 2
73 t 1 line 0 1 1
74 t 1 line 0 2 1
75 t 1 line 1 1
77 t 2 lines 0 2
78 t 2 lines 0 0 2
79 t 2 lines 0 1 2
80 t 2 lines 0 2 1
81 t 2 lines 1 1
83 t 3 lines 1 2
84 t 3 lines 1 0 2
85 t 3 lines 1 1 1
86 t 3 lines 1 2 1
88 t 9 lines 3 2
89 t 9 lines 3 2 2
90 t 9 lines 3 3 1
92 test_done