Skip to content

Commit 7765724

Browse files
authored
Merge pull request #7 from nicholas-arnica/skip-empty-content-headers
Fixed Irrelevant header data being returned
2 parents 9cc57d2 + 8d42dd9 commit 7765724

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

gitdiff/file_header.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ func (p *parser) ParseNextFileHeader() (*File, string, error) {
3030
return nil, "", p.Errorf(-1, "patch fragment without file header: %s", frag.Header())
3131
}
3232

33+
// check for end of merge header, and start of a new header
34+
if strings.HasPrefix(p.Line(0), commitPrefix) {
35+
preamble.Reset()
36+
goto NextLine
37+
}
38+
3339
// check for a git-generated patch
3440
file, err = p.ParseGitFileHeader()
3541
if err != nil {

gitdiff/parser_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,42 @@ a wild fragment appears?
301301
`,
302302
Err: true,
303303
},
304+
"mergeHeaderFollowedByNormalHeader": {
305+
Input: `commit f6ded7a51cf917bdb44097066fab608c0facde5b
306+
Merge: b2cf1cd0de 0254477421
307+
Author: BoloniniD <[email protected]>
308+
Date: Thu Apr 7 01:07:38 2022 +0300
309+
310+
Merge branch 'BLAKE3' of github.com:BoloniniD/ClickHouse into BLAKE3
311+
312+
commit 645e156af6b362145fad82d714f8e70a5b5a55a8
313+
Author: Meena Renganathan <[email protected]>
314+
Date: Wed Apr 6 14:50:10 2022 -0700
315+
316+
Updated the boringssl-cmake to match the latest broingssl module update
317+
318+
diff --git a/.gitmodules b/.gitmodules
319+
index 6c9e66f9cb..9cee5f697e 100644
320+
--- a/.gitmodules
321+
+++ b/.gitmodules
322+
@@ -207 +206,0 @@
323+
- branch = MergeWithUpstream
324+
`,
325+
Output: &File{
326+
OldName: ".gitmodules",
327+
NewName: ".gitmodules",
328+
OldMode: os.FileMode(0100644),
329+
OldOIDPrefix: "6c9e66f9cb",
330+
NewOIDPrefix: "9cee5f697e",
331+
},
332+
Preamble: `commit 645e156af6b362145fad82d714f8e70a5b5a55a8
333+
Author: Meena Renganathan <[email protected]>
334+
Date: Wed Apr 6 14:50:10 2022 -0700
335+
336+
Updated the boringssl-cmake to match the latest broingssl module update
337+
338+
`,
339+
},
304340
}
305341

306342
for name, test := range tests {

0 commit comments

Comments
 (0)