Start the 2.46 cycle
[git/gitster.git] / t / t4152-am-subjects.sh
blob9f2edba1f833a7127589f9c4883b91bf99bc00b1
1 #!/bin/sh
3 test_description='test subject preservation with format-patch | am'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 make_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
20 check_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
27 test_expect_success 'setup baseline commit' '
28 test_commit baseline file
31 SHORT_SUBJECT='short subject'
32 make_patches short "$SHORT_SUBJECT"
34 LONG_SUBJECT1='this is a long subject that is virtually guaranteed'
35 LONG_SUBJECT2='to require wrapping via format-patch if it is all'
36 LONG_SUBJECT3='going to appear on a single line'
37 LONG_SUBJECT="$LONG_SUBJECT1 $LONG_SUBJECT2 $LONG_SUBJECT3"
38 make_patches long "$LONG_SUBJECT"
40 MULTILINE_SUBJECT="$LONG_SUBJECT1
41 $LONG_SUBJECT2
42 $LONG_SUBJECT3"
43 make_patches multiline "$MULTILINE_SUBJECT"
45 echo "$SHORT_SUBJECT" >expect
46 test_expect_success 'short subject preserved (format-patch | am)' '
47 check_subject short
49 test_expect_success 'short subject preserved (format-patch -k | am)' '
50 check_subject short-k
52 test_expect_success 'short subject preserved (format-patch -k | am -k)' '
53 check_subject short-k -k
56 echo "$LONG_SUBJECT" >expect
57 test_expect_success 'long subject preserved (format-patch | am)' '
58 check_subject long
60 test_expect_success 'long subject preserved (format-patch -k | am)' '
61 check_subject long-k
63 test_expect_success 'long subject preserved (format-patch -k | am -k)' '
64 check_subject long-k -k
67 echo "$LONG_SUBJECT" >expect
68 test_expect_success 'multiline subject unwrapped (format-patch | am)' '
69 check_subject multiline
71 test_expect_success 'multiline subject unwrapped (format-patch -k | am)' '
72 check_subject multiline-k
74 echo "$MULTILINE_SUBJECT" >expect
75 test_expect_success 'multiline subject preserved (format-patch -k | am -k)' '
76 check_subject multiline-k -k
79 test_done