code: def _parse_source_sections(self, diff_str):
          
  
          # Create a dict to map source files to lines in the diff output
          source_dict = dict()
  
          # Keep track of the current source file
          src_path = None
  
          # Signal that we've found a hunk (after starting a source file)
          found_hunk = False
  
          # Parse the diff string into sections by source file
          for line in diff_str.split('\n'):
  
              # If the line starts with "diff --git"
              # or "diff --cc" (in the case of a merge conflict)
              # then it is the start of a new source file
              if line.startswith('diff --git') or line.startswith('diff --cc'):
  
                  # Retrieve the name of the source file
                  src_path = self._parse_source_line(line)
  
                  # Create an entry for the source file, if we don't
                  # already have one.
                  if src_path not in source_dict:
                      source_dict[src_path] = []
  
                  # Signal that we're waiting for a hunk for this source file
                  found_hunk = False
  
              # Every other line is stored in the dictionary for this source file
              # once we find a hunk section
              else:
  
                  # Only add lines if we're in a hunk section
                  # (ignore index and files changed lines)
                  if found_hunk or line.startswith('@@'):
  
                      # Remember that we found a hunk
                      found_hunk = True
  
                      if src_path is not None:
                          source_dict[src_path].append(line)
  
                      else:
                          # We tolerate other information before we have
                          # a source file defined, unless it's a hunk line
                          if line.startswith("@@"):
                              msg = "Hunk has no source file: '{}'".format(line)
                              raise GitDiffError(msg)
  
          return source_dict
docs: Given the output of `git diff`, return a dictionary
          with keys that are source file paths.
  
          Each value is a list of lines from the `git diff` output
          related to the source file.
  
          Raises a `GitDiffError` if `diff_str` is in an invalid format.