示例#1
0
        private static TreeComparisonHandleRetriever WorkdirAndIndexToTree(Repository repo)
        {
            TreeComparisonHandleRetriever comparisonHandleRetriever = (h, o) =>
            {
                DiffListSafeHandle diff = null, diff2 = null;

                try
                {
                    diff  = Proxy.git_diff_tree_to_index(repo.Handle, repo.Index.Handle, h, o);
                    diff2 = Proxy.git_diff_index_to_workdir(repo.Handle, repo.Index.Handle, o);
                    Proxy.git_diff_merge(diff, diff2);
                }
                catch
                {
                    diff.SafeDispose();
                    throw;
                }
                finally
                {
                    diff2.SafeDispose();
                }

                return(diff);
            };

            return(comparisonHandleRetriever);
        }
示例#2
0
        private DiffSafeHandle BuildDiffList(ObjectId oldTreeId, ObjectId newTreeId, TreeComparisonHandleRetriever comparisonHandleRetriever,
                                             DiffModifiers diffOptions, IEnumerable <string> paths, ExplicitPathsOptions explicitPathsOptions,
                                             CompareOptions compareOptions)
        {
            var matchedPaths = new MatchedPathsAggregator();
            var filePaths    = repo.ToFilePaths(paths);

            using (GitDiffOptions options = BuildOptions(diffOptions, filePaths, matchedPaths, compareOptions))
            {
                var diffList = comparisonHandleRetriever(oldTreeId, newTreeId, options);

                if (explicitPathsOptions != null)
                {
                    try
                    {
                        DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths);
                    }
                    catch
                    {
                        diffList.Dispose();
                        throw;
                    }
                }

                DetectRenames(diffList, compareOptions);

                return(diffList);
            }
        }
示例#3
0
        private static TreeComparisonHandleRetriever IndexToTree(Repository repo)
        {
            TreeComparisonHandleRetriever comparisonHandleRetriever = (h, o) =>
            {
                DiffListSafeHandle diff;
                Ensure.Success(NativeMethods.git_diff_index_to_tree(repo.Handle, o, h, out diff));
                return(diff);
            };

            return(comparisonHandleRetriever);
        }
示例#4
0
        private static TreeComparisonHandleRetriever WorkdirAndIndexToTree(Repository repo)
        {
            TreeComparisonHandleRetriever comparisonHandleRetriever = (oh, nh, o) =>
            {
                DiffSafeHandle diff = Proxy.git_diff_tree_to_index(repo.Handle, repo.Index.Handle, oh, o);

                using (DiffSafeHandle diff2 = Proxy.git_diff_index_to_workdir(repo.Handle, repo.Index.Handle, o))
                {
                    Proxy.git_diff_merge(diff, diff2);
                }

                return(diff);
            };

            return(comparisonHandleRetriever);
        }
示例#5
0
        private DiffHandle BuildDiffList(
            ObjectId oldTreeId,
            ObjectId newTreeId,
            TreeComparisonHandleRetriever comparisonHandleRetriever,
            DiffModifiers diffOptions,
            IEnumerable <string> paths,
            ExplicitPathsOptions explicitPathsOptions,
            CompareOptions compareOptions)
        {
            var filePaths = repo.ToFilePaths(paths);

            MatchedPathsAggregator matchedPaths = null;

            // We can't match paths unless we've got something to match
            // against and we're told to do so.
            if (filePaths != null && explicitPathsOptions != null)
            {
                if (explicitPathsOptions.OnUnmatchedPath != null || explicitPathsOptions.ShouldFailOnUnmatchedPath)
                {
                    matchedPaths = new MatchedPathsAggregator();
                }
            }

            using (GitDiffOptions options = BuildOptions(diffOptions, filePaths, matchedPaths, compareOptions))
            {
                var diffList = comparisonHandleRetriever(oldTreeId, newTreeId, options);

                if (matchedPaths != null)
                {
                    try
                    {
                        DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths);
                    }
                    catch
                    {
                        diffList.Dispose();
                        throw;
                    }
                }

                DetectRenames(diffList, compareOptions);

                return(diffList);
            }
        }
