]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4009-diff-rename-4.sh
for_each_hash: allow passing a 'void *data' pointer to callback
[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'
9. ./test-lib.sh
bfdbee98 10. "$TEST_DIRECTORY"/diff-lib.sh ;# test-lib chdir's into trash
ddafa7e9
JH
11
12test_expect_success \
13 'prepare reference tree' \
bfdbee98 14 'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
ddafa7e9 15 echo frotz >rezrov &&
5be60078
JH
16 git update-index --add COPYING rezrov &&
17 tree=$(git write-tree) &&
ddafa7e9
JH
18 echo $tree'
19
20test_expect_success \
21 'prepare work tree' \
22 'sed -e 's/HOWEVER/However/' <COPYING >COPYING.1 &&
23 sed -e 's/GPL/G.P.L/g' <COPYING >COPYING.2 &&
24 rm -f COPYING &&
5be60078 25 git update-index --add --remove COPYING COPYING.?'
ddafa7e9
JH
26
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
5be60078 32git diff-index -z -M $tree >current
ddafa7e9
JH
33
34cat >expected <<\EOF
35:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
36COPYING
37COPYING.1
38:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 R1234
39COPYING
40COPYING.2
41EOF
42
43test_expect_success \
44 'validate output from rename/copy detection (#1)' \
edb0c724 45 'compare_diff_raw_z current expected'
ddafa7e9 46
ddafa7e9
JH
47################################################################
48
49test_expect_success \
50 'prepare work tree again' \
51 'mv COPYING.2 COPYING &&
5be60078 52 git update-index --add --remove COPYING COPYING.1 COPYING.2'
ddafa7e9
JH
53
54# tree has COPYING and rezrov. work tree has COPYING and COPYING.1,
55# both are slightly edited, and unchanged rezrov. We say COPYING.1
56# is based on COPYING and COPYING is still there, and do not say anything
57# about rezrov.
58
5be60078 59git diff-index -z -C $tree >current
ddafa7e9
JH
60cat >expected <<\EOF
61:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 06c67961bbaed34a127f76d261f4c0bf73eda471 M
62COPYING
63:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
64COPYING
65COPYING.1
66EOF
67
68test_expect_success \
69 'validate output from rename/copy detection (#2)' \
edb0c724 70 'compare_diff_raw_z current expected'
ddafa7e9 71
ddafa7e9
JH
72################################################################
73
74# tree has COPYING and rezrov. work tree has the same COPYING and
75# copy-edited COPYING.1, and unchanged rezrov. We should not say
76# anything about rezrov nor COPYING, since the revised again diff-raw
77# nows how to say Copy.
78
79test_expect_success \
80 'prepare work tree once again' \
bfdbee98 81 'cat "$TEST_DIRECTORY"/../COPYING >COPYING &&
5be60078 82 git update-index --add --remove COPYING COPYING.1'
ddafa7e9 83
5be60078 84git diff-index -z -C --find-copies-harder $tree >current
ddafa7e9
JH
85cat >expected <<\EOF
86:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
87COPYING
88COPYING.1
89EOF
90
91test_expect_success \
92 'validate output from rename/copy detection (#3)' \
edb0c724 93 'compare_diff_raw_z current expected'
ddafa7e9 94
ddafa7e9 95test_done