]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4117-apply-reject.sh
git-apply --reject: send rejects to .rej files.
[thirdparty/git.git] / t / t4117-apply-reject.sh
CommitLineData
57dc397c
JH
1#!/bin/sh
2#
3# Copyright (c) 2005 Junio C Hamano
4#
5
6test_description='git-apply with rejects
7
8'
9
10. ./test-lib.sh
11
12test_expect_success setup '
13 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
14 do
15 echo $i
16 done >file1 &&
17 cat file1 >saved.file1 &&
18 git update-index --add file1 &&
19 git commit -m initial &&
20
21 for i in 1 2 A B 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 D 21
22 do
23 echo $i
24 done >file1 &&
25 git diff >patch.1 &&
82e2765f
JH
26 cat file1 >clean &&
27
28 for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 C 13 14 15 16 17 18 19 20 F 21
29 do
30 echo $i
31 done >expected &&
57dc397c
JH
32
33 mv file1 file2 &&
34 git update-index --add --remove file1 file2 &&
35 git diff -M HEAD >patch.2 &&
36
37 rm -f file1 file2 &&
38 mv saved.file1 file1 &&
39 git update-index --add --remove file1 file2 &&
40
41 for i in 1 E 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 F 21
42 do
43 echo $i
44 done >file1 &&
45
46 cat file1 >saved.file1
47'
48
49test_expect_success 'apply without --reject should fail' '
50
51 if git apply patch.1
52 then
53 echo "Eh? Why?"
54 exit 1
55 fi
56
57 diff -u file1 saved.file1
58'
59
60test_expect_success 'apply with --reject should fail but update the file' '
61
82e2765f
JH
62 cat saved.file1 >file1 &&
63 rm -f file1.rej file2.rej &&
57dc397c 64
82e2765f 65 if git apply --reject patch.1
57dc397c
JH
66 then
67 echo "succeeds with --reject?"
68 exit 1
69 fi
57dc397c 70
82e2765f
JH
71 diff -u file1 expected &&
72
73 cat file1.rej &&
74
75 if test -f file2.rej
76 then
77 echo "file2 should not have been touched"
78 exit 1
79 fi
57dc397c
JH
80'
81
82test_expect_success 'apply with --reject should fail but update the file' '
83
82e2765f
JH
84 cat saved.file1 >file1 &&
85 rm -f file1.rej file2.rej file2 &&
57dc397c
JH
86
87 if git apply --reject patch.2 >rejects
88 then
89 echo "succeeds with --reject?"
90 exit 1
91 fi
92
57dc397c
JH
93 test -f file1 && {
94 echo "file1 still exists?"
95 exit 1
96 }
82e2765f
JH
97 diff -u file2 expected &&
98
99 cat file2.rej &&
100
101 if test -f file1.rej
102 then
103 echo "file2 should not have been touched"
104 exit 1
105 fi
106
57dc397c
JH
107'
108
109test_done