]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4152-am-subjects.sh
The sixth batch
[thirdparty/git.git] / t / t4152-am-subjects.sh
CommitLineData
00ebc977
JK
1#!/bin/sh
2
3test_description='test subject preservation with format-patch | am'
4. ./test-lib.sh
5
6make_patches() {
7 type=$1
8 subject=$2
9 test_expect_success "create patches with $type subject" '
10 git reset --hard baseline &&
11 echo $type >file &&
12 git commit -a -m "$subject" &&
13 git format-patch -1 --stdout >$type.patch &&
14 git format-patch -1 --stdout -k >$type-k.patch
15 '
16}
17
18check_subject() {
19 git reset --hard baseline &&
20 git am $2 $1.patch &&
21 git log -1 --pretty=format:%B >actual &&
22 test_cmp expect actual
23}
24
25test_expect_success 'setup baseline commit' '
26 test_commit baseline file
27'
28
29SHORT_SUBJECT='short subject'
30make_patches short "$SHORT_SUBJECT"
31
32LONG_SUBJECT1='this is a long subject that is virtually guaranteed'
33LONG_SUBJECT2='to require wrapping via format-patch if it is all'
34LONG_SUBJECT3='going to appear on a single line'
35LONG_SUBJECT="$LONG_SUBJECT1 $LONG_SUBJECT2 $LONG_SUBJECT3"
36make_patches long "$LONG_SUBJECT"
37
38MULTILINE_SUBJECT="$LONG_SUBJECT1
39$LONG_SUBJECT2
40$LONG_SUBJECT3"
41make_patches multiline "$MULTILINE_SUBJECT"
42
43echo "$SHORT_SUBJECT" >expect
44test_expect_success 'short subject preserved (format-patch | am)' '
45 check_subject short
46'
47test_expect_success 'short subject preserved (format-patch -k | am)' '
48 check_subject short-k
49'
50test_expect_success 'short subject preserved (format-patch -k | am -k)' '
51 check_subject short-k -k
52'
53
54echo "$LONG_SUBJECT" >expect
55test_expect_success 'long subject preserved (format-patch | am)' '
56 check_subject long
57'
58test_expect_success 'long subject preserved (format-patch -k | am)' '
59 check_subject long-k
60'
5b38456e 61test_expect_success 'long subject preserved (format-patch -k | am -k)' '
00ebc977
JK
62 check_subject long-k -k
63'
64
65echo "$LONG_SUBJECT" >expect
66test_expect_success 'multiline subject unwrapped (format-patch | am)' '
67 check_subject multiline
68'
69test_expect_success 'multiline subject unwrapped (format-patch -k | am)' '
70 check_subject multiline-k
71'
72echo "$MULTILINE_SUBJECT" >expect
9553d2b2 73test_expect_success 'multiline subject preserved (format-patch -k | am -k)' '
00ebc977
JK
74 check_subject multiline-k -k
75'
76
77test_done