interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t4152-am-subjects.sh

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