Skip to content

Commit 570cd35

Browse files
fmaurer-rhjpgrayson
authored andcommitted
fix(import): Keep first line break in body
When importing a patch with multiple lines, the first line break in the body was removed from the body of the commit in the stack, because it was stripped when searching for the headers. Add the line break again when adding the first line to the split_message. This did not surface in the tests, because the test bodies always had one line and the expected bodies had an incorrect number of line breaks at the end. Fix the expected number of line breaks as well.
1 parent 5bf4666 commit 570cd35

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/cmd/import.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ impl Headers {
913913

914914
if headers.subject.is_some() {
915915
split_message.push_str(line.strip_prefix(dedent.as_bytes()).unwrap_or(line));
916+
split_message.push_char('\n');
916917
break;
917918
}
918919

t/t1800-import.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ test_expect_success 'Import patch with email headers' '
1919
Subject: Hey: the subject
2020
Message-ID: abc123
2121
22-
body
22+
body1
23+
body2
2324
2425
---
2526
@@ -41,7 +42,8 @@ test_expect_success 'Import patch with email headers' '
4142
test_when_finished "rm subject body expected" &&
4243
test_cmp expected subject &&
4344
cat >expected <<-\EOF &&
44-
body
45+
body1
46+
body2
4547
4648
Message-ID: abc123
4749
@@ -58,7 +60,8 @@ test_expect_success 'Import patch without email headers' '
5860
cat >patch <<-\EOF &&
5961
test subject
6062
61-
body
63+
body1
64+
body2
6265
6366
---
6467
@@ -80,7 +83,9 @@ test_expect_success 'Import patch without email headers' '
8083
test_when_finished "rm subject body expected" &&
8184
test_cmp expected subject &&
8285
cat >expected <<-\EOF &&
83-
body
86+
body1
87+
body2
88+
8489
8590
EOF
8691
test_cmp expected body &&
@@ -95,7 +100,8 @@ test_expect_success 'Patch subject resemebles header' '
95100
cat >patch <<-\EOF &&
96101
test: subject
97102
98-
body
103+
body1
104+
body2
99105
100106
---
101107
@@ -117,7 +123,9 @@ test_expect_success 'Patch subject resemebles header' '
117123
test_when_finished "rm subject body expected" &&
118124
test_cmp expected subject &&
119125
cat >expected <<-\EOF &&
120-
body
126+
body1
127+
body2
128+
121129
122130
EOF
123131
test_cmp expected body &&

0 commit comments

Comments
 (0)