summaryrefslogtreecommitdiff
path: root/t/t4004-diff-rename-symlink.sh
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-05-23 04:24:49 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-23 18:49:30 (GMT)
commit60896c7bfed67f1c7364595213ef9239642f83c5 (patch)
tree01c56ae444ab86d7df74664e04ac4d55e9658791 /t/t4004-diff-rename-symlink.sh
parentc1bb93502012b710ec5a31dff62d4aca7bf51adc (diff)
downloadgit-60896c7bfed67f1c7364595213ef9239642f83c5.zip
git-60896c7bfed67f1c7364595213ef9239642f83c5.tar.gz
git-60896c7bfed67f1c7364595213ef9239642f83c5.tar.bz2
[PATCH] Be careful with symlinks when detecting renames and copies.
Earlier round was not treating symbolic links carefully enough, and would have produced diff output that renamed/copied then edited the contents of a symbolic link, which made no practical sense. Change it to detect only pure renames. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 't/t4004-diff-rename-symlink.sh')
-rw-r--r--t/t4004-diff-rename-symlink.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh
new file mode 100644
index 0000000..31fdc50
--- /dev/null
+++ b/t/t4004-diff-rename-symlink.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+#
+# Copyright (c) 2005 Junio C Hamano
+#
+
+test_description='More rename detection tests.
+
+The rename detection logic should be able to detect pure rename or
+copy of symbolic links, but should not produce rename/copy followed
+by an edit for them.
+'
+. ./test-lib.sh
+
+test_expect_success \
+ 'prepare reference tree' \
+ 'echo xyzzy | tr -d '\\\\'012 >yomin &&
+ ln -s xyzzy frotz &&
+ git-update-cache --add frotz yomin &&
+ tree=$(git-write-tree) &&
+ echo $tree'
+
+test_expect_success \
+ 'prepare work tree' \
+ 'mv frotz rezrov &&
+ rm -f yomin &&
+ ln -s xyzzy nitfol &&
+ ln -s xzzzy bozbar &&
+ git-update-cache --add --remove frotz rezrov nitfol bozbar yomin'
+
+# tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
+# confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and
+# bozbar (xzzzy).
+# rezrov and nitfol are rename/copy of frotz and bozbar should be
+# a new creation.
+
+GIT_DIFF_OPTS=--unified=0 git-diff-cache -M -p $tree >current
+cat >expected <<\EOF
+diff --git a/frotz b/nitfol
+similarity index 100%
+copy from frotz
+copy to nitfol
+diff --git a/frotz b/rezrov
+similarity index 100%
+rename old frotz
+rename new rezrov
+diff --git a/yomin b/yomin
+deleted file mode 100644
+--- a/yomin
++++ /dev/null
+@@ -1 +0,0 @@
+-xyzzy
+\ No newline at end of file
+diff --git a/bozbar b/bozbar
+new file mode 120000
+--- /dev/null
++++ b/bozbar
+@@ -0,0 +1 @@
++xzzzy
+\ No newline at end of file
+EOF
+
+test_expect_success \
+ 'validate diff output' \
+ 'diff -u current expected'
+
+test_done