Git fork
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Same rename detection as t4003 but testing diff-raw.'
7
8
9. ./test-lib.sh
10. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
11
12test_expect_success 'setup reference tree' '
13 COPYING_test_data >COPYING &&
14 echo frotz >rezrov &&
15 git update-index --add COPYING rezrov &&
16 tree=$(git write-tree) &&
17 echo $tree &&
18 sed -e "s/HOWEVER/However/" <COPYING >COPYING.1 &&
19 sed -e "s/GPL/G.P.L/g" <COPYING >COPYING.2 &&
20 origoid=$(git hash-object COPYING) &&
21 oid1=$(git hash-object COPYING.1) &&
22 oid2=$(git hash-object COPYING.2)
23'
24
25################################################################
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.
30
31test_expect_success 'validate output from rename/copy detection (#1)' '
32 rm -f COPYING &&
33 git update-index --add --remove COPYING COPYING.? &&
34
35 cat <<-EOF >expected &&
36 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
37 :100644 100644 $origoid $oid2 R1234 COPYING COPYING.2
38 EOF
39 git diff-index -C $tree >current &&
40 compare_diff_raw expected current
41'
42
43################################################################
44# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
45# both are slightly edited, and unchanged rezrov. We say COPYING.1
46# is based on COPYING and COPYING is still there, and do not say anything
47# about rezrov.
48
49test_expect_success 'validate output from rename/copy detection (#2)' '
50 mv COPYING.2 COPYING &&
51 git update-index --add --remove COPYING COPYING.1 COPYING.2 &&
52
53 cat <<-EOF >expected &&
54 :100644 100644 $origoid $oid2 M COPYING
55 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
56 EOF
57 git diff-index -C $tree >current &&
58 compare_diff_raw current expected
59'
60
61################################################################
62# tree has COPYING and rezrov. work tree has the same COPYING and
63# copy-edited COPYING.1, and unchanged rezrov. We should not say
64# anything about rezrov or COPYING, since the revised again diff-raw
65# nows how to say Copy.
66
67test_expect_success 'validate output from rename/copy detection (#3)' '
68 COPYING_test_data >COPYING &&
69 git update-index --add --remove COPYING COPYING.1 &&
70
71 cat <<-EOF >expected &&
72 :100644 100644 $origoid $oid1 C1234 COPYING COPYING.1
73 EOF
74 git diff-index -C --find-copies-harder $tree >current &&
75 compare_diff_raw current expected
76'
77
78test_done