예제 #1
0
 public BlameHunkCollection Blame(string path, BlameOptions options = null)
 {
     throw new NotImplementedException();
 }
        internal BlameHunkCollection(Repository repo, RepositorySafeHandle repoHandle, string path, BlameOptions options)
        {
            this.repo = repo;

            var rawopts = new GitBlameOptions
            {
                version = 1,
                flags   = options.Strategy.ToGitBlameOptionFlags(),
                MinLine = (uint)options.MinLine,
                MaxLine = (uint)options.MaxLine,
            };

            if (options.StartingAt != null)
            {
                rawopts.NewestCommit = repo.Committish(options.StartingAt).Oid;
            }
            if (options.StoppingAt != null)
            {
                rawopts.OldestCommit = repo.Committish(options.StoppingAt).Oid;
            }

            using (var blameHandle = Proxy.git_blame_file(repoHandle, path, rawopts))
            {
                var numHunks = NativeMethods.git_blame_get_hunk_count(blameHandle);
                for (uint i = 0; i < numHunks; ++i)
                {
                    var rawHunk = Proxy.git_blame_get_hunk_byindex(blameHandle, i);
                    hunks.Add(new BlameHunk(this.repo, rawHunk));
                }
            }
        }
예제 #3
0
        internal unsafe BlameHunkCollection(Repository repo, RepositoryHandle repoHandle, string path, BlameOptions options)
        {
            this.repo = repo;

            var rawopts = new git_blame_options
            {
                version  = 1,
                flags    = options.Strategy.ToGitBlameOptionFlags(),
                min_line = new UIntPtr((uint)options.MinLine),
                max_line = new UIntPtr((uint)options.MaxLine),
            };

            if (options.StartingAt != null)
            {
                fixed(byte *p = rawopts.newest_commit.Id)
                {
                    Marshal.Copy(repo.Committish(options.StartingAt).Oid.Id, 0, new IntPtr(p), git_oid.Size);
                }
            }

            if (options.StoppingAt != null)
            {
                fixed(byte *p = rawopts.oldest_commit.Id)
                {
                    Marshal.Copy(repo.Committish(options.StoppingAt).Oid.Id, 0, new IntPtr(p), git_oid.Size);
                }
            }

            using (var blameHandle = Proxy.git_blame_file(repoHandle, path, rawopts))
            {
                var numHunks = NativeMethods.git_blame_get_hunk_count(blameHandle);
                for (uint i = 0; i < numHunks; ++i)
                {
                    var rawHunk = Proxy.git_blame_get_hunk_byindex(blameHandle, i);
                    hunks.Add(new BlameHunk(this.repo, rawHunk));
                }
            }
        }
        internal BlameHunkCollection(Repository repo, RepositorySafeHandle repoHandle, string path, BlameOptions options)
        {
            this.repo = repo;

            var rawopts = new GitBlameOptions
            {
                version     = 1,
                FindOptions = new GitDiffFindOptions {
                    Version = 1,
                },
                flags   = options.Strategy.ToGitBlameOptionFlags(),
                MinLine = (uint)options.MinLine,
                MaxLine = (uint)options.MaxLine,
            };

            if (options.FindNoRenames)
            {
                rawopts.FindOptions.Flags = GitDiffFindFlags.GIT_DIFF_FIND_NO_RENAMES;
            }
            else if (options.FindExactRenames)
            {
                rawopts.FindOptions.Flags = GitDiffFindFlags.GIT_DIFF_FIND_EXACT_MATCH_ONLY;
            }
            else
            {
                rawopts.FindOptions.Flags = GitDiffFindFlags.GIT_DIFF_FIND_RENAMES;
            }

            if (options.StartingAt != null)
            {
                rawopts.NewestCommit = repo.Committish(options.StartingAt).Oid;
            }

            if (options.StoppingAt != null)
            {
                rawopts.OldestCommit = repo.Committish(options.StoppingAt).Oid;
            }

            using (var blameHandle = Proxy.git_blame_file(repoHandle, path, rawopts))
            {
                var numHunks = NativeMethods.git_blame_get_hunk_count(blameHandle);
                for (uint i = 0; i < numHunks; ++i)
                {
                    var rawHunk = Proxy.git_blame_get_hunk_byindex(blameHandle, i);
                    hunks.Add(new BlameHunk(this.repo, rawHunk));
                }
            }
        }
예제 #5
0
 /// <summary>
 /// Find where each line of a file originated.
 /// </summary>
 /// <param name="path">Path of the file to blame.</param>
 /// <param name="options">Specifies optional parameters; if null, the defaults are used.</param>
 /// <returns>The blame for the file.</returns>
 public BlameHunkCollection Blame(string path, BlameOptions options = null)
 {
     return(new BlameHunkCollection(this, Handle, path, options ?? new BlameOptions()));
 }
예제 #6
0
 public BlameHunkCollection Blame(string path, BlameOptions options = null)
 {
     return Repository.Blame(path, options ?? new BlameOptions());
 }