t/t3*: avoid redundant uses of cat
[alt-git.git] / t / t4021-format-patch-numbered.sh
blob1219aa226dc7259172dba38da3f7354870e0929b
1 #!/bin/sh
3 # Copyright (c) 2006 Brian C Gernhardt
6 test_description='Format-patch numbering options'
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 test_expect_success setup '
13 echo A > file &&
14 git add file &&
15 git commit -m First &&
17 echo B >> file &&
18 git commit -a -m Second &&
20 echo C >> file &&
21 git commit -a -m Third
25 # Each of these gets used multiple times.
27 test_num_no_numbered() {
28 cnt=$(grep "^Subject: \[PATCH\]" $1 | wc -l) &&
29 test $cnt = $2
32 test_single_no_numbered() {
33 test_num_no_numbered $1 1
36 test_no_numbered() {
37 test_num_no_numbered $1 2
40 test_single_cover_letter_numbered() {
41 grep "^Subject: \[PATCH 0/1\]" $1 &&
42 grep "^Subject: \[PATCH 1/1\]" $1
45 test_single_numbered() {
46 grep "^Subject: \[PATCH 1/1\]" $1
49 test_numbered() {
50 grep "^Subject: \[PATCH 1/2\]" $1 &&
51 grep "^Subject: \[PATCH 2/2\]" $1
54 test_expect_success 'single patch defaults to no numbers' '
55 git format-patch --stdout HEAD~1 >patch0.single &&
56 test_single_no_numbered patch0.single
59 test_expect_success 'multiple patch defaults to numbered' '
61 git format-patch --stdout HEAD~2 >patch0.multiple &&
62 test_numbered patch0.multiple
66 test_expect_success 'Use --numbered' '
68 git format-patch --numbered --stdout HEAD~1 >patch1 &&
69 test_single_numbered patch1
73 test_expect_success 'format.numbered = true' '
75 git config format.numbered true &&
76 git format-patch --stdout HEAD~2 >patch2 &&
77 test_numbered patch2
81 test_expect_success 'format.numbered && single patch' '
83 git format-patch --stdout HEAD^ > patch3 &&
84 test_single_numbered patch3
88 test_expect_success 'format.numbered && --no-numbered' '
90 git format-patch --no-numbered --stdout HEAD~2 >patch4 &&
91 test_no_numbered patch4
95 test_expect_success 'format.numbered && --keep-subject' '
97 git format-patch --keep-subject --stdout HEAD^ >patch4a &&
98 grep "^Subject: Third" patch4a
102 test_expect_success 'format.numbered = auto' '
104 git config format.numbered auto &&
105 git format-patch --stdout HEAD~2 > patch5 &&
106 test_numbered patch5
110 test_expect_success 'format.numbered = auto && single patch' '
112 git format-patch --stdout HEAD^ > patch6 &&
113 test_single_no_numbered patch6
117 test_expect_success 'format.numbered = auto && --no-numbered' '
119 git format-patch --no-numbered --stdout HEAD~2 > patch7 &&
120 test_no_numbered patch7
124 test_expect_success '--start-number && --numbered' '
126 git format-patch --start-number 3 --numbered --stdout HEAD~1 > patch8 &&
127 grep "^Subject: \[PATCH 3/3\]" patch8
130 test_expect_success 'single patch with cover-letter defaults to numbers' '
131 git format-patch --cover-letter --stdout HEAD~1 >patch9.single &&
132 test_single_cover_letter_numbered patch9.single
135 test_expect_success 'Use --no-numbered and --cover-letter single patch' '
136 git format-patch --no-numbered --stdout --cover-letter HEAD~1 >patch10 &&
137 test_no_numbered patch10
142 test_done