blob: 6e562c80d12f9f58353c8f6444c0d7a0737dbae4 [file] [log] [blame]
Junio C Hamano60896c72005-05-22 21:24:49 -07001#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='More rename detection tests.
7
8The rename detection logic should be able to detect pure rename or
9copy of symbolic links, but should not produce rename/copy followed
10by an edit for them.
11'
12. ./test-lib.sh
Junio C Hamanobfdbee92008-08-08 02:26:28 -070013. "$TEST_DIRECTORY"/diff-lib.sh
Junio C Hamano60896c72005-05-22 21:24:49 -070014
Ævar Arnfjörð Bjarmasonf6c19982010-07-28 10:34:56 +000015test_expect_success SYMLINKS \
Junio C Hamano60896c72005-05-22 21:24:49 -070016 'prepare reference tree' \
17 'echo xyzzy | tr -d '\\\\'012 >yomin &&
18 ln -s xyzzy frotz &&
Junio C Hamano5be60072007-07-02 22:52:14 -070019 git update-index --add frotz yomin &&
20 tree=$(git write-tree) &&
Junio C Hamano60896c72005-05-22 21:24:49 -070021 echo $tree'
22
Ævar Arnfjörð Bjarmasonf6c19982010-07-28 10:34:56 +000023test_expect_success SYMLINKS \
Junio C Hamano60896c72005-05-22 21:24:49 -070024 'prepare work tree' \
25 'mv frotz rezrov &&
26 rm -f yomin &&
27 ln -s xyzzy nitfol &&
28 ln -s xzzzy bozbar &&
Junio C Hamano5be60072007-07-02 22:52:14 -070029 git update-index --add --remove frotz rezrov nitfol bozbar yomin'
Junio C Hamano60896c72005-05-22 21:24:49 -070030
31# tree has frotz pointing at xyzzy, and yomin that contains xyzzy to
32# confuse things. work tree has rezrov (xyzzy) nitfol (xyzzy) and
33# bozbar (xzzzy).
34# rezrov and nitfol are rename/copy of frotz and bozbar should be
35# a new creation.
36
Ævar Arnfjörð Bjarmasonf6c19982010-07-28 10:34:56 +000037test_expect_success SYMLINKS 'setup diff output' "
Linus Torvalds0940e5f2011-02-18 20:10:32 -080038 GIT_DIFF_OPTS=--unified=0 git diff-index -C -p $tree >current &&
Ævar Arnfjörð Bjarmasonf6c19982010-07-28 10:34:56 +000039 cat >expected <<\EOF
Junio C Hamano25d5ea42005-05-24 01:10:48 -070040diff --git a/bozbar b/bozbar
41new file mode 120000
42--- /dev/null
43+++ b/bozbar
44@@ -0,0 +1 @@
45+xzzzy
46\ No newline at end of file
Junio C Hamano60896c72005-05-22 21:24:49 -070047diff --git a/frotz b/nitfol
48similarity index 100%
49copy from frotz
50copy to nitfol
51diff --git a/frotz b/rezrov
52similarity index 100%
Linus Torvaldsdc938412005-06-05 15:31:52 -070053rename from frotz
54rename to rezrov
Junio C Hamano60896c72005-05-22 21:24:49 -070055diff --git a/yomin b/yomin
56deleted file mode 100644
57--- a/yomin
58+++ /dev/null
59@@ -1 +0,0 @@
60-xyzzy
61\ No newline at end of file
Junio C Hamano60896c72005-05-22 21:24:49 -070062EOF
Ævar Arnfjörð Bjarmasonf6c19982010-07-28 10:34:56 +000063"
Junio C Hamano60896c72005-05-22 21:24:49 -070064
Ævar Arnfjörð Bjarmasonf6c19982010-07-28 10:34:56 +000065test_expect_success SYMLINKS \
Junio C Hamano60896c72005-05-22 21:24:49 -070066 'validate diff output' \
Junio C Hamanoec1fcc12005-10-07 03:42:00 -070067 'compare_diff_patch current expected'
Junio C Hamano60896c72005-05-22 21:24:49 -070068
69test_done