3 # Copyright (c) 2005 Junio C Hamano
6 test_description
='git apply in reverse
12 test_expect_success setup
'
14 for i in a b c d e f g h i j k l m n; do echo $i; done >file1 &&
15 perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
17 git add file1 file2 &&
18 git commit -m initial &&
21 for i in a b c g h i J K L m o n p q; do echo $i; done >file1 &&
22 perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
24 git commit -a -m second &&
27 git diff --binary initial second >patch
31 test_expect_success
'apply in forward' '
33 T0=`git rev-parse "second^{tree}"` &&
34 git reset --hard initial &&
35 git apply --index --binary patch &&
36 T1=`git write-tree` &&
40 test_expect_success
'apply in reverse' '
42 git reset --hard second &&
43 git apply --reverse --binary --index patch &&
50 test_expect_success
'setup separate repository lacking postimage' '
52 git tar-tree initial initial | $TAR xf - &&
54 cd initial && git init && git add .
57 git tar-tree second second | $TAR xf - &&
59 cd second && git init && git add .
64 test_expect_success
'apply in forward without postimage' '
66 T0=`git rev-parse "second^{tree}"` &&
69 git apply --index --binary ../patch &&
70 T1=`git write-tree` &&
75 test_expect_success
'apply in reverse without postimage' '
77 T0=`git rev-parse "initial^{tree}"` &&
80 git apply --index --binary --reverse ../patch &&
81 T1=`git write-tree` &&
86 test_expect_success
'reversing a whitespace introduction' '
87 sed "s/a/a /" < file1 > file1.new &&
89 git diff | git apply --reverse --whitespace=error