|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
diffLine := &DiffLine{Type: DiffLineAdd, RightIdx: rightLine} |
|
|
diffLine := &DiffLine{Type: DiffLineAdd, RightIdx: rightLine} |
|
|
rightLine++ |
|
|
rightLine++ |
|
|
|
|
|
if curSection == nil { |
|
|
|
|
|
// Create a new section to represent this hunk |
|
|
|
|
|
curSection = &DiffSection{} |
|
|
|
|
|
curFile.Sections = append(curFile.Sections, curSection) |
|
|
|
|
|
} |
|
|
curSection.Lines = append(curSection.Lines, diffLine) |
|
|
curSection.Lines = append(curSection.Lines, diffLine) |
|
|
case '-': |
|
|
case '-': |
|
|
curFileLinesCount++ |
|
|
curFileLinesCount++ |
|
|
|
|
|
|
|
|
if leftLine > 0 { |
|
|
if leftLine > 0 { |
|
|
leftLine++ |
|
|
leftLine++ |
|
|
} |
|
|
} |
|
|
|
|
|
if curSection == nil { |
|
|
|
|
|
// Create a new section to represent this hunk |
|
|
|
|
|
curSection = &DiffSection{} |
|
|
|
|
|
curFile.Sections = append(curFile.Sections, curSection) |
|
|
|
|
|
} |
|
|
curSection.Lines = append(curSection.Lines, diffLine) |
|
|
curSection.Lines = append(curSection.Lines, diffLine) |
|
|
case ' ': |
|
|
case ' ': |
|
|
curFileLinesCount++ |
|
|
curFileLinesCount++ |
|
|
|
|
|
|
|
|
diffLine := &DiffLine{Type: DiffLinePlain, LeftIdx: leftLine, RightIdx: rightLine} |
|
|
diffLine := &DiffLine{Type: DiffLinePlain, LeftIdx: leftLine, RightIdx: rightLine} |
|
|
leftLine++ |
|
|
leftLine++ |
|
|
rightLine++ |
|
|
rightLine++ |
|
|
|
|
|
if curSection == nil { |
|
|
|
|
|
// Create a new section to represent this hunk |
|
|
|
|
|
curSection = &DiffSection{} |
|
|
|
|
|
curFile.Sections = append(curFile.Sections, curSection) |
|
|
|
|
|
} |
|
|
curSection.Lines = append(curSection.Lines, diffLine) |
|
|
curSection.Lines = append(curSection.Lines, diffLine) |
|
|
default: |
|
|
default: |
|
|
// This is unexpected |
|
|
// This is unexpected |