]>
Commit | Line | Data |
---|---|---|
6a0ebe8c JH |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2005 Junio C Hamano | |
4 | # | |
5 | ||
6 | test_description='git-apply in reverse | |
7 | ||
8 | ' | |
9 | ||
10 | . ./test-lib.sh | |
11 | ||
12 | test_expect_success setup ' | |
13 | ||
14 | for i in a b c d e f g h i j k l m n; do echo $i; done >file1 && | |
15 | tr "[ijk]" '\''[\0\1\2]'\'' <file1 >file2 && | |
16 | ||
17 | git add file1 file2 && | |
18 | git commit -m initial && | |
19 | git tag initial && | |
20 | ||
21 | for i in a b c g h i J K L m o n p q; do echo $i; done >file1 && | |
22 | tr "[mon]" '\''[\0\1\2]'\'' <file1 >file2 && | |
23 | ||
24 | git commit -a -m second && | |
2cda1a21 | 25 | git tag second && |
6a0ebe8c | 26 | |
2cda1a21 | 27 | git diff --binary initial second >patch |
6a0ebe8c JH |
28 | |
29 | ' | |
30 | ||
31 | test_expect_success 'apply in forward' ' | |
32 | ||
2cda1a21 JH |
33 | T0=`git rev-parse "second^{tree}"` && |
34 | git reset --hard initial && | |
6a0ebe8c | 35 | git apply --index --binary patch && |
2cda1a21 JH |
36 | T1=`git write-tree` && |
37 | test "$T0" = "$T1" | |
6a0ebe8c JH |
38 | ' |
39 | ||
40 | test_expect_success 'apply in reverse' ' | |
41 | ||
2cda1a21 | 42 | git reset --hard second && |
6a0ebe8c JH |
43 | git apply --reverse --binary --index patch && |
44 | git diff >diff && | |
5bd74506 | 45 | git diff /dev/null diff |
6a0ebe8c JH |
46 | |
47 | ' | |
48 | ||
2cda1a21 JH |
49 | test_expect_success 'setup separate repository lacking postimage' ' |
50 | ||
51 | git tar-tree initial initial | tar xf - && | |
52 | ( | |
5c94f87e | 53 | cd initial && git init && git add . |
2cda1a21 JH |
54 | ) && |
55 | ||
56 | git tar-tree second second | tar xf - && | |
57 | ( | |
5c94f87e | 58 | cd second && git init && git add . |
2cda1a21 JH |
59 | ) |
60 | ||
61 | ' | |
62 | ||
63 | test_expect_success 'apply in forward without postimage' ' | |
64 | ||
65 | T0=`git rev-parse "second^{tree}"` && | |
66 | ( | |
67 | cd initial && | |
68 | git apply --index --binary ../patch && | |
69 | T1=`git write-tree` && | |
70 | test "$T0" = "$T1" | |
71 | ) | |
72 | ' | |
73 | ||
74 | test_expect_success 'apply in reverse without postimage' ' | |
75 | ||
76 | T0=`git rev-parse "initial^{tree}"` && | |
77 | ( | |
78 | cd second && | |
79 | git apply --index --binary --reverse ../patch && | |
80 | T1=`git write-tree` && | |
81 | test "$T0" = "$T1" | |
82 | ) | |
83 | ' | |
84 | ||
6a0ebe8c | 85 | test_done |