index-pack: support checking objects but not links
[git] / t / t4046-diff-unmerged.sh
1 #!/bin/sh
2
3 test_description='diff with unmerged index entries'
4 . ./test-lib.sh
5
6 test_expect_success setup '
7         for i in 0 1 2 3
8         do
9                 blob=$(echo $i | git hash-object --stdin) &&
10                 eval "blob$i=$blob" &&
11                 eval "m$i=\"100644 \$blob$i $i\"" || return 1
12         done &&
13         paths= &&
14         for b in o x
15         do
16                 for o in o x
17                 do
18                         for t in o x
19                         do
20                                 path="$b$o$t" &&
21                                 case "$path" in ooo) continue ;; esac
22                                 paths="$paths$path " &&
23                                 p="     $path" &&
24                                 case "$b" in x) echo "$m1$p" ;; esac &&
25                                 case "$o" in x) echo "$m2$p" ;; esac &&
26                                 case "$t" in x) echo "$m3$p" ;; esac ||
27                                 return 1
28                         done
29                 done
30         done >ls-files-s.expect &&
31         git update-index --index-info <ls-files-s.expect &&
32         git ls-files -s >ls-files-s.actual &&
33         test_cmp ls-files-s.expect ls-files-s.actual
34 '
35
36 test_expect_success 'diff-files -0' '
37         for path in $paths
38         do
39                 >"$path" &&
40                 echo ":000000 100644 $_z40 $_z40 U      $path"
41         done >diff-files-0.expect &&
42         git diff-files -0 >diff-files-0.actual &&
43         test_cmp diff-files-0.expect diff-files-0.actual
44 '
45
46 test_expect_success 'diff-files -1' '
47         for path in $paths
48         do
49                 >"$path" &&
50                 echo ":000000 100644 $_z40 $_z40 U      $path" &&
51                 case "$path" in
52                 x??) echo ":100644 100644 $blob1 $_z40 M        $path"
53                 esac
54         done >diff-files-1.expect &&
55         git diff-files -1 >diff-files-1.actual &&
56         test_cmp diff-files-1.expect diff-files-1.actual
57 '
58
59 test_expect_success 'diff-files -2' '
60         for path in $paths
61         do
62                 >"$path" &&
63                 echo ":000000 100644 $_z40 $_z40 U      $path" &&
64                 case "$path" in
65                 ?x?) echo ":100644 100644 $blob2 $_z40 M        $path"
66                 esac
67         done >diff-files-2.expect &&
68         git diff-files -2 >diff-files-2.actual &&
69         test_cmp diff-files-2.expect diff-files-2.actual &&
70         git diff-files >diff-files-default-2.actual &&
71         test_cmp diff-files-2.expect diff-files-default-2.actual
72 '
73
74 test_expect_success 'diff-files -3' '
75         for path in $paths
76         do
77                 >"$path" &&
78                 echo ":000000 100644 $_z40 $_z40 U      $path" &&
79                 case "$path" in
80                 ??x) echo ":100644 100644 $blob3 $_z40 M        $path"
81                 esac
82         done >diff-files-3.expect &&
83         git diff-files -3 >diff-files-3.actual &&
84         test_cmp diff-files-3.expect diff-files-3.actual
85 '
86
87 test_done