1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Test rename detection in diff engine.
7
8'
9. ./test-lib.sh
10
11echo >path0 'Line 1
12Line 2
13Line 3
14Line 4
15Line 5
16Line 6
17Line 7
18Line 8
19Line 9
20Line 10
21line 11
22Line 12
23Line 13
24Line 14
25Line 15
26'
27
28test_expect_success \
29 'update-cache --add a file.' \
30 'git-update-cache --add path0'
31
32test_expect_success \
33 'write that tree.' \
34 'tree=$(git-write-tree) && echo $tree'
35
36sed -e 's/line/Line/' <path0 >path1
37rm -f path0
38test_expect_success \
39 'renamed and edited the file.' \
40 'git-update-cache --add --remove path0 path1'
41
42test_expect_success \
43 'git-diff-cache -p -M after rename and editing.' \
44 'git-diff-cache -p -M $tree >current'
45cat >expected <<\EOF
46diff --git a/path0 b/path1
47rename old path0
48rename new 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
60EOF
61
62test_expect_success \
63 'validate the output.' \
64 'diff -I "similarity.*" >/dev/null current expected'
65
66test_done