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