Merge branch 'jc/apply'
[git.git] / t / t4001-diff-rename.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='Test rename detection in diff engine.
7
8 '
9 . ./test-lib.sh
10 . ../diff-lib.sh
11
12 echo >path0 'Line 1
13 Line 2
14 Line 3
15 Line 4
16 Line 5
17 Line 6
18 Line 7
19 Line 8
20 Line 9
21 Line 10
22 line 11
23 Line 12
24 Line 13
25 Line 14
26 Line 15
27 '
28
29 test_expect_success \
30     'update-cache --add a file.' \
31     'git-update-index --add path0'
32
33 test_expect_success \
34     'write that tree.' \
35     'tree=$(git-write-tree) && echo $tree'
36
37 sed -e 's/line/Line/' <path0 >path1
38 rm -f path0
39 test_expect_success \
40     'renamed and edited the file.' \
41     'git-update-index --add --remove path0 path1'
42
43 test_expect_success \
44     'git-diff-index -p -M after rename and editing.' \
45     'git-diff-index -p -M $tree >current'
46 cat >expected <<\EOF
47 diff --git a/path0 b/path1
48 rename from path0
49 rename to path1
50 --- a/path0
51 +++ b/path1
52 @@ -8,7 +8,7 @@ Line 7
53  Line 8
54  Line 9
55  Line 10
56 -line 11
57 +Line 11
58  Line 12
59  Line 13
60  Line 14
61 EOF
62
63 test_expect_success \
64     'validate the output.' \
65     'compare_diff_patch current expected'
66
67 test_done