]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4009-diff-rename-4.sh
Merge branch 'gc/branch-recurse-submodules-fix'
[thirdparty/git.git] / t / t4009-diff-rename-4.sh
CommitLineData
ddafa7e9
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='Same rename detection as t4003 but testing diff-raw -z.
7
8'
16d4bd4f
ÆAB
9
10TEST_PASSES_SANITIZE_LEAK=true
ddafa7e9 11. ./test-lib.sh
ebd73f50 12. "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
ddafa7e9
JH
13
14test_expect_success \
15 'prepare reference tree' \
15b808da 16 'COPYING_test_data >COPYING &&
ddafa7e9 17 echo frotz >rezrov &&
5be60078 18 git update-index --add COPYING rezrov &&
0c37c41d 19 orig=$(git hash-object COPYING) &&
5be60078 20 tree=$(git write-tree) &&
ddafa7e9
JH
21 echo $tree'
22
23test_expect_success \
24 'prepare work tree' \
25 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
26 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
27 rm -f COPYING &&
0c37c41d 28 c1=$(git hash-object COPYING.1) &&
29 c2=$(git hash-object COPYING.2) &&
5be60078 30 git update-index --add --remove COPYING COPYING.?'
ddafa7e9
JH
31
32# tree has COPYING and rezrov. work tree has COPYING.1 and COPYING.2,
33# both are slightly edited, and unchanged rezrov. We say COPYING.1
34# and COPYING.2 are based on COPYING, and do not say anything about
35# rezrov.
36
0940e5f2 37git diff-index -z -C $tree >current
ddafa7e9 38
0c37c41d 39cat >expected <<EOF
40:100644 100644 $orig $c1 C1234
ddafa7e9
JH
41COPYING
42COPYING.1
0c37c41d 43:100644 100644 $orig $c2 R1234
ddafa7e9
JH
44COPYING
45COPYING.2
46EOF
47
48test_expect_success \
49 'validate output from rename/copy detection (#1)' \
edb0c724 50 'compare_diff_raw_z current expected'
ddafa7e9 51
ddafa7e9
JH
52################################################################
53
54test_expect_success \
55 'prepare work tree again' \
56 'mv COPYING.2 COPYING &&
5be60078 57 git update-index --add --remove COPYING COPYING.1 COPYING.2'
ddafa7e9
JH
58
59# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
60# both are slightly edited, and unchanged rezrov. We say COPYING.1
61# is based on COPYING and COPYING is still there, and do not say anything
62# about rezrov.
63
5be60078 64git diff-index -z -C $tree >current
0c37c41d 65cat >expected <<EOF
66:100644 100644 $orig $c2 M
ddafa7e9 67COPYING
0c37c41d 68:100644 100644 $orig $c1 C1234
ddafa7e9
JH
69COPYING
70COPYING.1
71EOF
72
73test_expect_success \
74 'validate output from rename/copy detection (#2)' \
edb0c724 75 'compare_diff_raw_z current expected'
ddafa7e9 76
ddafa7e9
JH
77################################################################
78
79# tree has COPYING and rezrov. work tree has the same COPYING and
80# copy-edited COPYING.1, and unchanged rezrov. We should not say
235e8d59 81# anything about rezrov or COPYING, since the revised again diff-raw
ddafa7e9
JH
82# nows how to say Copy.
83
84test_expect_success \
85 'prepare work tree once again' \
15b808da 86 'COPYING_test_data >COPYING &&
5be60078 87 git update-index --add --remove COPYING COPYING.1'
ddafa7e9 88
5be60078 89git diff-index -z -C --find-copies-harder $tree >current
0c37c41d 90cat >expected <<EOF
91:100644 100644 $orig $c1 C1234
ddafa7e9
JH
92COPYING
93COPYING.1
94EOF
95
96test_expect_success \
97 'validate output from rename/copy detection (#3)' \
edb0c724 98 'compare_diff_raw_z current expected'
ddafa7e9 99
ddafa7e9 100test_done