Raw
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
5
6 test_description='More rename detection tests.
7
8 The rename detection logic should be able to detect pure rename or
9 copy of symbolic links, but should not produce rename/copy followed
10 by an edit for them.
11 '
12
13 . ./test-lib.sh
14 . "$TEST_DIRECTORY"/lib-diff.sh
15
16 test_expect_success SYMLINKS 'prepare reference tree' '
17 echo xyzzy | tr -d '\\\\'012 >yomin &&
18 ln -s xyzzy frotz &&
19 git update-index --add frotz yomin &&
20 tree=$(git write-tree) &&
21 echo $tree
22 '
23
24 test_expect_success SYMLINKS 'prepare work tree' '
25 mv frotz rezrov &&
26 rm -f yomin &&
27 ln -s xyzzy nitfol &&
28 ln -s xzzzy bozbar &&
29 git update-index --add --remove frotz rezrov nitfol bozbar yomin
30 '
31
32 # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
33 # confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and
34 # bozbar (xzzzy).
35 # rezrov and nitfol are rename/copy of frotz and bozbar should be
36 # a new creation.
37
38 test_expect_success SYMLINKS 'setup diff output' '
39 GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current &&
40 cat >expected <<\EOF
41 diff --git a/bozbar b/bozbar
42 new file mode 120000
43 --- /dev/null
44 +++ b/bozbar
45 @@ -0,0 +1 @@
46 +xzzzy
47 \ No newline at end of file
48 diff --git a/frotz b/nitfol
49 similarity index 100%
50 copy from frotz
51 copy to nitfol
52 diff --git a/frotz b/rezrov
53 similarity index 100%
54 rename from frotz
55 rename to rezrov
56 diff --git a/yomin b/yomin
57 deleted file mode 100644
58 --- a/yomin
59 +++ /dev/null
60 @@ -1 +0,0 @@
61 -xyzzy
62 \ No newline at end of file
63 EOF
64 '
65
66 test_expect_success SYMLINKS 'validate diff output' '
67 compare_diff_patch current expected
68 '
69
70 test_done