[PATCH] Redo rename/copy detection logic.
[git/git.git] / t / t4004-diff-rename-symlink.sh
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 . ./test-lib.sh
13
14 test_expect_success \
15 'prepare reference tree' \
16 'echo xyzzy | tr -d '\\\\'012 >yomin &&
17 ln -s xyzzy frotz &&
18 git-update-cache --add frotz yomin &&
19 tree=$(git-write-tree) &&
20 echo $tree'
21
22 test_expect_success \
23 'prepare work tree' \
24 'mv frotz rezrov &&
25 rm -f yomin &&
26 ln -s xyzzy nitfol &&
27 ln -s xzzzy bozbar &&
28 git-update-cache --add --remove frotz rezrov nitfol bozbar yomin'
29
30 # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
31 # confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and
32 # bozbar (xzzzy).
33 # rezrov and nitfol are rename/copy of frotz and bozbar should be
34 # a new creation.
35
36 GIT_DIFF_OPTS=--unified=0 git-diff-cache -M -p $tree >current
37 cat >expected <<\EOF
38 diff --git a/bozbar b/bozbar
39 new file mode 120000
40 --- /dev/null
41 +++ b/bozbar
42 @@ -0,0 +1 @@
43 +xzzzy
44 \ No newline at end of file
45 diff --git a/frotz b/nitfol
46 similarity index 100%
47 copy from frotz
48 copy to nitfol
49 diff --git a/frotz b/rezrov
50 similarity index 100%
51 rename old frotz
52 rename new rezrov
53 diff --git a/yomin b/yomin
54 deleted file mode 100644
55 --- a/yomin
56 +++ /dev/null
57 @@ -1 +0,0 @@
58 -xyzzy
59 \ No newline at end of file
60 EOF
61
62 test_expect_success \
63 'validate diff output' \
64 'diff -u current expected'
65
66 test_done