]> rtime.felk.cvut.cz Git - git.git/blob - t/t4004-diff-rename-symlink.sh
Merge git://git.kernel.org/pub/scm/gitk/gitk
[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 . "$TEST_DIRECTORY"/diff-lib.sh
14
15 if ! test_have_prereq SYMLINKS
16 then
17         say 'Symbolic links not supported, skipping tests.'
18         test_done
19 fi
20
21 test_expect_success \
22     'prepare reference tree' \
23     'echo xyzzy | tr -d '\\\\'012 >yomin &&
24      ln -s xyzzy frotz &&
25     git update-index --add frotz yomin &&
26     tree=$(git write-tree) &&
27     echo $tree'
28
29 test_expect_success \
30     'prepare work tree' \
31     'mv frotz rezrov &&
32      rm -f yomin &&
33      ln -s xyzzy nitfol &&
34      ln -s xzzzy bozbar &&
35     git update-index --add --remove frotz rezrov nitfol bozbar yomin'
36
37 # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
38 # confuse things.  work tree has rezrov (xyzzy) nitfol (xyzzy) and
39 # bozbar (xzzzy).
40 # rezrov and nitfol are rename/copy of frotz and bozbar should be
41 # a new creation.
42
43 GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree >current
44 cat >expected <<\EOF
45 diff --git a/bozbar b/bozbar
46 new file mode 120000
47 --- /dev/null
48 +++ b/bozbar
49 @@ -0,0 +1 @@
50 +xzzzy
51 \ No newline at end of file
52 diff --git a/frotz b/nitfol
53 similarity index 100%
54 copy from frotz
55 copy to nitfol
56 diff --git a/frotz b/rezrov
57 similarity index 100%
58 rename from frotz
59 rename to rezrov
60 diff --git a/yomin b/yomin
61 deleted file mode 100644
62 --- a/yomin
63 +++ /dev/null
64 @@ -1 +0,0 @@
65 -xyzzy
66 \ No newline at end of file
67 EOF
68
69 test_expect_success \
70     'validate diff output' \
71     'compare_diff_patch current expected'
72
73 test_done