invert the condition for special case for "git diff".
@@ -107,12 +107,13 @@ func (p *fileParser) parseHunks() ([]*Hunk, error) {
if err != nil {
return nil, ErrNoHunks
}
- if !bytes.HasPrefix(b, []byte(tokenDiffGit)) {
- return nil, ErrNoHunks
- }
- // It seems that you deleted an empty file.
+ if bytes.HasPrefix(b, []byte(tokenDiffGit)) {
+ // git diff may contain a file diff with empty hunks.
+ // e.g. delete an empty file.
return []*Hunk{}, nil
}
+ return nil, ErrNoHunks
+ }
var hunks []*Hunk
hp := &hunkParser{r: p.r}
for {
