diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/gitdiff/file_header.go b/gitdiff/file_header.go index 58904b4..1962e64 100644 --- a/gitdiff/file_header.go +++ b/gitdiff/file_header.go @@ -30,6 +30,12 @@ func (p *parser) ParseNextFileHeader() (*File, string, error) { return nil, "", p.Errorf(-1, "patch fragment without file header: %s", frag.Header()) } + // check for end of merge header, and start of a new header + if strings.HasPrefix(p.Line(0), commitPrefix) { + preamble.Reset() + goto NextLine + } + // check for a git-generated patch file, err = p.ParseGitFileHeader() if err != nil { diff --git a/gitdiff/parser_test.go b/gitdiff/parser_test.go index 5040b0a..2e7a91a 100644 --- a/gitdiff/parser_test.go +++ b/gitdiff/parser_test.go @@ -301,6 +301,42 @@ a wild fragment appears? `, Err: true, }, + "mergeHeaderFollowedByNormalHeader": { + Input: `commit f6ded7a51cf917bdb44097066fab608c0facde5b +Merge: b2cf1cd0de 0254477421 +Author: BoloniniD +Date: Thu Apr 7 01:07:38 2022 +0300 + + Merge branch 'BLAKE3' of github.com:BoloniniD/ClickHouse into BLAKE3 + +commit 645e156af6b362145fad82d714f8e70a5b5a55a8 +Author: Meena Renganathan +Date: Wed Apr 6 14:50:10 2022 -0700 + + Updated the boringssl-cmake to match the latest broingssl module update + +diff --git a/.gitmodules b/.gitmodules +index 6c9e66f9cb..9cee5f697e 100644 +--- a/.gitmodules ++++ b/.gitmodules +@@ -207 +206,0 @@ +- branch = MergeWithUpstream +`, + Output: &File{ + OldName: ".gitmodules", + NewName: ".gitmodules", + OldMode: os.FileMode(0100644), + OldOIDPrefix: "6c9e66f9cb", + NewOIDPrefix: "9cee5f697e", + }, + Preamble: `commit 645e156af6b362145fad82d714f8e70a5b5a55a8 +Author: Meena Renganathan +Date: Wed Apr 6 14:50:10 2022 -0700 + + Updated the boringssl-cmake to match the latest broingssl module update + +`, + }, } for name, test := range tests {