示例#6
0
        private TreeChanges BuildTreeChangesFromComparer(
            ObjectId oldTreeId, ObjectId newTreeId, TreeComparisonHandleRetriever comparisonHandleRetriever,
            DiffOptions diffOptions, IEnumerable <string> paths = null, ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null)
        {
            var matchedPaths = new MatchedPathsAggregator();
            var filePaths    = ToFilePaths(repo, paths);

            using (GitDiffOptions options = BuildOptions(diffOptions, filePaths, matchedPaths, compareOptions))
                using (DiffListSafeHandle diffList = comparisonHandleRetriever(oldTreeId, newTreeId, options))
                {
                    if (explicitPathsOptions != null)
                    {
                        DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths);
                    }

                    return(new TreeChanges(diffList));
                }
        }
示例#7
0
 private static DiffListSafeHandle BuildDiffListFromComparer(ObjectId treeId, TreeComparisonHandleRetriever comparisonHandleRetriever, GitDiffOptions options)
 {
     return(comparisonHandleRetriever(treeId, options));
 }
示例#8
0
        private static DiffListSafeHandle BuildDiffListFromComparer(GitObjectSafeHandle handle, TreeComparisonHandleRetriever comparisonHandleRetriever)
        {
            GitDiffOptions options = DefaultOptions;

            return(comparisonHandleRetriever(handle, options));
        }
示例#9
0
 private static DiffListSafeHandle BuildDiffListFromTreeAndComparer(Repository repo, ObjectId treeId, TreeComparisonHandleRetriever comparisonHandleRetriever)
 {
     using (var osw = new ObjectSafeWrapper(treeId, repo))
     {
         return(BuildDiffListFromComparer(osw.ObjectPtr, comparisonHandleRetriever));
     }
 }
示例#10
0
        private TreeChanges BuildTreeChangesFromComparer(
            ObjectId oldTreeId, ObjectId newTreeId, TreeComparisonHandleRetriever comparisonHandleRetriever,
            DiffModifiers diffOptions, IEnumerable<string> paths = null, ExplicitPathsOptions explicitPathsOptions = null, CompareOptions compareOptions = null)
        {
            var matchedPaths = new MatchedPathsAggregator();
            var filePaths = repo.ToFilePaths(paths);

            using (GitDiffOptions options = BuildOptions(diffOptions, filePaths, matchedPaths, compareOptions))
            using (DiffListSafeHandle diffList = comparisonHandleRetriever(oldTreeId, newTreeId, options))
            {
                if (explicitPathsOptions != null)
                {
                    DispatchUnmatchedPaths(explicitPathsOptions, filePaths, matchedPaths);
                }

                return new TreeChanges(diffList);
            }
        }
示例#11
0
 private static DiffListSafeHandle BuildDiffListFromTreeAndComparer(Repository repo, ObjectId treeId, TreeComparisonHandleRetriever comparisonHandleRetriever)
 {
     using (var osw = new ObjectSafeWrapper(treeId, repo))
     {
         return BuildDiffListFromComparer(osw.ObjectPtr, comparisonHandleRetriever);
     }
 }
示例#12
0
 private static DiffListSafeHandle BuildDiffListFromComparer(GitObjectSafeHandle handle, TreeComparisonHandleRetriever comparisonHandleRetriever)
 {
     GitDiffOptions options = DefaultOptions;
     return comparisonHandleRetriever(handle, options);
 }
示例#13
0
 private static DiffListSafeHandle BuildDiffListFromTreeAndComparer(ObjectId treeId, TreeComparisonHandleRetriever comparisonHandleRetriever, GitDiffOptions options)
 {
     return BuildDiffListFromComparer(treeId, comparisonHandleRetriever, options);
 }