git hook run: add an --ignore-missing flag
[alt-git.git] / t / t4009-diff-rename-4.sh
blob3480781dabf30aca2a01c40a1ab34eb1e075eccc
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Same rename detection as t4003 but testing diff-raw -z.
10 TEST_PASSES_SANITIZE_LEAK=true
11 . ./test-lib.sh
12 . "$TEST_DIRECTORY"/lib-diff.sh ;# test-lib chdir's into trash
14 test_expect_success \
15 'prepare reference tree' \
16 'COPYING_test_data >COPYING &&
17 echo frotz >rezrov &&
18 git update-index --add COPYING rezrov &&
19 orig=$(git hash-object COPYING) &&
20 tree=$(git write-tree) &&
21 echo $tree'
23 test_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 &&
28 c1=$(git hash-object COPYING.1) &&
29 c2=$(git hash-object COPYING.2) &&
30 git update-index --add --remove COPYING COPYING.?'
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.
37 git diff-index -z -C $tree >current
39 cat >expected <<EOF
40 :100644 100644 $orig $c1 C1234
41 COPYING
42 COPYING.1
43 :100644 100644 $orig $c2 R1234
44 COPYING
45 COPYING.2
46 EOF
48 test_expect_success \
49 'validate output from rename/copy detection (#1)' \
50 'compare_diff_raw_z current expected'
52 ################################################################
54 test_expect_success \
55 'prepare work tree again' \
56 'mv COPYING.2 COPYING &&
57 git update-index --add --remove COPYING COPYING.1 COPYING.2'
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.
64 git diff-index -z -C $tree >current
65 cat >expected <<EOF
66 :100644 100644 $orig $c2 M
67 COPYING
68 :100644 100644 $orig $c1 C1234
69 COPYING
70 COPYING.1
71 EOF
73 test_expect_success \
74 'validate output from rename/copy detection (#2)' \
75 'compare_diff_raw_z current expected'
77 ################################################################
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
81 # anything about rezrov or COPYING, since the revised again diff-raw
82 # nows how to say Copy.
84 test_expect_success \
85 'prepare work tree once again' \
86 'COPYING_test_data >COPYING &&
87 git update-index --add --remove COPYING COPYING.1'
89 git diff-index -z -C --find-copies-harder $tree >current
90 cat >expected <<EOF
91 :100644 100644 $orig $c1 C1234
92 COPYING
93 COPYING.1
94 EOF
96 test_expect_success \
97 'validate output from rename/copy detection (#3)' \
98 'compare_diff_raw_z current expected'
100 test_done