]>
Commit | Line | Data |
---|---|---|
e90ecb68 BG |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2006 Brian C Gernhardt | |
4 | # | |
5 | ||
6 | test_description='Format-patch numbering options' | |
7 | ||
8 | . ./test-lib.sh | |
9 | ||
10 | test_expect_success setup ' | |
11 | ||
12 | echo A > file && | |
13 | git add file && | |
14 | git commit -m First && | |
15 | ||
16 | echo B >> file && | |
17 | git commit -a -m Second && | |
18 | ||
19 | echo C >> file && | |
20 | git commit -a -m Third | |
21 | ||
22 | ' | |
23 | ||
24 | # Each of these gets used multiple times. | |
25 | ||
26 | test_num_no_numbered() { | |
27 | cnt=$(grep "^Subject: \[PATCH\]" $1 | wc -l) && | |
28 | test $cnt = $2 | |
29 | } | |
30 | ||
31 | test_single_no_numbered() { | |
32 | test_num_no_numbered $1 1 | |
33 | } | |
34 | ||
35 | test_no_numbered() { | |
36 | test_num_no_numbered $1 2 | |
37 | } | |
38 | ||
957ed3a5 JK |
39 | test_single_cover_letter_numbered() { |
40 | grep "^Subject: \[PATCH 0/1\]" $1 && | |
41 | grep "^Subject: \[PATCH 1/1\]" $1 | |
42 | } | |
43 | ||
e90ecb68 BG |
44 | test_single_numbered() { |
45 | grep "^Subject: \[PATCH 1/1\]" $1 | |
46 | } | |
47 | ||
48 | test_numbered() { | |
49 | grep "^Subject: \[PATCH 1/2\]" $1 && | |
50 | grep "^Subject: \[PATCH 2/2\]" $1 | |
51 | } | |
52 | ||
a567fdcb BG |
53 | test_expect_success 'single patch defaults to no numbers' ' |
54 | git format-patch --stdout HEAD~1 >patch0.single && | |
55 | test_single_no_numbered patch0.single | |
56 | ' | |
57 | ||
58 | test_expect_success 'multiple patch defaults to numbered' ' | |
e90ecb68 | 59 | |
a567fdcb BG |
60 | git format-patch --stdout HEAD~2 >patch0.multiple && |
61 | test_numbered patch0.multiple | |
e90ecb68 BG |
62 | |
63 | ' | |
64 | ||
65 | test_expect_success 'Use --numbered' ' | |
66 | ||
a567fdcb BG |
67 | git format-patch --numbered --stdout HEAD~1 >patch1 && |
68 | test_single_numbered patch1 | |
e90ecb68 BG |
69 | |
70 | ' | |
71 | ||
72 | test_expect_success 'format.numbered = true' ' | |
73 | ||
74 | git config format.numbered true && | |
75 | git format-patch --stdout HEAD~2 >patch2 && | |
76 | test_numbered patch2 | |
77 | ||
78 | ' | |
79 | ||
80 | test_expect_success 'format.numbered && single patch' ' | |
81 | ||
82 | git format-patch --stdout HEAD^ > patch3 && | |
83 | test_single_numbered patch3 | |
84 | ||
85 | ' | |
86 | ||
87 | test_expect_success 'format.numbered && --no-numbered' ' | |
88 | ||
89 | git format-patch --no-numbered --stdout HEAD~2 >patch4 && | |
90 | test_no_numbered patch4 | |
91 | ||
92 | ' | |
93 | ||
ca6b91d2 JM |
94 | test_expect_success 'format.numbered && --keep-subject' ' |
95 | ||
96 | git format-patch --keep-subject --stdout HEAD^ >patch4a && | |
97 | grep "^Subject: Third" patch4a | |
98 | ||
99 | ' | |
100 | ||
e90ecb68 BG |
101 | test_expect_success 'format.numbered = auto' ' |
102 | ||
a48fcd83 | 103 | git config format.numbered auto && |
e90ecb68 BG |
104 | git format-patch --stdout HEAD~2 > patch5 && |
105 | test_numbered patch5 | |
106 | ||
107 | ' | |
108 | ||
109 | test_expect_success 'format.numbered = auto && single patch' ' | |
110 | ||
111 | git format-patch --stdout HEAD^ > patch6 && | |
112 | test_single_no_numbered patch6 | |
113 | ||
114 | ' | |
115 | ||
116 | test_expect_success 'format.numbered = auto && --no-numbered' ' | |
117 | ||
118 | git format-patch --no-numbered --stdout HEAD~2 > patch7 && | |
119 | test_no_numbered patch7 | |
120 | ||
121 | ' | |
122 | ||
f044fe2d SB |
123 | test_expect_success '--start-number && --numbered' ' |
124 | ||
125 | git format-patch --start-number 3 --numbered --stdout HEAD~1 > patch8 && | |
126 | grep "^Subject: \[PATCH 3/3\]" patch8 | |
127 | ' | |
128 | ||
957ed3a5 JK |
129 | test_expect_success 'single patch with cover-letter defaults to numbers' ' |
130 | git format-patch --cover-letter --stdout HEAD~1 >patch9.single && | |
131 | test_single_cover_letter_numbered patch9.single | |
132 | ' | |
133 | ||
134 | test_expect_success 'Use --no-numbered and --cover-letter single patch' ' | |
135 | git format-patch --no-numbered --stdout --cover-letter HEAD~1 >patch10 && | |
136 | test_no_numbered patch10 | |
137 | ' | |
138 | ||
139 | ||
140 | ||
e90ecb68 | 141 | test_done |