Big tool rename.
[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
11 echo >path0 'Line 1
12 Line 2
13 Line 3
14 Line 4
15 Line 5
16 Line 6
17 Line 7
18 Line 8
19 Line 9
20 Line 10
21 line 11
22 Line 12
23 Line 13
24 Line 14
25 Line 15
26 '
27
28 test_expect_success \
29     'update-cache --add a file.' \
30     'git-update-index --add path0'
31
32 test_expect_success \
33     'write that tree.' \
34     'tree=$(git-write-tree) && echo $tree'
35
36 sed -e 's/line/Line/' <path0 >path1
37 rm -f path0
38 test_expect_success \
39     'renamed and edited the file.' \
40     'git-update-index --add --remove path0 path1'
41
42 test_expect_success \
43     'git-diff-index -p -M after rename and editing.' \
44     'git-diff-index -p -M $tree >current'
45 cat >expected <<\EOF
46 diff --git a/path0 b/path1
47 rename from path0
48 rename to path1
49 --- a/path0
50 +++ b/path1
51 @@ -8,7 +8,7 @@ Line 7
52  Line 8
53  Line 9
54  Line 10
55 -line 11
56 +Line 11
57  Line 12
58  Line 13
59  Line 14
60 EOF
61
62 test_expect_success \
63     'validate the output.' \
64     'diff -I "similarity.*" >/dev/null current expected'
65
66 test_done