gitweb: hack around CGI's list-context param() handling
[git/mingw.git] / t / t4045-diff-relative.sh
blob3950f5034d319be99695c9332b22a8d26e20ff32
1 #!/bin/sh
3 test_description='diff --relative tests'
4 . ./test-lib.sh
6 test_expect_success 'setup' '
7 git commit --allow-empty -m empty &&
8 echo content >file1 &&
9 mkdir subdir &&
10 echo other content >subdir/file2 &&
11 git add . &&
12 git commit -m one
15 check_diff() {
16 expect=$1; shift
17 cat >expected <<EOF
18 diff --git a/$expect b/$expect
19 new file mode 100644
20 index 0000000..25c05ef
21 --- /dev/null
22 +++ b/$expect
23 @@ -0,0 +1 @@
24 +other content
25 EOF
26 test_expect_success "-p $*" "
27 git diff -p $* HEAD^ >actual &&
28 test_cmp expected actual
32 check_numstat() {
33 expect=$1; shift
34 cat >expected <<EOF
35 1 0 $expect
36 EOF
37 test_expect_success "--numstat $*" "
38 echo '1 0 $expect' >expected &&
39 git diff --numstat $* HEAD^ >actual &&
40 test_cmp expected actual
44 check_stat() {
45 expect=$1; shift
46 cat >expected <<EOF
47 $expect | 1 +
48 1 file changed, 1 insertion(+)
49 EOF
50 test_expect_success "--stat $*" "
51 git diff --stat $* HEAD^ >actual &&
52 test_i18ncmp expected actual
56 check_raw() {
57 expect=$1; shift
58 cat >expected <<EOF
59 :000000 100644 0000000000000000000000000000000000000000 25c05ef3639d2d270e7fe765a67668f098092bc5 A $expect
60 EOF
61 test_expect_success "--raw $*" "
62 git diff --no-abbrev --raw $* HEAD^ >actual &&
63 test_cmp expected actual
67 for type in diff numstat stat raw; do
68 check_$type file2 --relative=subdir/
69 check_$type file2 --relative=subdir
70 check_$type dir/file2 --relative=sub
71 done
73 test_done