Example #1
0
        /// <summary>
        /// Generate a list of lines with information about when the lines were
        /// introduced into the file path.
        /// </summary>
        /// <remarks>
        /// Generate a list of lines with information about when the lines were
        /// introduced into the file path.
        /// </remarks>
        /// <returns>list of lines</returns>
        /// <exception cref="NGit.Api.Errors.GitAPIException"></exception>
        public override BlameResult Call()
        {
            CheckCallable();
            BlameGenerator gen = new BlameGenerator(repo, path);

            try
            {
                if (diffAlgorithm != null)
                {
                    gen.SetDiffAlgorithm(diffAlgorithm);
                }
                if (textComparator != null)
                {
                    gen.SetTextComparator(textComparator);
                }
                if (followFileRenames != null)
                {
                    gen.SetFollowFileRenames(followFileRenames);
                }
                if (reverseEndCommits != null)
                {
                    gen.Reverse(startCommit, reverseEndCommits);
                }
                else
                {
                    if (startCommit != null)
                    {
                        gen.Push(null, startCommit);
                    }
                    else
                    {
                        gen.Push(null, repo.Resolve(Constants.HEAD));
                        if (!repo.IsBare)
                        {
                            DirCache dc    = repo.ReadDirCache();
                            int      entry = dc.FindEntry(path);
                            if (0 <= entry)
                            {
                                gen.Push(null, dc.GetEntry(entry).GetObjectId());
                            }
                            FilePath inTree = new FilePath(repo.WorkTree, path);
                            if (inTree.IsFile())
                            {
                                gen.Push(null, new RawText(inTree));
                            }
                        }
                    }
                }
                return(gen.ComputeBlameResult());
            }
            catch (IOException e)
            {
                throw new JGitInternalException(e.Message, e);
            }
            finally
            {
                gen.Release();
            }
        }