static private List <GitDiffSection> getDiffSections(IGitRepository gitRepository, string sha1, string sha2, string filename1, string filename2) { List <GitDiffSection> sections = new List <GitDiffSection>(); List <string> diff = gitRepository.Diff(sha1, sha2, filename1, filename2, 0); foreach (string line in diff) { Match m = diffSectionRe.Match(line); if (!m.Success || m.Groups.Count < 3) { continue; } if (!m.Groups["left_start"].Success || !m.Groups["right_start"].Success) { continue; } // @@ -1 +1 @@ is essentially the same as @@ -1,1 +1,1 @@ int leftSectionLength = m.Groups["left_len"].Success ? int.Parse(m.Groups["left_len"].Value) : 1; int rightSectionLength = m.Groups["right_len"].Success ? int.Parse(m.Groups["right_len"].Value) : 1; GitDiffSection section; section.LeftSectionStart = int.Parse(m.Groups["left_start"].Value); section.LeftSectionEnd = section.LeftSectionStart + leftSectionLength; section.RightSectionStart = int.Parse(m.Groups["right_start"].Value); section.RightSectionEnd = section.RightSectionStart + rightSectionLength; sections.Add(section); } return(sections); }