Git 1.7.0.7
[git/mingw/4msysgit/kblees.git] / t / t4011-diff-symlink.sh
blobd7e327cc5bc5984546032fb085fb581de5755e11
1 #!/bin/sh
3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test diff of symlinks.
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/diff-lib.sh
12 if ! test_have_prereq SYMLINKS
13 then
14 say 'Symbolic links not supported, skipping tests.'
15 test_done
18 cat > expected << EOF
19 diff --git a/frotz b/frotz
20 new file mode 120000
21 index 0000000..7c465af
22 --- /dev/null
23 +++ b/frotz
24 @@ -0,0 +1 @@
25 +xyzzy
26 \ No newline at end of file
27 EOF
29 test_expect_success \
30 'diff new symlink' \
31 'ln -s xyzzy frotz &&
32 git update-index &&
33 tree=$(git write-tree) &&
34 git update-index --add frotz &&
35 GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree > current &&
36 compare_diff_patch current expected'
38 test_expect_success \
39 'diff unchanged symlink' \
40 'tree=$(git write-tree) &&
41 git update-index frotz &&
42 test -z "$(git diff-index --name-only $tree)"'
44 cat > expected << EOF
45 diff --git a/frotz b/frotz
46 deleted file mode 120000
47 index 7c465af..0000000
48 --- a/frotz
49 +++ /dev/null
50 @@ -1 +0,0 @@
51 -xyzzy
52 \ No newline at end of file
53 EOF
55 test_expect_success \
56 'diff removed symlink' \
57 'rm frotz &&
58 git diff-index -M -p $tree > current &&
59 compare_diff_patch current expected'
61 cat > expected << EOF
62 diff --git a/frotz b/frotz
63 EOF
65 test_expect_success \
66 'diff identical, but newly created symlink' \
67 'sleep 3 &&
68 ln -s xyzzy frotz &&
69 git diff-index -M -p $tree > current &&
70 compare_diff_patch current expected'
72 cat > expected << EOF
73 diff --git a/frotz b/frotz
74 index 7c465af..df1db54 120000
75 --- a/frotz
76 +++ b/frotz
77 @@ -1 +1 @@
78 -xyzzy
79 \ No newline at end of file
80 +yxyyz
81 \ No newline at end of file
82 EOF
84 test_expect_success \
85 'diff different symlink' \
86 'rm frotz &&
87 ln -s yxyyz frotz &&
88 git diff-index -M -p $tree > current &&
89 compare_diff_patch current expected'
91 test_expect_success \
92 'diff symlinks with non-existing targets' \
93 'ln -s narf pinky &&
94 ln -s take\ over brain &&
95 test_must_fail git diff --no-index pinky brain > output 2> output.err &&
96 grep narf output &&
97 ! grep error output.err'
98 test_done