1
#!/bin/sh
2
3
+# NOTICE:
4
+# This testsuite does a number of diffs and checks that the output match.
5
+# However, it is a "garbage in, garbage out" situation; the trees have
6
+# duplicate entries for individual paths, and it results in diffs that do
7
+# not make much sense. As such, it is not clear that the diffs are
8
+# "correct". The primary purpose of these tests was to verify that
9
+# diff-tree does not segfault, but there is perhaps some value in ensuring
10
+# that the diff output isn't wildly unreasonable.
11
+
12
test_description='test tree diff when trees have duplicate entries'
13
. ./test-lib.sh
14
66
git tag two $outer_two
67
'
68
60
-test_expect_success 'diff-tree between trees' '
69
+test_expect_success 'create tree without duplicate entries' '
70
+ blob_one=$(echo one | git hash-object -w --stdin) &&
71
+ outer_three=$(make_tree \
72
+ 100644 renamed $blob_one
73
+ ) &&
74
+ git tag three $outer_three
75
+'
76
+
77
+test_expect_success 'diff-tree between duplicate trees' '
78
+ # See NOTICE at top of file
79
{
80
printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" &&
81
printf ":000000 100644 $ZERO_OID $blob_two A\touter/inner\n" &&
89
'
90
91
test_expect_success 'diff-tree with renames' '
74
- # same expectation as above, since we disable rename detection
92
+ # See NOTICE at top of file.
93
git diff-tree -M -r --no-abbrev one two >actual &&
94
test_cmp expect actual
95
'
96
97
+test_expect_success 'diff-tree FROM duplicate tree' '
98
+ # See NOTICE at top of file.
99
+ {
100
+ printf ":100644 000000 $blob_one $ZERO_OID D\touter/inner\n" &&
101
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
102
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
103
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
104
+ printf ":000000 100644 $ZERO_OID $blob_one A\trenamed\n"
105
+ } >expect &&
106
+ git diff-tree -r --no-abbrev one three >actual &&
107
+ test_cmp expect actual
108
+'
109
+
110
+test_expect_success 'diff-tree FROM duplicate tree, with renames' '
111
+ # See NOTICE at top of file.
112
+ {
113
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
114
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
115
+ printf ":100644 000000 $blob_two $ZERO_OID D\touter/inner\n" &&
116
+ printf ":100644 100644 $blob_one $blob_one R100\touter/inner\trenamed\n"
117
+ } >expect &&
118
+ git diff-tree -M -r --no-abbrev one three >actual &&
119
+ test_cmp expect actual
120
+'
121
+
122
test_done