diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2010-04-29 03:02:58 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2010-05-02 11:44:00 +0200 |
commit | f9db7450fa2788377c4567b5d0565b0ddfc1015c (patch) | |
tree | 25566a3297ecb1f664ed976946848f8ae4c8d178 /tests/symlinks | |
parent | 12fdbd5cec18539bd87cc89e5a917afeea831631 (diff) | |
download | patch-f9db7450fa2788377c4567b5d0565b0ddfc1015c.tar.gz |
git diffs: Support symlinks
* src/patch.c (main): Support git symlink diffs.
* tests/symlinks: Add git symlink diff test cases.
Diffstat (limited to 'tests/symlinks')
-rw-r--r-- | tests/symlinks | 104 |
1 files changed, 103 insertions, 1 deletions
diff --git a/tests/symlinks b/tests/symlinks index 3472791..6665028 100644 --- a/tests/symlinks +++ b/tests/symlinks @@ -73,4 +73,106 @@ File l is not a regular file -- can't patch Status: 1 EOF -# FIXME: Add tests for backup / reject file clashes with symlinks +# -------------------------------------------------------------- + +cat > create-symlink.diff <<EOF +diff --git a/symlink b/symlink +new file mode 120000 +index 0000000..12a8d8a +--- /dev/null ++++ b/symlink +@@ -0,0 +1 @@ ++target1 +\ No newline at end of file +EOF + +check 'patch -p1 < create-symlink.diff || echo "Status: $?"' <<EOF +patching symbolic link symlink +EOF + +check 'echo a > target1 && cat symlink' <<EOF +a +EOF +check 'echo b > target1 && cat symlink' <<EOF +b +EOF +rm -f target1 + +cat > modify-symlink.diff <<EOF +diff --git a/symlink b/symlink +index 12a8d8a..3b7781e 120000 +--- a/symlink ++++ b/symlink +@@ -1 +1 @@ +-target1 +\ No newline at end of file ++target2 +\ No newline at end of file +EOF + +check 'patch -p1 < modify-symlink.diff || echo "Status: $?"' <<EOF +patching symbolic link symlink +EOF + +check 'echo a > target2 && cat symlink' <<EOF +a +EOF +check 'echo b > target2 && cat symlink' <<EOF +b +EOF +rm -f target2 + +cat > delete-symlink.diff <<EOF +diff --git a/symlink b/symlink +deleted file mode 120000 +index 3b7781e..0000000 +--- a/symlink ++++ /dev/null +@@ -1 +0,0 @@ +-target2 +\ No newline at end of file +EOF + +check 'patch -p1 < delete-symlink.diff || echo "Status: $?"' <<EOF +patching symbolic link symlink +EOF + +ncheck 'test ! -e symlink' + +# -------------------------------------------------------------- + +# The backup file of a new symlink is an empty regular file. + +check 'patch -p1 --backup < create-symlink.diff || echo "Status: $?"' <<EOF +patching symbolic link symlink +EOF + +ncheck 'test ! \( -L symlink.orig -o -s symlink.orig \)' + +# The backup file of a modified symlink is the old symlink. + +check 'patch -p1 --backup < modify-symlink.diff || echo "Status: $?"' <<EOF +patching symbolic link symlink +EOF + +check 'echo a > symlink.orig && cat target1' <<EOF +a +EOF +check 'echo b > symlink.orig && cat target1' <<EOF +b +EOF +rm -f target1 + +# The backup file of a deleted symlink is the old symlink. + +check 'patch -p1 --backup < delete-symlink.diff || echo "Status: $?"' <<EOF +patching symbolic link symlink +EOF + +check 'echo a > symlink.orig && cat target2' <<EOF +a +EOF +check 'echo b > symlink.orig && cat target2' <<EOF +b +EOF +rm -f target2 |