]>
Commit | Line | Data |
---|---|---|
975b31dc JS |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Johannes Schindelin | |
4 | # | |
5 | ||
6 | test_description='Test diff of symlinks. | |
7 | ||
8 | ' | |
9 | . ./test-lib.sh | |
bfdbee98 | 10 | . "$TEST_DIRECTORY"/diff-lib.sh |
975b31dc | 11 | |
704a3143 JS |
12 | if ! test_have_prereq SYMLINKS |
13 | then | |
14 | say 'Symbolic links not supported, skipping tests.' | |
15 | test_done | |
16 | exit | |
17 | fi | |
18 | ||
975b31dc JS |
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 | |
29 | ||
30 | test_expect_success \ | |
31 | 'diff new symlink' \ | |
32 | 'ln -s xyzzy frotz && | |
5be60078 JH |
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 && | |
975b31dc JS |
37 | compare_diff_patch current expected' |
38 | ||
39 | test_expect_success \ | |
40 | 'diff unchanged symlink' \ | |
5be60078 JH |
41 | 'tree=$(git write-tree) && |
42 | git update-index frotz && | |
43 | test -z "$(git diff-index --name-only $tree)"' | |
975b31dc JS |
44 | |
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 | |
55 | ||
56 | test_expect_success \ | |
57 | 'diff removed symlink' \ | |
58 | 'rm frotz && | |
5be60078 | 59 | git diff-index -M -p $tree > current && |
975b31dc JS |
60 | compare_diff_patch current expected' |
61 | ||
62 | cat > expected << EOF | |
63 | diff --git a/frotz b/frotz | |
64 | EOF | |
65 | ||
66 | test_expect_success \ | |
67 | 'diff identical, but newly created symlink' \ | |
5df9140c | 68 | 'sleep 3 && |
975b31dc | 69 | ln -s xyzzy frotz && |
5be60078 | 70 | git diff-index -M -p $tree > current && |
975b31dc JS |
71 | compare_diff_patch current expected' |
72 | ||
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 | |
84 | ||
85 | test_expect_success \ | |
86 | 'diff different symlink' \ | |
87 | 'rm frotz && | |
88 | ln -s yxyyz frotz && | |
5be60078 | 89 | git diff-index -M -p $tree > current && |
975b31dc JS |
90 | compare_diff_patch current expected' |
91 | ||
418566b6 JS |
92 | test_expect_success \ |
93 | 'diff symlinks with non-existing targets' \ | |
94 | 'ln -s narf pinky && | |
95 | ln -s take\ over brain && | |
96 | test_must_fail git diff --no-index pinky brain > output 2> output.err && | |
97 | grep narf output && | |
98 | ! grep error output.err' | |
975b31dc | 99 | test_done |