A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/GitoxideLabs/gitoxide/commit/ef73c6b6631a3308b7bf5d15b69f4f14767a23d5 below:

Merge pull request #2098 from dscho/fix-parsing-of-legacy-git.git-commit · GitoxideLabs/gitoxide@ef73c6b · GitHub

File tree Expand file treeCollapse file tree 7 files changed

+65

-11

lines changed

Filter options

Expand file treeCollapse file tree 7 files changed

+65

-11

lines changed Original file line number Diff line number Diff line change

@@ -33,9 +33,6 @@ mod serde_only {

33 33

}

34 34

}

35 35

}

36 - 37 -

#[derive(serde::Serialize, serde::Deserialize)]

38 -

pub struct NodeId {}

39 36

}

40 37

}

41 38 Original file line number Diff line number Diff line change

@@ -44,14 +44,14 @@ pub fn commit<'a, E: ParserError<&'a [u8]> + AddContext<&'a [u8], StrContext>>(

44 44

.context(StrContext::Expected("author <signature>".into())),

45 45

(|i: &mut _| parse::header_field(i, b"committer", parse::signature))

46 46

.context(StrContext::Expected("committer <signature>".into())),

47 -

opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(1.., NL)))

47 +

opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(0.., NL)))

48 48

.context(StrContext::Expected("encoding <encoding>".into())),

49 49

repeat(

50 50

0..,

51 51

alt((

52 52

parse::any_header_field_multi_line.map(|(k, o)| (k.as_bstr(), Cow::Owned(o))),

53 53

|i: &mut _| {

54 -

parse::any_header_field(i, take_till(1.., NL))

54 +

parse::any_header_field(i, take_till(0.., NL))

55 55

.map(|(k, o)| (k.as_bstr(), Cow::Borrowed(o.as_bstr())))

56 56

},

57 57

)),

Original file line number Diff line number Diff line change

@@ -214,7 +214,7 @@ impl<'a> CommitRefIter<'a> {

214 214

}

215 215

}

216 216

Encoding => {

217 -

let encoding = opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(1.., NL)))

217 +

let encoding = opt(|i: &mut _| parse::header_field(i, b"encoding", take_till(0.., NL)))

218 218

.context(StrContext::Expected("encoding <encoding>".into()))

219 219

.parse_next(input)?;

220 220

*state = State::ExtraHeaders;

@@ -227,7 +227,7 @@ impl<'a> CommitRefIter<'a> {

227 227

let extra_header = opt(alt((

228 228

|i: &mut _| parse::any_header_field_multi_line(i).map(|(k, o)| (k.as_bstr(), Cow::Owned(o))),

229 229

|i: &mut _| {

230 -

parse::any_header_field(i, take_till(1.., NL))

230 +

parse::any_header_field(i, take_till(0.., NL))

231 231

.map(|(k, o)| (k.as_bstr(), Cow::Borrowed(o.as_bstr())))

232 232

},

233 233

)))

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

@@ -18,7 +18,7 @@ pub(crate) fn any_header_field_multi_line<'a, E: ParserError<&'a [u8]> + AddCont

18 18

(

19 19

terminated(take_till(1.., SPACE_OR_NL), SPACE),

20 20

(

21 -

take_till(1.., NL),

21 +

take_till(0.., NL),

22 22

NL,

23 23

repeat(1.., terminated((SPACE, take_until(0.., NL)), NL)).map(|()| ()),

24 24

)

Original file line number Diff line number Diff line change

@@ -0,0 +1,31 @@

1 +

tree db079155794727ac821adfba2eb68b330cc0c120

2 +

parent 33a11a20eb7610771268e34211509cbbdee76b1e

3 +

author Junio C Hamano <gitster@pobox.com> 1319256362 -0700

4 +

committer Junio C Hamano <gitster@pobox.com> 1319259176 -0700

5 +

gpgsig -----BEGIN PGP SIGNATURE-----

6 +

gpgsig Version: GnuPG v1.4.10 (GNU/Linux)

7 +

gpgsig

8 +

gpgsig iQIcBAABAgAGBQJOokwoAAoJELC16IaWr+bL0WoP/2QKYkWpEyXF608m2L/cB9Qx

9 +

gpgsig /N0oBjyL1guIjPX9B3Wxq80dnLLEPnpnO39aiQIXFoJS0L6KEurqK6uDPHy3/ULa

10 +

gpgsig QsAug2HeCLsDnIFbzFSpSIMv/bP/72FDb/idMBT99xTcQj5UJEUgj7AAtx0vnKvQ

11 +

gpgsig pQIXtPu5GBUdhl3SiGgiJFRyp4r5EgV5I40GBwx/ty9cPEIN7ukJ3CR9+KC8eIGx

12 +

gpgsig Az7qngi3dhTn7g+3Z8XX5OYFDMSt9xn1gxqWXOMNlG0mxCvpFe59kwciugp26KVp

13 +

gpgsig n+yJ0UOdoxyZX8pdqXQjvklmoo7e55aaxtbHe7KSD56ebL7h7vHhkGWORU1dOp+h

14 +

gpgsig Iv5dQItkKSR8afB7FmRjo8+B/2g0wZDKRTGhzm7d1gooO5gpXvuvm4GRl5Io+IEj

15 +

gpgsig c7Li3EYmXADWUZWJtbDKDgKGKIOmWv72Qrz52iaESrhZ909HiXfn/jhHBuDRmLtQ

16 +

gpgsig /4v3T4O25uhdZ4p/PjHQn/ZroCmDyMwmnrtw/tt5fSNrl4qGcYg8Jj/1ynfF1AtS

17 +

gpgsig dM2LR65sOwXzSsqAbQjyRFYMLSWhHd/h8BcpZHDXmNBkZJVPm4zvD3ZVaAo6rtZD

18 +

gpgsig WJ9YXWXtPhuf09OgYBzcBlamTrk9ByH+NCIdrFkqfhNF1YI5dArSZytIXJhpPI1e

19 +

gpgsig TrmQAZf0BiI5J6PYN0AI

20 +

gpgsig =Qg/+

21 +

gpgsig -----END PGP SIGNATURE-----

22 + 23 +

pretty: %G[?GS] placeholders

24 + 25 +

Add new placeholders related to the GPG signature on signed commits.

26 + 27 +

- %GG to show the raw verification message from GPG;

28 +

- %G? to show either "G" for Good, "B" for Bad;

29 +

- %GS to show the name of the signer.

30 + 31 +

Signed-off-by: Junio C Hamano <gitster@pobox.com>

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]

@@ -342,3 +342,27 @@ fn newline_right_after_signature_multiline_header() -> crate::Result {

342 342

assert!(commit.message.starts_with(b"Rollup"));

343 343

Ok(())

344 344

}

345 + 346 +

#[test]

347 +

fn bogus_multi_gpgsig_header() -> crate::Result {

348 +

let fixture = fixture_name("commit", "bogus-gpgsig-lines-in-git.git.txt");

349 +

let commit = CommitRef::from_bytes(&fixture)?;

350 +

let pgp_sig = b"-----BEGIN PGP SIGNATURE-----".as_bstr();

351 +

assert_eq!(commit.extra_headers().pgp_signature(), Some(pgp_sig));

352 +

assert_eq!(

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 +

);

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 +

);

367 +

Ok(())

368 +

}

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