Use a strbuf in symlink
[git/mingw/4msysgit.git] / t / t4004-diff-rename-symlink.sh
blob1175dd5b9ec94847ec2471f6dc652c8d41c99bcd
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='More rename detection tests.
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.
12 . ./test-lib.sh
13 . "$TEST_DIRECTORY"/diff-lib.sh
15 test_expect_success SYMLINKS \
16 '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'
23 test_expect_success SYMLINKS \
24 'prepare work tree' \
25 '>xyzzy &&
26 mv frotz rezrov &&
27 rm -f yomin &&
28 rm -f xyzzy &&
29 ln -s xyzzy nitfol &&
30 ln -s xzzzy bozbar &&
31 git update-index --add --remove frotz rezrov nitfol bozbar yomin'
33 # tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
34 # confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and
35 # bozbar (xzzzy).
36 # rezrov and nitfol are rename/copy of frotz and bozbar should be
37 # a new creation.
39 test_expect_success SYMLINKS 'setup diff output' "
40 GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current &&
41 cat >expected <<\EOF
42 diff --git a/bozbar b/bozbar
43 new file mode 120000
44 --- /dev/null
45 +++ b/bozbar
46 @@ -0,0 +1 @@
47 +xzzzy
48 \ No newline at end of file
49 diff --git a/frotz b/nitfol
50 similarity index 100%
51 copy from frotz
52 copy to nitfol
53 diff --git a/frotz b/rezrov
54 similarity index 100%
55 rename from frotz
56 rename to rezrov
57 diff --git a/yomin b/yomin
58 deleted file mode 100644
59 --- a/yomin
60 +++ /dev/null
61 @@ -1 +0,0 @@
62 -xyzzy
63 \ No newline at end of file
64 EOF
67 test_expect_success SYMLINKS \
68 'validate diff output' \
69 'compare_diff_patch current expected'
71 test_done