1 # Helpers shared by the test scripts for diff algorithms (patience,
12 for(i
= 0; i
< 10; i
++)
14 printf("Your answer is: ");
28 int main
(int argc
, char
**argv
)
41 return fib
(n-1
) + fib
(n-2
);
50 for(i
= 0; i
< 10; i
++)
56 int main
(int argc
, char
**argv
)
62 file1
=$
(git rev-parse
--short $
(git hash-object file1
))
63 file2
=$
(git rev-parse
--short $
(git hash-object file2
))
65 diff --git a/file1 b/file2
66 index $file1..$file2 100644
76 + return fib(n-1) + fib(n-2);
85 for(i = 0; i < 10; i++)
87 - printf("Your answer is: ");
96 - return fact(n-1) * n;
101 int main(int argc, char **argv)
103 - frobnitz(fact(10));
108 cat >expect_diffstat
<<EOF
109 file1 => file2 | 21 ++++++++++-----------
110 1 file changed, 10 insertions(+), 11 deletions(-)
115 test_expect_success
"$STRATEGY diff from attributes" '
116 echo "file* diff=driver" >.gitattributes &&
117 git config diff.driver.algorithm "$STRATEGY" &&
118 test_must_fail git diff --no-index file1 file2 > output &&
121 test_cmp expect output
124 test_expect_success
"$STRATEGY diff from attributes has valid diffstat" '
125 echo "file* diff=driver" >.gitattributes &&
126 git config diff.driver.algorithm "$STRATEGY" &&
127 test_must_fail git diff --stat --no-index file1 file2 > output &&
128 test_cmp expect_diffstat output
131 test_expect_success
"$STRATEGY diff" '
132 test_must_fail git diff --no-index "--diff-algorithm=$STRATEGY" file1 file2 > output &&
133 test_cmp expect output
136 test_expect_success
"$STRATEGY diff command line precedence before attributes" '
137 echo "file* diff=driver" >.gitattributes &&
138 git config diff.driver.algorithm myers &&
139 test_must_fail git diff --no-index "--diff-algorithm=$STRATEGY" file1 file2 > output &&
140 test_cmp expect output
143 test_expect_success
"$STRATEGY diff attributes precedence before config" '
144 git config diff.algorithm default &&
145 echo "file* diff=driver" >.gitattributes &&
146 git config diff.driver.algorithm "$STRATEGY" &&
147 test_must_fail git diff --no-index file1 file2 > output &&
148 test_cmp expect output
151 test_expect_success
"$STRATEGY diff output is valid" '
153 git apply < output &&
154 test_cmp expect file2
177 uniq1
=$
(git rev-parse
--short $
(git hash-object uniq1
))
178 uniq2
=$
(git rev-parse
--short $
(git hash-object uniq2
))
180 diff --git a/uniq1 b/uniq2
181 index $uniq1..$uniq2 100644
201 test_expect_success
'completely different files' '
202 test_must_fail git diff --no-index "--$STRATEGY" uniq1 uniq2 > output &&
203 test_cmp expect output