]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4152-am-subjects.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t4152-am-subjects.sh
1 #!/bin/sh
2
3 test_description='test subject preservation with format-patch | am'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
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
17 '
18 }
19
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
25 }
26
27 test_expect_success 'setup baseline commit' '
28 test_commit baseline file
29 '
30
31 SHORT_SUBJECT='short subject'
32 make_patches short "$SHORT_SUBJECT"
33
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"
39
40 MULTILINE_SUBJECT="$LONG_SUBJECT1
41 $LONG_SUBJECT2
42 $LONG_SUBJECT3"
43 make_patches multiline "$MULTILINE_SUBJECT"
44
45 echo "$SHORT_SUBJECT" >expect
46 test_expect_success 'short subject preserved (format-patch | am)' '
47 check_subject short
48 '
49 test_expect_success 'short subject preserved (format-patch -k | am)' '
50 check_subject short-k
51 '
52 test_expect_success 'short subject preserved (format-patch -k | am -k)' '
53 check_subject short-k -k
54 '
55
56 echo "$LONG_SUBJECT" >expect
57 test_expect_success 'long subject preserved (format-patch | am)' '
58 check_subject long
59 '
60 test_expect_success 'long subject preserved (format-patch -k | am)' '
61 check_subject long-k
62 '
63 test_expect_success 'long subject preserved (format-patch -k | am -k)' '
64 check_subject long-k -k
65 '
66
67 echo "$LONG_SUBJECT" >expect
68 test_expect_success 'multiline subject unwrapped (format-patch | am)' '
69 check_subject multiline
70 '
71 test_expect_success 'multiline subject unwrapped (format-patch -k | am)' '
72 check_subject multiline-k
73 '
74 echo "$MULTILINE_SUBJECT" >expect
75 test_expect_success 'multiline subject preserved (format-patch -k | am -k)' '
76 check_subject multiline-k -k
77 '
78
79 test_done