+18
-11
lines changedFilter options
+18
-11
lines changed Original file line number Diff line number Diff line change
@@ -38,7 +38,9 @@ pub(crate) fn header_field_multi_line(name: &[u8], value: &[u8], out: &mut dyn i
38
38
let mut lines = value.as_bstr().lines_with_terminator();
39
39
out.write_all(name)?;
40
40
out.write_all(SPACE)?;
41
-
out.write_all(lines.next().ok_or(Error::EmptyValue)?)?;
41
+
if let Some(line) = lines.next() {
42
+
out.write_all(line)?;
43
+
}
42
44
for line in lines {
43
45
out.write_all(SPACE)?;
44
46
out.write_all(line)?;
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
1
1
use gix_actor::SignatureRef;
2
-
use gix_object::{bstr::ByteSlice, commit::message::body::TrailerRef, CommitRef};
2
+
use gix_object::{bstr::ByteSlice, commit::message::body::TrailerRef, CommitRef, WriteTo};
3
3
use smallvec::SmallVec;
4
4
5
5
use crate::{
6
6
commit::{LONG_MESSAGE, MERGE_TAG, SIGNATURE},
7
-
fixture_name, linus_signature, signature,
7
+
fixture_name, hex_to_id, linus_signature, signature,
8
8
};
9
9
10
10
#[test]
@@ -347,15 +347,22 @@ fn newline_right_after_signature_multiline_header() -> crate::Result {
347
347
fn bogus_multi_gpgsig_header() -> crate::Result {
348
348
let fixture = fixture_name("commit", "bogus-gpgsig-lines-in-git.git.txt");
349
349
let commit = CommitRef::from_bytes(&fixture)?;
350
-
let pgp_sig = crate::commit::BEGIN_PGP_SIGNATURE.as_bstr();
351
-
assert_eq!(commit.extra_headers[0].1.as_ref(), pgp_sig);
350
+
let pgp_sig = b"-----BEGIN PGP SIGNATURE-----".as_bstr();
352
351
assert_eq!(commit.extra_headers().pgp_signature(), Some(pgp_sig));
353
352
assert_eq!(
354
-
commit.extra_headers().find(gix_object::commit::SIGNATURE_FIELD_NAME),
355
-
Some(pgp_sig)
353
+
commit.extra_headers().find_all("gpgsig").count(),
354
+
17,
355
+
"Each signature header line is prefixed with `gpgsig` here, so we parse it as extra header"
356
356
);
357
-
assert_eq!(commit.extra_headers().find_pos("gpgsig"), Some(0));
358
-
assert_eq!(commit.extra_headers().find_pos("something else"), None);
359
357
assert!(commit.message.starts_with(b"pretty: %G[?GS] placeholders"));
358
+
359
+
let mut buf = Vec::<u8>::new();
360
+
commit.write_to(&mut buf)?;
361
+
let actual = gix_object::compute_hash(gix_hash::Kind::Sha1, gix_object::Kind::Commit, &buf)?;
362
+
assert_eq!(
363
+
actual,
364
+
hex_to_id("5f549aa2f78314ac37bbd436c8f80aea4c752e07"),
365
+
"round-tripping works despite the strangeness"
366
+
);
360
367
Ok(())
361
368
}
Original file line number Diff line number Diff line change
@@ -149,8 +149,6 @@ iyBBl69jASy41Ug/BlFJbw4+ItkShpXwkJKuBBV/JExChmvbxYWaS7QnyYC9UO0=
149
149
150
150
";
151
151
152
-
const BEGIN_PGP_SIGNATURE: &[u8] = b"-----BEGIN PGP SIGNATURE-----";
153
-
154
152
mod method {
155
153
use gix_object::CommitRef;
156
154
use pretty_assertions::assert_eq;
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4