]>
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 | |
fadb5156 | 14 | skip_all='Symbolic links not supported, skipping tests.' |
704a3143 | 15 | test_done |
704a3143 JS |
16 | fi |
17 | ||
975b31dc JS |
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 | |
28 | ||
29 | test_expect_success \ | |
30 | 'diff new symlink' \ | |
31 | 'ln -s xyzzy frotz && | |
5be60078 JH |
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 && | |
975b31dc JS |
36 | compare_diff_patch current expected' |
37 | ||
38 | test_expect_success \ | |
39 | 'diff unchanged symlink' \ | |
5be60078 JH |
40 | 'tree=$(git write-tree) && |
41 | git update-index frotz && | |
42 | test -z "$(git diff-index --name-only $tree)"' | |
975b31dc JS |
43 | |
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 | |
54 | ||
55 | test_expect_success \ | |
56 | 'diff removed symlink' \ | |
016e5ff2 | 57 | 'mv frotz frotz2 && |
5be60078 | 58 | git diff-index -M -p $tree > current && |
975b31dc JS |
59 | compare_diff_patch current expected' |
60 | ||
61 | cat > expected << EOF | |
62 | diff --git a/frotz b/frotz | |
63 | EOF | |
64 | ||
65 | test_expect_success \ | |
66 | 'diff identical, but newly created symlink' \ | |
016e5ff2 | 67 | 'ln -s xyzzy frotz && |
5be60078 | 68 | git diff-index -M -p $tree > current && |
975b31dc JS |
69 | compare_diff_patch current expected' |
70 | ||
71 | cat > expected << EOF | |
72 | diff --git a/frotz b/frotz | |
73 | index 7c465af..df1db54 120000 | |
74 | --- a/frotz | |
75 | +++ b/frotz | |
76 | @@ -1 +1 @@ | |
77 | -xyzzy | |
78 | \ No newline at end of file | |
79 | +yxyyz | |
80 | \ No newline at end of file | |
81 | EOF | |
82 | ||
83 | test_expect_success \ | |
84 | 'diff different symlink' \ | |
85 | 'rm frotz && | |
86 | ln -s yxyyz frotz && | |
5be60078 | 87 | git diff-index -M -p $tree > current && |
975b31dc JS |
88 | compare_diff_patch current expected' |
89 | ||
418566b6 JS |
90 | test_expect_success \ |
91 | 'diff symlinks with non-existing targets' \ | |
92 | 'ln -s narf pinky && | |
93 | ln -s take\ over brain && | |
94 | test_must_fail git diff --no-index pinky brain > output 2> output.err && | |
95 | grep narf output && | |
96 | ! grep error output.err' | |
975b31dc | 97 | test_done |