# eric7.Plugins.VcsPlugins.vcsGit.GitDiffParser

Module implementing a class to store and parse diff output.

### Global Attributes

None

### Classes

GitDiffParser | Class implementing a class to store and parse diff output.

### Functions

None

## GitDiffParser

Class implementing a class to store and parse diff output.

### Derived from

None

### Class Attributes

HunkHeaderRegexp

### Class Methods

None

### Methods

GitDiffParser | Constructor
__generateHunkHeader | Private method to generate a hunk header line.
__generateRange | Private method to generate a hunk header range.
__initHunk | Private method to initialize a hunk data structure.
__parseDiff | Private method to parse the diff output.
__parseRange | Private method to parse the hunk header range part.
createHunkPatch | Public method to create a hunk based patch.
createLinesPatch | Public method to create a selected lines based patch.
headerLength | Public method to get the header length.

### Static Methods

None

#### GitDiffParser (Constructor)

GitDiffParser(diff)

Constructor

diff
  output of the diff command (list of string)

#### GitDiffParser.__generateHunkHeader

__generateHunkHeader(oldStart, oldCount, newStart, newCount, heading=os.linesep)

Private method to generate a hunk header line.

oldStart
  start line of the old part (integer)
oldCount
  line count of the old part (integer)
newStart
  start line of the new part (integer)
newCount
  line count of the new part (integer)
heading
  hunk heading (string)

Return:
  hunk header (string)

#### GitDiffParser.__generateRange

__generateRange(start, count)

Private method to generate a hunk header range.

start
  start line (integer)
count
  line count (integer)

Return:
  hunk header range (string)

#### GitDiffParser.__initHunk

__initHunk()

Private method to initialize a hunk data structure.

Return:
  hunk data structure (dictionary)

#### GitDiffParser.__parseDiff

__parseDiff()

Private method to parse the diff output.

Raises AssertionError:
  raised when a malformed hunk header is encountered

#### GitDiffParser.__parseRange

__parseRange(headerRange)

Private method to parse the hunk header range part.

headerRange
  hunk header range (string)

Return:
  tuple of hunk start and hunk length (integer, integer)

#### GitDiffParser.createHunkPatch

createHunkPatch(lineIndex)

Public method to create a hunk based patch.

lineIndex
  line number of the hunk (integer)

Return:
  diff lines of the patch (string)

#### GitDiffParser.createLinesPatch

createLinesPatch(startIndex, endIndex, reverse=False)

Public method to create a selected lines based patch.

startIndex
  start line number (integer)
endIndex
  end line number (integer)
reverse
  flag indicating a reverse patch (boolean)

Return:
  diff lines of the patch (string)

#### GitDiffParser.headerLength

headerLength()

Public method to get the header length.

Return:
  length of the header (integer)

Up