]>
Commit | Line | Data |
---|---|---|
f7c1512a JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='Same rename detection as t4003 but testing diff-raw. | |
7 | ||
8 | ' | |
9 | . ./test-lib.sh | |
bfdbee98 | 10 | . "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash |
b6d8f309 | 11 | |
f7c1512a JH |
12 | test_expect_success \ |
13 | 'prepare reference tree' \ | |
bfdbee98 | 14 | 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && |
f7c1512a | 15 | echo frotz >rezrov && |
5be60078 JH |
16 | git update-index --add COPYING rezrov && |
17 | tree=$(git write-tree) && | |
f7c1512a JH |
18 | echo $tree' |
19 | ||
20 | test_expect_success \ | |
21 | 'prepare work tree' \ | |
22 | 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 && | |
23 | sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 && | |
24 | rm -f COPYING && | |
5be60078 | 25 | git update-index --add --remove COPYING COPYING.?' |
f7c1512a JH |
26 | |
27 | # tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2, | |
28 | # both are slightly edited, and unchanged rezrov. We say COPYING.1 | |
29 | # and COPYING.2 are based on COPYING, and do not say anything about | |
30 | # rezrov. | |
31 | ||
0940e5f2 | 32 | git diff-index -C $tree >current |
f7c1512a JH |
33 | |
34 | cat >expected <<\EOF | |
b6d8f309 JH |
35 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 |
36 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234 COPYING COPYING.2 | |
f7c1512a JH |
37 | EOF |
38 | ||
39 | test_expect_success \ | |
b6d8f309 JH |
40 | 'validate output from rename/copy detection (#1)' \ |
41 | 'compare_diff_raw current expected' | |
42 | ||
b6d8f309 | 43 | ################################################################ |
f7c1512a JH |
44 | |
45 | test_expect_success \ | |
46 | 'prepare work tree again' \ | |
47 | 'mv COPYING.2 COPYING && | |
5be60078 | 48 | git update-index --add --remove COPYING COPYING.1 COPYING.2' |
f7c1512a JH |
49 | |
50 | # tree has COPYING and rezrov. work tree has COPYING and COPYING.1, | |
51 | # both are slightly edited, and unchanged rezrov. We say COPYING.1 | |
52 | # is based on COPYING and COPYING is still there, and do not say anything | |
53 | # about rezrov. | |
54 | ||
5be60078 | 55 | git diff-index -C $tree >current |
f7c1512a | 56 | cat >expected <<\EOF |
b6d8f309 | 57 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M COPYING |
25d5ea41 | 58 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 |
f7c1512a JH |
59 | EOF |
60 | ||
61 | test_expect_success \ | |
b6d8f309 JH |
62 | 'validate output from rename/copy detection (#2)' \ |
63 | 'compare_diff_raw current expected' | |
f7c1512a | 64 | |
b6d8f309 JH |
65 | ################################################################ |
66 | ||
f7c1512a | 67 | # tree has COPYING and rezrov. work tree has the same COPYING and |
bceafe75 JH |
68 | # copy-edited COPYING.1, and unchanged rezrov. We should not say |
69 | # anything about rezrov nor COPYING, since the revised again diff-raw | |
70 | # nows how to say Copy. | |
f7c1512a | 71 | |
ddafa7e9 JH |
72 | test_expect_success \ |
73 | 'prepare work tree once again' \ | |
bfdbee98 | 74 | 'cat "$TEST_DIRECTORY"/../COPYING >COPYING && |
5be60078 | 75 | git update-index --add --remove COPYING COPYING.1' |
ddafa7e9 | 76 | |
5be60078 | 77 | git diff-index -C --find-copies-harder $tree >current |
f7c1512a | 78 | cat >expected <<\EOF |
b6d8f309 | 79 | :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1 |
b6d8f309 JH |
80 | EOF |
81 | ||
82 | test_expect_success \ | |
83 | 'validate output from rename/copy detection (#3)' \ | |
84 | 'compare_diff_raw current expected' | |
85 | ||
f7c1512a | 86 | test_done |