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