# 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 (list of str)
  output of the diff command

#### GitDiffParser.__generateHunkHeader

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

Private method to generate a hunk header line.

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

Return:
  hunk header

Return Type:
  str

#### GitDiffParser.__generateRange

__generateRange(start, count)

Private method to generate a hunk header range.

start (int)
  start line
count (int)
  line count

Return:
  hunk header range

Return Type:
  str

#### GitDiffParser.__initHunk

__initHunk()

Private method to initialize a hunk data structure.

Return:
  hunk data structure

Return Type:
  dict

#### 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 (str)
  hunk header range

Return:
  tuple of hunk start and hunk length

Return Type:
  tuple of (int, int)

#### GitDiffParser.createHunkPatch

createHunkPatch(lineIndex)

Public method to create a hunk based patch.

lineIndex (int)
  line number of the hunk

Return:
  diff lines of the patch

Return Type:
  str

#### GitDiffParser.createLinesPatch

createLinesPatch(startIndex, endIndex, reverse=False)

Public method to create a selected lines based patch.

startIndex (int)
  start line number
endIndex (int)
  end line number
reverse (bool)
  flag indicating a reverse patch

Return:
  diff lines of the patch

Return Type:
  str

#### GitDiffParser.headerLength

headerLength()

Public method to get the header length.

Return:
  length of the header

Return Type:
  int

Up