diff options
Diffstat (limited to 'main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs')
-rw-r--r-- | main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs index f9bb1b5ca4..2b21cd1348 100644 --- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs +++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs @@ -802,26 +802,34 @@ namespace MonoDevelop.VersionControl.Git return GetCommitTextContent (c, repositoryPath); } + public override DiffInfo GenerateDiff (FilePath baseLocalPath, VersionInfo vi) + { + try { + if ((vi.Status & VersionStatus.ScheduledAdd) != 0) { + var ctxt = GetFileContent (vi.LocalPath); + return new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (EmptyContent, ctxt)); + } else if ((vi.Status & VersionStatus.ScheduledDelete) != 0) { + var ctxt = GetCommitContent (GetHeadCommit (), vi.LocalPath); + return new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt, EmptyContent)); + } else if ((vi.Status & VersionStatus.Modified) != 0 || (vi.Status & VersionStatus.Conflicted) != 0) { + var ctxt1 = GetCommitContent (GetHeadCommit (), vi.LocalPath); + var ctxt2 = GetFileContent (vi.LocalPath); + return new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt1, ctxt2)); + } + } catch (Exception ex) { + LoggingService.LogError ("Could not get diff for file '" + vi.LocalPath + "'", ex); + } + return null; + } + public override DiffInfo[] PathDiff (FilePath baseLocalPath, FilePath[] localPaths, bool remoteDiff) { List<DiffInfo> diffs = new List<DiffInfo> (); VersionInfo[] vinfos = GetDirectoryVersionInfo (baseLocalPath, localPaths, false, true); foreach (VersionInfo vi in vinfos) { - try { - if ((vi.Status & VersionStatus.ScheduledAdd) != 0) { - var ctxt = GetFileContent (vi.LocalPath); - diffs.Add (new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (EmptyContent, ctxt))); - } else if ((vi.Status & VersionStatus.ScheduledDelete) != 0) { - var ctxt = GetCommitContent (GetHeadCommit (), vi.LocalPath); - diffs.Add (new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt, EmptyContent))); - } else if ((vi.Status & VersionStatus.Modified) != 0 || (vi.Status & VersionStatus.Conflicted) != 0) { - var ctxt1 = GetCommitContent (GetHeadCommit (), vi.LocalPath); - var ctxt2 = GetFileContent (vi.LocalPath); - diffs.Add (new DiffInfo (baseLocalPath, vi.LocalPath, GenerateDiff (ctxt1, ctxt2))); - } - } catch (Exception ex) { - LoggingService.LogError ("Could not get diff for file '" + vi.LocalPath + "'", ex); - } + var diff = GenerateDiff (baseLocalPath, vi); + if (diff != null) + diffs.Add (diff); } return diffs.ToArray (); } |