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