Code

[PATCH] Rename/copy detection fix.
[git.git] / t / t4005-diff-rename-2.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2005 Junio C Hamano
4 #
6 test_description='Same rename detection as t4003 but testing diff-raw.
8 '
9 . ./test-lib.sh
11 test_expect_success \
12     'prepare reference tree' \
13     'cat ../../COPYING >COPYING &&
14      echo frotz >rezrov &&
15     git-update-cache --add COPYING rezrov &&
16     tree=$(git-write-tree) &&
17     echo $tree'
19 test_expect_success \
20     'prepare work tree' \
21     'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
22     sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
23     rm -f COPYING &&
24     git-update-cache --add --remove COPYING COPYING.?'
26 # tree has COPYING and rezrov.  work tree has COPYING.1 and COPYING.2,
27 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
28 # and COPYING.2 are based on COPYING, and do not say anything about
29 # rezrov.
31 git-diff-cache -M $tree >current
33 cat >expected <<\EOF
34 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178        COPYING COPYING.1
35 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471        COPYING COPYING.2
36 EOF
38 test_expect_success \
39     'validate output from rename/copy detection' \
40     'diff -u current expected'
42 test_expect_success \
43     'prepare work tree again' \
44     'mv COPYING.2 COPYING &&
45      git-update-cache --add --remove COPYING COPYING.1 COPYING.2'
47 # tree has COPYING and rezrov.  work tree has COPYING and COPYING.1,
48 # both are slightly edited, and unchanged rezrov.  We say COPYING.1
49 # is based on COPYING and COPYING is still there, and do not say anything
50 # about rezrov.
52 git-diff-cache -C $tree >current
53 cat >expected <<\EOF
54 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178        COPYING COPYING.1
55 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471        COPYING COPYING
56 EOF
58 test_expect_success \
59     'validate output from rename/copy detection' \
60     'diff -u current expected'
62 test_expect_success \
63     'prepare work tree once again' \
64     'cat ../../COPYING >COPYING &&
65      git-update-cache --add --remove COPYING COPYING.1'
67 # tree has COPYING and rezrov.  work tree has the same COPYING and
68 # copy-edited COPYING.1, and unchanged rezrov.  We should see
69 # unmodified COPYING in the output, so that downstream diff-helper can
70 # notice.  We should not say anything about rezrov.
72 git-diff-cache -C $tree >current
73 cat >expected <<\EOF
74 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178        COPYING COPYING.1
75 :100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3        COPYING COPYING
76 EOF
78 test_expect_success \
79     'validate output from rename/copy detection' \
80     'diff -u current expected'
82 test_done