mirror of
https://github.com/git/git.git
synced 2024-11-01 14:57:52 +01:00
704a3143d5
Many tests depend on that symbolic links work. This introduces a check that sets the prerequisite tag SYMLINKS if the file system supports symbolic links. Since so many tests have to check for this prerequisite, we do the check in test-lib.sh, so that we don't need to repeat the test in many scripts. To check for 'ln -s' failures, you can use a FAT partition on Linux: $ mkdosfs -C git-on-fat 1000000 $ sudo mount -o loop,uid=j6t,gid=users,shortname=winnt git-on-fat /mnt Clone git to /mnt and $ GIT_SKIP_TESTS='t0001.1[34] t0010 t1301 t403[34] t4129.[47] t5701.7 t7701.3 t9100 t9101.26 t9119 t9124.[67] t9200.10 t9600.6' \ make test (These additionally skipped tests depend on POSIX permissions that FAT on Linux does not provide.) Signed-off-by: Johannes Sixt <j6t@kdbg.org>
99 lines
2 KiB
Bash
Executable file
99 lines
2 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2005 Johannes Schindelin
|
|
#
|
|
|
|
test_description='Test diff of symlinks.
|
|
|
|
'
|
|
. ./test-lib.sh
|
|
. "$TEST_DIRECTORY"/diff-lib.sh
|
|
|
|
if ! test_have_prereq SYMLINKS
|
|
then
|
|
say 'Symbolic links not supported, skipping tests.'
|
|
test_done
|
|
exit
|
|
fi
|
|
|
|
cat > expected << EOF
|
|
diff --git a/frotz b/frotz
|
|
new file mode 120000
|
|
index 0000000..7c465af
|
|
--- /dev/null
|
|
+++ b/frotz
|
|
@@ -0,0 +1 @@
|
|
+xyzzy
|
|
\ No newline at end of file
|
|
EOF
|
|
|
|
test_expect_success \
|
|
'diff new symlink' \
|
|
'ln -s xyzzy frotz &&
|
|
git update-index &&
|
|
tree=$(git write-tree) &&
|
|
git update-index --add frotz &&
|
|
GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree > current &&
|
|
compare_diff_patch current expected'
|
|
|
|
test_expect_success \
|
|
'diff unchanged symlink' \
|
|
'tree=$(git write-tree) &&
|
|
git update-index frotz &&
|
|
test -z "$(git diff-index --name-only $tree)"'
|
|
|
|
cat > expected << EOF
|
|
diff --git a/frotz b/frotz
|
|
deleted file mode 120000
|
|
index 7c465af..0000000
|
|
--- a/frotz
|
|
+++ /dev/null
|
|
@@ -1 +0,0 @@
|
|
-xyzzy
|
|
\ No newline at end of file
|
|
EOF
|
|
|
|
test_expect_success \
|
|
'diff removed symlink' \
|
|
'rm frotz &&
|
|
git diff-index -M -p $tree > current &&
|
|
compare_diff_patch current expected'
|
|
|
|
cat > expected << EOF
|
|
diff --git a/frotz b/frotz
|
|
EOF
|
|
|
|
test_expect_success \
|
|
'diff identical, but newly created symlink' \
|
|
'sleep 3 &&
|
|
ln -s xyzzy frotz &&
|
|
git diff-index -M -p $tree > current &&
|
|
compare_diff_patch current expected'
|
|
|
|
cat > expected << EOF
|
|
diff --git a/frotz b/frotz
|
|
index 7c465af..df1db54 120000
|
|
--- a/frotz
|
|
+++ b/frotz
|
|
@@ -1 +1 @@
|
|
-xyzzy
|
|
\ No newline at end of file
|
|
+yxyyz
|
|
\ No newline at end of file
|
|
EOF
|
|
|
|
test_expect_success \
|
|
'diff different symlink' \
|
|
'rm frotz &&
|
|
ln -s yxyyz frotz &&
|
|
git diff-index -M -p $tree > current &&
|
|
compare_diff_patch current expected'
|
|
|
|
test_expect_success \
|
|
'diff symlinks with non-existing targets' \
|
|
'ln -s narf pinky &&
|
|
ln -s take\ over brain &&
|
|
test_must_fail git diff --no-index pinky brain > output 2> output.err &&
|
|
grep narf output &&
|
|
! grep error output.err'
|
|
test_done
|