Makefile: whitespace style fixes in macro definitions
[alt-git.git] / t / t4127-apply-same-fn.sh
blob972946c174c18ee831d8595068c6ffa235c8a538
1 #!/bin/sh
3 test_description='apply same filename'
5 . ./test-lib.sh
7 modify () {
8 sed -e "$1" < "$2" > "$2".x &&
9 mv "$2".x "$2"
12 test_expect_success setup '
13 for i in a b c d e f g h i j k l m
15 echo $i
16 done >same_fn &&
17 cp same_fn other_fn &&
18 git add same_fn other_fn &&
19 git commit -m initial
21 test_expect_success 'apply same filename with independent changes' '
22 modify "s/^d/z/" same_fn &&
23 git diff > patch0 &&
24 git add same_fn &&
25 modify "s/^i/y/" same_fn &&
26 git diff >> patch0 &&
27 cp same_fn same_fn2 &&
28 git reset --hard &&
29 git apply patch0 &&
30 test_cmp same_fn same_fn2
33 test_expect_success 'apply same filename with overlapping changes' '
34 git reset --hard &&
35 modify "s/^d/z/" same_fn &&
36 git diff > patch0 &&
37 git add same_fn &&
38 modify "s/^e/y/" same_fn &&
39 git diff >> patch0 &&
40 cp same_fn same_fn2 &&
41 git reset --hard &&
42 git apply patch0 &&
43 test_cmp same_fn same_fn2
46 test_expect_success 'apply same new filename after rename' '
47 git reset --hard &&
48 git mv same_fn new_fn &&
49 modify "s/^d/z/" new_fn &&
50 git add new_fn &&
51 git diff -M --cached > patch1 &&
52 modify "s/^e/y/" new_fn &&
53 git diff >> patch1 &&
54 cp new_fn new_fn2 &&
55 git reset --hard &&
56 git apply --index patch1 &&
57 test_cmp new_fn new_fn2
60 test_expect_success 'apply same old filename after rename -- should fail.' '
61 git reset --hard &&
62 git mv same_fn new_fn &&
63 modify "s/^d/z/" new_fn &&
64 git add new_fn &&
65 git diff -M --cached > patch1 &&
66 git mv new_fn same_fn &&
67 modify "s/^e/y/" same_fn &&
68 git diff >> patch1 &&
69 git reset --hard &&
70 test_must_fail git apply patch1
73 test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' '
74 git reset --hard &&
75 git mv same_fn new_fn &&
76 modify "s/^d/z/" new_fn &&
77 git add new_fn &&
78 git diff -M --cached > patch1 &&
79 git commit -m "a rename" &&
80 git mv other_fn same_fn &&
81 modify "s/^e/y/" same_fn &&
82 git add same_fn &&
83 git diff -M --cached >> patch1 &&
84 modify "s/^g/x/" same_fn &&
85 git diff >> patch1 &&
86 git reset --hard HEAD^ &&
87 git apply patch1
90 test_done