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