3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Test rename detection in diff engine.
10 . "$TEST_DIRECTORY"/diff-lib.sh
30 'update-index --add a file.' \
31 'git update-index --add path0'
35 'tree=$(git write-tree) && echo $tree'
37 sed -e 's/line/Line/' <path0 >path1
40 'renamed and edited the file.' \
41 'git update-index --add --remove path0 path1'
44 'git diff-index -p -M after rename and editing.' \
45 'git diff-index -p -M $tree >current'
47 diff --git a/path0 b/path1
52 @@ -8,7 +8,7 @@ Line 7
64 'validate the output.' \
65 'compare_diff_patch current expected'
67 test_expect_success 'favour same basenames over different ones' '
68 cp path1 another-path &&
69 git add another-path &&
73 git mv another-path subdir/path1 &&
74 git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
76 test_expect_success 'favour same basenames even with minor differences' '
77 git show HEAD:path1 | sed "s/15/16/" > subdir/path1 &&
78 git status | test_i18ngrep "renamed: .*path1 -> subdir/path1"'
80 test_expect_success 'setup for many rename source candidates' '
82 for i in 0 1 2 3 4 5 6 7 8 9;
84 for j in 0 1 2 3 4 5 6 7 8 9;
86 echo "$i$j" >"path$i$j"
91 git commit -m "hundred" &&
92 (cat path1; echo new) >new-path &&
94 git add new-path path1 &&
95 git diff -l 4 -C -C --cached --name-status >actual 2>actual.err &&
96 sed -e "s/^\([CM]\)[0-9]* /\1 /" actual >actual.munged &&
101 test_cmp expect actual.munged &&
102 grep warning actual.err