Windows ANSI - hook write()
[git/mingw/4msysgit/peterh.git] / t / t4011-diff-symlink.sh
blob6409d69c39d1dc787ae9893cf33fb46670e7b24a
1 #!/bin/sh
3 # Copyright (c) 2005 Johannes Schindelin
6 test_description='Test diff of symlinks.
9 . ./test-lib.sh
10 . ../diff-lib.sh
12 if test "$no_symlinks"
13 then
14 say 'Symbolic links not supported, skipping tests.'
15 test_done
16 exit
19 cat > expected << EOF
20 diff --git a/frotz b/frotz
21 new file mode 120000
22 index 0000000..7c465af
23 --- /dev/null
24 +++ b/frotz
25 @@ -0,0 +1 @@
26 +xyzzy
27 \ No newline at end of file
28 EOF
30 test_expect_success \
31 'diff new symlink' \
32 'ln -s xyzzy frotz &&
33 git update-index &&
34 tree=$(git write-tree) &&
35 git update-index --add frotz &&
36 GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree > current &&
37 compare_diff_patch current expected'
39 test_expect_success \
40 'diff unchanged symlink' \
41 'tree=$(git write-tree) &&
42 git update-index frotz &&
43 test -z "$(git diff-index --name-only $tree)"'
45 cat > expected << EOF
46 diff --git a/frotz b/frotz
47 deleted file mode 120000
48 index 7c465af..0000000
49 --- a/frotz
50 +++ /dev/null
51 @@ -1 +0,0 @@
52 -xyzzy
53 \ No newline at end of file
54 EOF
56 test_expect_success \
57 'diff removed symlink' \
58 'rm frotz &&
59 git diff-index -M -p $tree > current &&
60 compare_diff_patch current expected'
62 cat > expected << EOF
63 diff --git a/frotz b/frotz
64 EOF
66 test_expect_success \
67 'diff identical, but newly created symlink' \
68 'sleep 3 &&
69 ln -s xyzzy frotz &&
70 git diff-index -M -p $tree > current &&
71 compare_diff_patch current expected'
73 cat > expected << EOF
74 diff --git a/frotz b/frotz
75 index 7c465af..df1db54 120000
76 --- a/frotz
77 +++ b/frotz
78 @@ -1 +1 @@
79 -xyzzy
80 \ No newline at end of file
81 +yxyyz
82 \ No newline at end of file
83 EOF
85 test_expect_success \
86 'diff different symlink' \
87 'rm frotz &&
88 ln -s yxyyz frotz &&
89 git diff-index -M -p $tree > current &&
90 compare_diff_patch current expected'
92 test_done