コード例 #1
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        } // End Function Commit

        public virtual void CommitAndPush(string path)
        {
            // No empty commit
            if (!HasChanges(path))
            {
                return;
            }

            NGit.Api.Git repository = NGit.Api.Git.Open(path);

            NGit.PersonIdent author  = new NGit.PersonIdent("Lance Mcnearney", "*****@*****.**");
            string           message = "My commit message";

            // Commit our changes after adding files to the stage
            NGit.Revwalk.RevCommit commit = repository.Commit()
                                            .SetMessage(message)
                                            .SetAuthor(author)
                                            .SetAll(true) // This automatically stages modified and deleted files
                                            .Call();

            // Our new commit's hash
            NGit.ObjectId hash = commit.Id;

            // Push our changes back to the origin
            Sharpen.Iterable <NGit.Transport.PushResult> push = repository.Push().Call();
            CloseRepository(repository);
        } // End Sub CommitAndPush
コード例 #2
0
ファイル: CherryPickResult.cs プロジェクト: LunarLanding/ngit
		/// <param name="newHead">commit the head points at after this cherry-pick</param>
		/// <param name="cherryPickedRefs">list of successfully cherry-picked <code>Ref</code>'s
		/// 	</param>
		public CherryPickResult(RevCommit newHead, IList<Ref> cherryPickedRefs)
		{
			this.status = CherryPickResult.CherryPickStatus.OK;
			this.newHead = newHead;
			this.cherryPickedRefs = cherryPickedRefs;
			this.failingPaths = null;
		}
コード例 #3
0
ファイル: ResetCommandTest.cs プロジェクト: shoff/ngit
		/// <exception cref="System.IO.IOException"></exception>
		/// <exception cref="NGit.Api.Errors.NoFilepatternException"></exception>
		/// <exception cref="NGit.Api.Errors.NoHeadException"></exception>
		/// <exception cref="NGit.Api.Errors.NoMessageException"></exception>
		/// <exception cref="NGit.Api.Errors.ConcurrentRefUpdateException"></exception>
		/// <exception cref="NGit.Api.Errors.JGitInternalException"></exception>
		/// <exception cref="NGit.Api.Errors.WrongRepositoryStateException"></exception>
		public virtual void SetupRepository()
		{
			// create initial commit
			git = new Git(db);
			initialCommit = git.Commit().SetMessage("initial commit").Call();
			// create file
			indexFile = new FilePath(db.WorkTree, "a.txt");
			FileUtils.CreateNewFile(indexFile);
			PrintWriter writer = new PrintWriter(indexFile);
			writer.Write("content");
			writer.Flush();
			// add file and commit it
			git.Add().AddFilepattern("a.txt").Call();
			secondCommit = git.Commit().SetMessage("adding a.txt").Call();
			prestage = DirCache.Read(db.GetIndexFile(), db.FileSystem).GetEntry(indexFile.GetName
				());
			// modify file and add to index
			writer.Write("new content");
			writer.Close();
			git.Add().AddFilepattern("a.txt").Call();
			// create a file not added to the index
			untrackedFile = new FilePath(db.WorkTree, "notAddedToIndex.txt");
			FileUtils.CreateNewFile(untrackedFile);
			PrintWriter writer2 = new PrintWriter(untrackedFile);
			writer2.Write("content");
			writer2.Close();
		}
コード例 #4
0
		/// <summary>Core validation to be performed on all stashed commits</summary>
		/// <param name="commit"></param>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		private void ValidateStashedCommit(RevCommit commit)
		{
			NUnit.Framework.Assert.IsNotNull(commit);
			Ref stashRef = db.GetRef(Constants.R_STASH);
			NUnit.Framework.Assert.IsNotNull(stashRef);
			NUnit.Framework.Assert.AreEqual(commit, stashRef.GetObjectId());
			NUnit.Framework.Assert.IsNotNull(commit.GetAuthorIdent());
			NUnit.Framework.Assert.AreEqual(commit.GetAuthorIdent(), commit.GetCommitterIdent
				());
			NUnit.Framework.Assert.AreEqual(2, commit.ParentCount);
			// Load parents
			RevWalk walk = new RevWalk(db);
			try
			{
				foreach (RevCommit parent in commit.Parents)
				{
					walk.ParseBody(parent);
				}
			}
			finally
			{
				walk.Release();
			}
			NUnit.Framework.Assert.AreEqual(1, commit.GetParent(1).ParentCount);
			NUnit.Framework.Assert.AreEqual(head, commit.GetParent(1).GetParent(0));
			NUnit.Framework.Assert.IsFalse(commit.Tree.Equals(head.Tree), "Head tree matches stashed commit tree"
				);
			NUnit.Framework.Assert.AreEqual(head, commit.GetParent(0));
			NUnit.Framework.Assert.IsFalse(commit.GetFullMessage().Equals(commit.GetParent(1)
				.GetFullMessage()));
		}
コード例 #5
0
ファイル: RevCommit.cs プロジェクト: TetradogOther/NGit
 internal static void CarryFlags(NGit.Revwalk.RevCommit c, int carry)
 {
     for (; ;)
     {
         NGit.Revwalk.RevCommit[] pList = c.parents;
         if (pList == null)
         {
             return;
         }
         int n = pList.Length;
         if (n == 0)
         {
             return;
         }
         for (int i = 1; i < n; i++)
         {
             NGit.Revwalk.RevCommit p = pList[i];
             if ((p.flags & carry) == carry)
             {
                 continue;
             }
             p.flags |= carry;
             CarryFlags(p, carry);
         }
         c = pList[0];
         if ((c.flags & carry) == carry)
         {
             return;
         }
         c.flags |= carry;
     }
 }
コード例 #6
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        } // End Function Commit

        public virtual string Commit(string path, string message)
        {
            string commitId = null;

            // No empty commit
            if (!HasChanges(path))
            {
                return(commitId);
            }

            NGit.Api.Git repository = NGit.Api.Git.Open(path);

            NGit.PersonIdent author = new NGit.PersonIdent("FooBar2000", "*****@*****.**");

            // Commit our changes after adding files to the stage
            NGit.Revwalk.RevCommit commit = repository.Commit()
                                            .SetMessage(message)
                                            .SetAuthor(author)
                                            .SetAll(true) // This automatically stages modified and deleted files
                                            .Call();

            // Our new commit's hash
            NGit.ObjectId hash = commit.Id;
            commitId = hash.Name;

            CloseRepository(repository);

            return(commitId);
        } // End Function Commit
コード例 #7
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        } // End Function GetRemoteBranchId

        // http://stackoverflow.com/questions/3407575/retrieving-oldest-commit-with-jgit
        public virtual System.DateTime GetLastCommitDate(string path)
        {
            System.DateTime retVal = default(System.DateTime);

            NGit.Revwalk.RevCommit c          = null;
            NGit.Api.Git           repository = NGit.Api.Git.Open(path);


            try
            {
                NGit.Revwalk.RevWalk rw = new NGit.Revwalk.RevWalk(repository.GetRepository());

                NGit.AnyObjectId headid = repository.GetRepository().Resolve(NGit.Constants.HEAD);
                c = rw.ParseCommit(headid);

                // repository.GetRepository().
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            // Get author
            NGit.PersonIdent authorIdent = c.GetAuthorIdent();
            System.DateTime  authorDate  = authorIdent.GetWhen();

            retVal = authorDate.ToUniversalTime();

            CloseRepository(repository);

            return(retVal);
        }
コード例 #8
0
ファイル: AbstractRevQueue.cs プロジェクト: LunarLanding/ngit
		/// <summary>Add a commit if it does not have a flag set yet, then set the flag.</summary>
		/// <remarks>
		/// Add a commit if it does not have a flag set yet, then set the flag.
		/// <p>
		/// This method permits the application to test if the commit has the given
		/// flag; if it does not already have the flag than the commit is added to
		/// the queue and the flag is set. This later will prevent the commit from
		/// being added twice.
		/// </remarks>
		/// <param name="c">commit to add.</param>
		/// <param name="queueControl">flag that controls admission to the queue.</param>
		public void Add(RevCommit c, RevFlag queueControl)
		{
			if (!c.Has(queueControl))
			{
				c.Add(queueControl);
				Add(c);
			}
		}
コード例 #9
0
ファイル: SkipRevFilter.cs プロジェクト: LunarLanding/ngit
		/// <exception cref="NGit.Errors.StopWalkException"></exception>
		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public override bool Include(RevWalk walker, RevCommit cmit)
		{
			if (skip > count++)
			{
				return false;
			}
			return true;
		}
コード例 #10
0
ファイル: GitUtil.cs プロジェクト: llucenic/monodevelop
		/// <summary>
		/// Compares two commits and returns a list of files that have changed
		/// </summary>
		public static IEnumerable<DiffEntry> CompareCommits (NGit.Repository repo, RevCommit reference, RevCommit compared)
		{
			var changes = new List<DiffEntry>();
			if (reference == null && compared == null)
				return changes;
			ObjectId refTree = (reference != null ? reference.Tree.Id : ObjectId.ZeroId);
			ObjectId comparedTree = (compared != null ? compared.Tree.Id : ObjectId.ZeroId);
			return CompareCommits (repo, refTree, comparedTree);
		}
コード例 #11
0
		/// <exception cref="NGit.Errors.StopWalkException"></exception>
		/// <exception cref="NGit.Errors.MissingObjectException"></exception>
		/// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public override bool Include(RevWalk walker, RevCommit cmit)
		{
			count++;
			if (count > maxCount)
			{
				throw StopWalkException.INSTANCE;
			}
			return true;
		}
コード例 #12
0
		public override void SetUp()
		{
			base.SetUp();
			git = Git.Wrap(db);
			committedFile = WriteTrashFile(PATH, "content");
			git.Add().AddFilepattern(PATH).Call();
			head = git.Commit().SetMessage("add file").Call();
			NUnit.Framework.Assert.IsNotNull(head);
		}
コード例 #13
0
ファイル: PlotCommitListTest.cs プロジェクト: shoff/ngit
			public virtual PlotCommitListTest.CommitListAssert Commit(RevCommit id)
			{
				NUnit.Framework.Assert.IsTrue(this.pcl.Count > this.nextIndex, "Unexpected end of list at pos#"
					 + this.nextIndex);
				this.current = this.pcl[this.nextIndex++];
				NUnit.Framework.Assert.AreEqual(id.Id, this.current.Id, "Expected commit not found at pos#"
					 + (this.nextIndex - 1));
				return this;
			}
コード例 #14
0
ファイル: GitUtil.cs プロジェクト: joaonunesk/monodevelop
		/// <summary>
		/// Returns a list of files that have changed in a commit
		/// </summary>
		public static IEnumerable<Change> GetCommitChanges (NGit.Repository repo, RevCommit commit)
		{
			var treeIds = new[] { commit.Tree.Id }.Concat (commit.Parents.Select (c => c.Tree.Id)).ToArray ();
			var walk = new TreeWalk (repo);
			walk.Reset (treeIds);
			walk.Recursive = true;
			walk.Filter = AndTreeFilter.Create (AndTreeFilter.ANY_DIFF, AndTreeFilter.ALL);
			
			return CalculateCommitDiff (repo, walk, new[] { commit }.Concat (commit.Parents).ToArray ());
		}
コード例 #15
0
ファイル: RevCommit.cs プロジェクト: TetradogOther/NGit
        /// <summary>Parse a commit from its canonical format.</summary>
        /// <remarks>
        /// Parse a commit from its canonical format.
        /// This method inserts the commit directly into the caller supplied revision
        /// pool, making it appear as though the commit exists in the repository,
        /// even if it doesn't.  The repository under the pool is not affected.
        /// </remarks>
        /// <param name="rw">
        /// the revision pool to allocate the commit within. The commit's
        /// tree and parent pointers will be obtained from this pool.
        /// </param>
        /// <param name="raw">the canonical formatted commit to be parsed.</param>
        /// <returns>
        /// the parsed commit, in an isolated revision pool that is not
        /// available to the caller.
        /// </returns>
        public static NGit.Revwalk.RevCommit Parse(RevWalk rw, byte[] raw)
        {
            ObjectInserter.Formatter fmt = new ObjectInserter.Formatter();
            bool retain = rw.IsRetainBody();

            rw.SetRetainBody(true);
            NGit.Revwalk.RevCommit r = rw.LookupCommit(fmt.IdFor(Constants.OBJ_COMMIT, raw));
            r.ParseCanonical(rw, raw);
            rw.SetRetainBody(retain);
            return(r);
        }
コード例 #16
0
ファイル: RefDirectoryTest.cs プロジェクト: JamesChan/ngit
 public override void SetUp()
 {
     base.SetUp();
     diskRepo = CreateBareRepository();
     refdir = (RefDirectory)diskRepo.RefDatabase;
     repo = new TestRepository<Repository>(diskRepo);
     A = repo.Commit().Create();
     B = repo.Commit(repo.GetRevWalk().ParseCommit(A));
     v1_0 = repo.Tag("v1_0", B);
     repo.GetRevWalk().ParseBody(v1_0);
 }
コード例 #17
0
		public virtual void TestCommit()
		{
			Git git = new Git(db);
			revCommit = git.Commit().SetMessage("squash_me").Call();
			Ref master = db.GetRef("refs/heads/master");
			string message = msgFormatter.Format(Arrays.AsList(revCommit), master);
			NUnit.Framework.Assert.AreEqual("Squashed commit of the following:\n\ncommit " + 
				revCommit.GetName() + "\nAuthor: " + revCommit.GetAuthorIdent().GetName() + " <"
				 + revCommit.GetAuthorIdent().GetEmailAddress() + ">\nDate:   " + dateFormatter.
				FormatDate(author) + "\n\n\tsquash_me\n", message);
		}
コード例 #18
0
		public override void Add(RevCommit c)
		{
			BlockRevQueue.Block b = head;
			if (b == null || !b.CanUnpop())
			{
				b = free.NewBlock();
				b.ResetToEnd();
				b.next = head;
				head = b;
			}
			b.Unpop(c);
		}
コード例 #19
0
ファイル: NotesCommandTest.cs プロジェクト: shoff/ngit
		public override void SetUp()
		{
			base.SetUp();
			git = new Git(db);
			// commit something
			WriteTrashFile(FILE, "Hello world");
			git.Add().AddFilepattern(FILE).Call();
			commit1 = git.Commit().SetMessage("Initial commit").Call();
			git.Rm().AddFilepattern(FILE).Call();
			commit2 = git.Commit().SetMessage("Removed file").Call();
			git.NotesAdd().SetObjectId(commit1).SetMessage("data").Call();
		}
コード例 #20
0
		/// <exception cref="System.InvalidOperationException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		private void CheckoutCommit(RevCommit commit)
		{
			RevWalk walk = new RevWalk(db);
			RevCommit head = walk.ParseCommit(db.Resolve(Constants.HEAD));
			DirCacheCheckout dco = new DirCacheCheckout(db, head.Tree, db.LockDirCache(), commit
				.Tree);
			dco.SetFailOnConflict(true);
			dco.Checkout();
			walk.Release();
			// update the HEAD
			RefUpdate refUpdate = db.UpdateRef(Constants.HEAD, true);
			refUpdate.SetNewObjectId(commit);
			refUpdate.ForceUpdate();
		}
コード例 #21
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        // https://stackoverflow.com/questions/45793800/jgit-read-the-content-of-a-file-at-a-commit-in-a-branch
        private string GetFileContent(string repositoryPath, string path, NGit.Revwalk.RevCommit commit)
        {
            NGit.Api.Git repository = NGit.Api.Git.Open(repositoryPath);

            NGit.Treewalk.TreeWalk treeWalk = NGit.Treewalk.TreeWalk.ForPath(
                repository.GetRepository(), path, commit.Tree);

            NGit.ObjectId blobId = treeWalk.GetObjectId(0);

            NGit.ObjectReader objectReader = repository.GetRepository().NewObjectReader();
            NGit.ObjectLoader objectLoader = objectReader.Open(blobId);

            byte[] bytes = objectLoader.GetBytes();
            return(System.Text.Encoding.UTF8.GetString(bytes));
        }
コード例 #22
0
 public static List<DiffEntry> diff_Commits(this API_NGit nGit, RevCommit from_RevCommit, RevCommit to_RevCommit)
 {
     if (nGit.repository().notNull())
         try
         {
             var outputStream = NGit_Factory.New_OutputStream();
             var diffFormater = new DiffFormatter(outputStream);
             diffFormater.SetRepository(nGit.repository());
             return diffFormater.Scan(from_RevCommit, to_RevCommit).toList();
         }
         catch (Exception ex)
         {
             ex.log("[API_NGit][diff]");
         }
     return new List<DiffEntry>();
 }
コード例 #23
0
ファイル: GitUtil.cs プロジェクト: stewartwhaley/monodevelop
		/// <summary>
		/// Compares two commits and returns a list of files that have changed
		/// </summary>
		public static IEnumerable<Change> CompareCommits (NGit.Repository repo, RevCommit reference, RevCommit compared)
		{
			var changes = new List<Change>();
			if (reference == null && compared == null)
				return changes;
			ObjectId refTree = (reference != null ? reference.Tree.Id : ObjectId.ZeroId);
			ObjectId comparedTree = (compared != null ? compared.Tree.Id : ObjectId.ZeroId);
			var walk = new TreeWalk (repo);
			if (reference == null || compared == null)
				walk.Reset ((reference ?? compared).Tree.Id);
			else
				walk.Reset (new AnyObjectId[] {refTree, comparedTree});
			walk.Recursive = true;
			walk.Filter = AndTreeFilter.Create(TreeFilter.ANY_DIFF, TreeFilter.ALL);

			return CalculateCommitDiff (repo, walk, new[] { reference, compared });
		}
コード例 #24
0
		public override void SetUp()
		{
			base.SetUp();
			git = new Git(db);
			// commit something
			WriteTrashFile("Test.txt", "Hello world");
			git.Add().AddFilepattern("Test.txt").Call();
			initialCommit = git.Commit().SetMessage("Initial commit").Call();
			// create a master branch and switch to it
			git.BranchCreate().SetName("test").Call();
			RefUpdate rup = db.UpdateRef(Constants.HEAD);
			rup.Link("refs/heads/test");
			// commit something on the test branch
			WriteTrashFile("Test.txt", "Some change");
			git.Add().AddFilepattern("Test.txt").Call();
			secondCommit = git.Commit().SetMessage("Second commit").Call();
		}
コード例 #25
0
		public override void SetUp()
		{
			base.SetUp();
			git = new Git(db);
			WriteTrashFile(FILE1, "1");
			WriteTrashFile(FILE2, "a");
			git.Add().AddFilepattern(FILE1).AddFilepattern(FILE2).Call();
			initialCommit = git.Commit().SetMessage("Initial commit").Call();
			WriteTrashFile(FILE1, "2");
			WriteTrashFile(FILE2, "b");
			git.Add().AddFilepattern(FILE1).AddFilepattern(FILE2).Call();
			secondCommit = git.Commit().SetMessage("Second commit").Call();
			WriteTrashFile(FILE1, "3");
			WriteTrashFile(FILE2, "c");
			git.Add().AddFilepattern(FILE1).AddFilepattern(FILE2).Call();
			git.Commit().SetMessage("Third commit").Call();
		}
コード例 #26
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        // http://stackoverflow.com/questions/3407575/retrieving-oldest-commit-with-jgit
        public virtual void GetOldestCommit(string path)
        {
            NGit.Revwalk.RevCommit c          = null;
            NGit.Api.Git           repository = NGit.Api.Git.Open(path);


            try
            {
                NGit.Revwalk.RevWalk rw = new NGit.Revwalk.RevWalk(repository.GetRepository());

                NGit.AnyObjectId       headid = repository.GetRepository().Resolve(NGit.Constants.HEAD);
                NGit.Revwalk.RevCommit root   = rw.ParseCommit(headid);

                string msg1 = root.GetFullMessage();


                rw.Sort(NGit.Revwalk.RevSort.REVERSE);

                rw.MarkStart(root);
                c = rw.Next();
                // repository.GetRepository().
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            string msg2 = c.GetFullMessage();

            // Get author
            NGit.PersonIdent    authorIdent    = c.GetAuthorIdent();
            System.DateTime     authorDate     = authorIdent.GetWhen();
            System.TimeZoneInfo authorTimeZone = authorIdent.GetTimeZone();

            NGit.PersonIdent committerIdent = c.GetCommitterIdent();
            // http://stackoverflow.com/questions/12608610/how-do-you-get-the-author-date-and-commit-date-from-a-jgit-revcommit

            System.Console.WriteLine(authorIdent);
            System.Console.WriteLine(authorDate);
            System.Console.WriteLine(authorTimeZone);
            System.Console.WriteLine(committerIdent);

            CloseRepository(repository);
        }
コード例 #27
0
 /// <summary>Create a new sorter and completely spin the generator.</summary>
 /// <remarks>
 /// Create a new sorter and completely spin the generator.
 /// <p>
 /// When the constructor completes the supplied generator will have no
 /// commits remaining, as all of the commits will be held inside of this
 /// generator's internal buffer.
 /// </remarks>
 /// <param name="s">generator to pull all commits out of, and into this buffer.</param>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 ///     </exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 ///     </exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 internal TopoSortGenerator(Generator s)
 {
     pending    = new FIFORevQueue();
     outputType = s.OutputType() | SORT_TOPO;
     s.ShareFreeList(pending);
     for (; ;)
     {
         RevCommit c = s.Next();
         if (c == null)
         {
             break;
         }
         foreach (RevCommit p in c.parents)
         {
             p.inDegree++;
         }
         pending.Add(c);
     }
 }
コード例 #28
0
        public virtual void TestSort_TOPO()
        {
            // c1 is back dated before its parent.
            //
            RevCommit a  = Commit();
            RevCommit b  = Commit(a);
            RevCommit c1 = Commit(-5, b);
            RevCommit c2 = Commit(10, b);
            RevCommit d  = Commit(c1, c2);

            rw.Sort(RevSort.TOPO);
            MarkStart(d);
            AssertCommit(d, rw.Next());
            AssertCommit(c2, rw.Next());
            AssertCommit(c1, rw.Next());
            AssertCommit(b, rw.Next());
            AssertCommit(a, rw.Next());
            NUnit.Framework.Assert.IsNull(rw.Next());
        }
コード例 #29
0
		public override void SetUp()
		{
			base.SetUp();
			git = new Git(db);
			// checkout master
			git.Commit().SetMessage("initial commit").Call();
			// commit something
			WriteTrashFile("Test.txt", "Hello world");
			git.Add().AddFilepattern("Test.txt").Call();
			initialCommit = git.Commit().SetMessage("Initial commit").Call();
			WriteTrashFile("Test.txt", "Some change");
			git.Add().AddFilepattern("Test.txt").Call();
			secondCommit = git.Commit().SetMessage("Second commit").Call();
			// create a master branch
			RefUpdate rup = db.UpdateRef("refs/heads/master");
			rup.SetNewObjectId(initialCommit.Id);
			rup.SetForceUpdate(true);
			rup.Update();
		}
コード例 #30
0
ファイル: FIFORevQueue.cs プロジェクト: TetradogOther/NGit
        internal override RevCommit Next()
        {
            BlockRevQueue.Block b = head;
            if (b == null)
            {
                return(null);
            }
            RevCommit c = b.Pop();

            if (b.IsEmpty())
            {
                head = b.next;
                if (head == null)
                {
                    tail = null;
                }
                free.FreeBlock(b);
            }
            return(c);
        }
コード例 #31
0
        public virtual void TestSort_COMMIT_TIME_DESC_OutOfOrder1()
        {
            // Despite being out of order time-wise, a strand-of-pearls must
            // still maintain topological order.
            //
            RevCommit a = Commit();
            RevCommit b = Commit(a);
            RevCommit c = Commit(-5, b);
            RevCommit d = Commit(10, c);

            NUnit.Framework.Assert.IsTrue(ParseBody(a).CommitTime < ParseBody(d).CommitTime);
            NUnit.Framework.Assert.IsTrue(ParseBody(c).CommitTime < ParseBody(b).CommitTime);
            rw.Sort(RevSort.COMMIT_TIME_DESC);
            MarkStart(d);
            AssertCommit(d, rw.Next());
            AssertCommit(c, rw.Next());
            AssertCommit(b, rw.Next());
            AssertCommit(a, rw.Next());
            NUnit.Framework.Assert.IsNull(rw.Next());
        }
コード例 #32
0
        public virtual void TestCloneFIFO()
        {
            RevCommit    a   = ParseBody(Commit());
            RevCommit    b   = ParseBody(Commit(200, a));
            RevCommit    c   = ParseBody(Commit(200, b));
            FIFORevQueue src = new FIFORevQueue();

            src.Add(a);
            src.Add(b);
            src.Add(c);
            q = new DateRevQueue(src);
            NUnit.Framework.Assert.IsFalse(q.EverbodyHasFlag(RevWalk.UNINTERESTING));
            NUnit.Framework.Assert.IsFalse(q.AnybodyHasFlag(RevWalk.UNINTERESTING));
            AssertCommit(c, q.Peek());
            AssertCommit(c, q.Peek());
            AssertCommit(c, q.Next());
            AssertCommit(b, q.Next());
            AssertCommit(a, q.Next());
            NUnit.Framework.Assert.IsNull(q.Next());
        }
コード例 #33
0
        public virtual void TestCrissCross()
        {
            // See http://marc.info/?l=git&m=111463358500362&w=2 for a nice
            // description of what this test is creating. We don't have a
            // clean merge base for d,e as they each merged the parents b,c
            // in different orders.
            //
            RevCommit a = Commit();
            RevCommit b = Commit(a);
            RevCommit c = Commit(a);
            RevCommit d = Commit(b, c);
            RevCommit e = Commit(c, b);

            rw.SetRevFilter(RevFilter.MERGE_BASE);
            MarkStart(d);
            MarkStart(e);
            AssertCommit(c, rw.Next());
            AssertCommit(b, rw.Next());
            NUnit.Framework.Assert.IsNull(rw.Next());
        }
コード例 #34
0
        public virtual void TestMatchesBugId()
        {
            RevCommit commit = Parse("this is a commit subject for test\n" + "\n" + "Simple-Bug-Id: 42\n"
                                     );
            // paragraph break, now footers appear in final block
            IList <FooterLine> footers = commit.GetFooterLines();

            NUnit.Framework.Assert.IsNotNull(footers);
            NUnit.Framework.Assert.AreEqual(1, footers.Count);
            FooterLine line = footers[0];

            NUnit.Framework.Assert.IsNotNull(line);
            NUnit.Framework.Assert.AreEqual("Simple-Bug-Id", line.GetKey());
            NUnit.Framework.Assert.AreEqual("42", line.GetValue());
            FooterKey bugid = new FooterKey("Simple-Bug-Id");

            NUnit.Framework.Assert.IsTrue(line.Matches(bugid), "matches Simple-Bug-Id");
            NUnit.Framework.Assert.IsFalse(line.Matches(FooterKey.SIGNED_OFF_BY), "not Signed-off-by"
                                           );
            NUnit.Framework.Assert.IsFalse(line.Matches(FooterKey.CC), "not CC");
        }
コード例 #35
0
        public virtual void TestMaxCountRevFilter()
        {
            RevCommit a  = Commit();
            RevCommit b  = Commit(a);
            RevCommit c1 = Commit(b);
            RevCommit c2 = Commit(b);
            RevCommit d  = Commit(c1, c2);
            RevCommit e  = Commit(d);

            rw.Reset();
            rw.SetRevFilter(MaxCountRevFilter.Create(3));
            MarkStart(e);
            AssertCommit(e, rw.Next());
            AssertCommit(d, rw.Next());
            AssertCommit(c2, rw.Next());
            NUnit.Framework.Assert.IsNull(rw.Next());
            rw.Reset();
            rw.SetRevFilter(MaxCountRevFilter.Create(0));
            MarkStart(e);
            NUnit.Framework.Assert.IsNull(rw.Next());
        }
コード例 #36
0
        public virtual void TestTwoCommitTwoTreeTwoBlob()
        {
            RevBlob   f0 = Blob("0");
            RevBlob   f1 = Blob("1");
            RevBlob   f2 = Blob("0v2");
            RevTree   ta = Tree(File("0", f0), File("1", f1), File("2", f1));
            RevTree   tb = Tree(File("0", f2), File("1", f1), File("2", f1));
            RevCommit a  = Commit(ta);
            RevCommit b  = Commit(tb, a);

            MarkStart(b);
            AssertCommit(b, objw.Next());
            AssertCommit(a, objw.Next());
            NUnit.Framework.Assert.IsNull(objw.Next());
            NUnit.Framework.Assert.AreSame(tb, objw.NextObject());
            NUnit.Framework.Assert.AreSame(f2, objw.NextObject());
            NUnit.Framework.Assert.AreSame(f1, objw.NextObject());
            NUnit.Framework.Assert.AreSame(ta, objw.NextObject());
            NUnit.Framework.Assert.AreSame(f0, objw.NextObject());
            NUnit.Framework.Assert.IsNull(objw.NextObject());
        }
コード例 #37
0
 public virtual void TestInsertTie()
 {
     RevCommit a = ParseBody(Commit());
     RevCommit b = ParseBody(Commit(0, a));
     {
         q = Create();
         q.Add(a);
         q.Add(b);
         AssertCommit(a, q.Next());
         AssertCommit(b, q.Next());
         NUnit.Framework.Assert.IsNull(q.Next());
     }
     {
         q = Create();
         q.Add(b);
         q.Add(a);
         AssertCommit(b, q.Next());
         AssertCommit(a, q.Next());
         NUnit.Framework.Assert.IsNull(q.Next());
     }
 }
コード例 #38
0
        /// <exception cref="NGit.Errors.MissingObjectException"></exception>
        /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        internal override RevCommit Next()
        {
            while (size < OVER_SCAN)
            {
                RevCommit c = pending.Next();
                if (c == null)
                {
                    break;
                }
                delay.Add(c);
                size++;
            }
            RevCommit c_1 = delay.Next();

            if (c_1 == null)
            {
                return(null);
            }
            size--;
            return(c_1);
        }
コード例 #39
0
            /// <exception cref="NGit.Errors.MissingObjectException"></exception>
            /// <exception cref="NGit.Errors.IncorrectObjectTypeException"></exception>
            /// <exception cref="System.IO.IOException"></exception>
            internal override RevCommit Next()
            {
                RevCommit c = this.source.Next();

                if (c != null)
                {
                    foreach (RevCommit p in c.parents)
                    {
                        if ((p.flags & BoundaryGenerator.UNINTERESTING) != 0)
                        {
                            this.held.Add(p);
                        }
                    }
                    return(c);
                }
                FIFORevQueue boundary = new FIFORevQueue();

                boundary.ShareFreeList(this.held);
                for (; ;)
                {
                    c = this.held.Next();
                    if (c == null)
                    {
                        break;
                    }
                    if ((c.flags & BoundaryGenerator.InitialGenerator.DUPLICATE) != 0)
                    {
                        continue;
                    }
                    if ((c.flags & BoundaryGenerator.InitialGenerator.PARSED) == 0)
                    {
                        c.ParseHeaders(this.walk);
                    }
                    c.flags |= BoundaryGenerator.InitialGenerator.DUPLICATE;
                    boundary.Add(c);
                }
                boundary.RemoveFlag(BoundaryGenerator.InitialGenerator.DUPLICATE);
                this._enclosing.g = boundary;
                return(boundary.Next());
            }
コード例 #40
0
        public virtual void TestRevFilterReceivesParsedCommits()
        {
            RevCommit     a          = Commit();
            RevCommit     b          = Commit(a);
            RevCommit     c          = Commit(b);
            AtomicBoolean filterRan  = new AtomicBoolean();
            RevFilter     testFilter = new _RevFilter_68(filterRan);

            // Do an initial run through the walk
            filterRan.Set(false);
            rw.SetRevFilter(testFilter);
            MarkStart(c);
            rw.MarkUninteresting(b);
            for (RevCommit cmit = rw.Next(); cmit != null; cmit = rw.Next())
            {
            }
            // Don't dispose the body here, because we want to test the effect
            // of marking 'b' as uninteresting.
            NUnit.Framework.Assert.IsTrue(filterRan.Get(), "filter ran");
            // Run through the walk again, this time disposing of all commits.
            filterRan.Set(false);
            rw.Reset();
            MarkStart(c);
            for (RevCommit cmit_1 = rw.Next(); cmit_1 != null; cmit_1 = rw.Next())
            {
                cmit_1.DisposeBody();
            }
            NUnit.Framework.Assert.IsTrue(filterRan.Get(), "filter ran");
            // Do the third run through the reused walk. Test that the explicitly
            // disposed commits are parsed on this walk.
            filterRan.Set(false);
            rw.Reset();
            MarkStart(c);
            for (RevCommit cmit_2 = rw.Next(); cmit_2 != null; cmit_2 = rw.Next())
            {
            }
            // spin through the walk.
            NUnit.Framework.Assert.IsTrue(filterRan.Get(), "filter ran");
        }
コード例 #41
0
        public virtual void TestTwoCommitDeepTree2()
        {
            RevBlob   f1 = Blob("1");
            RevTree   ta = Tree(File("a/b/0", f1), File("a/c/q", f1));
            RevTree   tb = Tree(File("a/b/1", f1), File("a/c/q", f1));
            RevCommit a  = Commit(ta);
            RevCommit b  = Commit(tb, a);

            MarkStart(b);
            AssertCommit(b, objw.Next());
            AssertCommit(a, objw.Next());
            NUnit.Framework.Assert.IsNull(objw.Next());
            NUnit.Framework.Assert.AreSame(tb, objw.NextObject());
            NUnit.Framework.Assert.AreSame(Get(tb, "a"), objw.NextObject());
            NUnit.Framework.Assert.AreSame(Get(tb, "a/b"), objw.NextObject());
            NUnit.Framework.Assert.AreSame(f1, objw.NextObject());
            NUnit.Framework.Assert.AreSame(Get(tb, "a/c"), objw.NextObject());
            NUnit.Framework.Assert.AreSame(ta, objw.NextObject());
            NUnit.Framework.Assert.AreSame(Get(ta, "a"), objw.NextObject());
            NUnit.Framework.Assert.AreSame(Get(ta, "a/b"), objw.NextObject());
            NUnit.Framework.Assert.IsNull(objw.NextObject());
        }
コード例 #42
0
		public override void Add(RevCommit c)
		{
			DateRevQueue.Entry q = head;
			long when = c.commitTime;
			DateRevQueue.Entry n = NewEntry(c);
			if (q == null || when > q.commit.commitTime)
			{
				n.next = q;
				head = n;
			}
			else
			{
				DateRevQueue.Entry p = q.next;
				while (p != null && p.commit.commitTime > when)
				{
					q = p;
					p = q.next;
				}
				n.next = q.next;
				q.next = n;
			}
		}
コード例 #43
0
ファイル: FIFORevQueue.cs プロジェクト: TetradogOther/NGit
 public override void Add(RevCommit c)
 {
     BlockRevQueue.Block b = tail;
     if (b == null)
     {
         b = free.NewBlock();
         b.Add(c);
         head = b;
         tail = b;
         return;
     }
     else
     {
         if (b.IsFull())
         {
             b         = free.NewBlock();
             tail.next = b;
             tail      = b;
         }
     }
     b.Add(c);
 }
コード例 #44
0
		public override void Add(RevCommit c)
		{
			BlockRevQueue.Block b = tail;
			if (b == null)
			{
				b = free.NewBlock();
				b.Add(c);
				head = b;
				tail = b;
				return;
			}
			else
			{
				if (b.IsFull())
				{
					b = free.NewBlock();
					tail.next = b;
					tail = b;
				}
			}
			b.Add(c);
		}
コード例 #45
0
ファイル: DepthGenerator.cs プロジェクト: TetradogOther/NGit
 /// <param name="w"></param>
 /// <param name="s">Parent generator</param>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 ///     </exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 ///     </exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 internal DepthGenerator(DepthWalk w, Generator s)
 {
     pending            = new FIFORevQueue();
     walk               = (RevWalk)w;
     this.depth         = w.GetDepth();
     this.UNSHALLOW     = w.GetUnshallowFlag();
     this.REINTERESTING = w.GetReinterestingFlag();
     s.ShareFreeList(pending);
     // Begin by sucking out all of the source's commits, and
     // adding them to the pending queue
     for (; ;)
     {
         RevCommit c = s.Next();
         if (c == null)
         {
             break;
         }
         if (((NGit.Revwalk.Depthwalk.Commit)c).GetDepth() == 0)
         {
             pending.Add(c);
         }
     }
 }
コード例 #46
0
ファイル: MergeBaseGenerator.cs プロジェクト: shoff/ngit
        private bool CarryOntoOne(RevCommit p, int carry)
        {
            bool haveAll = (p.flags & carry) == carry;

            p.flags |= carry;
            if ((p.flags & recarryMask) == recarryTest)
            {
                // We were popped without being a merge base, but we just got
                // voted to be one. Inject ourselves back at the front of the
                // pending queue and tell all of our ancestors they are within
                // the merge base now.
                //
                p.flags &= ~POPPED;
                pending.Add(p);
                CarryOntoHistory(p, branchMask | MERGE_BASE);
                return(true);
            }
            // If we already had all carried flags, our parents do too.
            // Return true to stop the caller from running down this leg
            // of the revision graph any further.
            //
            return(haveAll);
        }
コード例 #47
0
        public override void Add(RevCommit c)
        {
            DateRevQueue.Entry q = head;
            long when            = c.commitTime;

            DateRevQueue.Entry n = NewEntry(c);
            if (q == null || when > q.commit.commitTime)
            {
                n.next = q;
                head   = n;
            }
            else
            {
                DateRevQueue.Entry p = q.next;
                while (p != null && p.commit.commitTime > when)
                {
                    q = p;
                    p = q.next;
                }
                n.next = q.next;
                q.next = n;
            }
        }
コード例 #48
0
 /// <summary>Verify all interesting objects are available, and reachable.</summary>
 /// <remarks>
 /// Verify all interesting objects are available, and reachable.
 /// <p>
 /// Callers should populate starting points and ending points with
 /// <see cref="MarkStart(RevObject)">MarkStart(RevObject)</see>
 /// and
 /// <see cref="MarkUninteresting(RevObject)">MarkUninteresting(RevObject)</see>
 /// and then use this method to verify all objects between those two points
 /// exist in the repository and are readable.
 /// <p>
 /// This method returns successfully if everything is connected; it throws an
 /// exception if there is a connectivity problem. The exception message
 /// provides some detail about the connectivity failure.
 /// </remarks>
 /// <exception cref="NGit.Errors.MissingObjectException">
 /// one or or more of the next objects are not available from the
 /// object database, but were thought to be candidates for
 /// traversal. This usually indicates a broken link.
 /// </exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">
 /// one or or more of the objects in a tree do not match the type
 /// indicated.
 /// </exception>
 /// <exception cref="System.IO.IOException">a pack file or loose object could not be read.
 ///     </exception>
 public virtual void CheckConnectivity()
 {
     for (; ;)
     {
         RevCommit c = Next();
         if (c == null)
         {
             break;
         }
     }
     for (; ;)
     {
         RevObject o = NextObject();
         if (o == null)
         {
             break;
         }
         if (o is RevBlob && !reader.Has(o))
         {
             throw new MissingObjectException(o, Constants.OBJ_BLOB);
         }
     }
 }
コード例 #49
0
 // Never happen. The filter we use does not throw any
 // exceptions, for any reason.
 /// <summary>Find the next commit that has the given flag set.</summary>
 /// <remarks>Find the next commit that has the given flag set.</remarks>
 /// <param name="flag">the flag to test commits against.</param>
 /// <param name="begin">
 /// first commit index to test at. Applications may wish to begin
 /// at 0, to test the first commit in the list.
 /// </param>
 /// <returns>
 /// index of the first commit at or after index <code>begin</code>
 /// that has the specified flag set on it; -1 if no match is found.
 /// </returns>
 public virtual int IndexOf(RevFlag flag, int begin)
 {
     while (begin < Count)
     {
         int index            = begin;
         RevObjectListBlock s = contents;
         while (s.shift > 0)
         {
             int i = index >> s.shift;
             index -= i << s.shift;
             s      = (RevObjectListBlock)s.contents[i];
         }
         while (begin++ < Count && index < BLOCK_SIZE)
         {
             RevCommit c = (RevCommit)s.contents[index++];
             if (c.Has(flag))
             {
                 return(begin);
             }
         }
     }
     return(-1);
 }
コード例 #50
0
 /// <summary>Find the next commit that has the given flag set.</summary>
 /// <remarks>Find the next commit that has the given flag set.</remarks>
 /// <param name="flag">the flag to test commits against.</param>
 /// <param name="begin">
 /// first commit index to test at. Applications may wish to begin
 /// at <code>size()-1</code>, to test the last commit in the
 /// list.
 /// </param>
 /// <returns>
 /// index of the first commit at or before index <code>begin</code>
 /// that has the specified flag set on it; -1 if no match is found.
 /// </returns>
 public virtual int LastIndexOf(RevFlag flag, int begin)
 {
     begin = Math.Min(begin, Count - 1);
     while (begin >= 0)
     {
         int index            = begin;
         RevObjectListBlock s = contents;
         while (s.shift > 0)
         {
             int i = index >> s.shift;
             index -= i << s.shift;
             s      = (RevObjectListBlock)s.contents[i];
         }
         while (begin-- >= 0 && index >= 0)
         {
             RevCommit c = (RevCommit)s.contents[index--];
             if (c.Has(flag))
             {
                 return(begin);
             }
         }
     }
     return(-1);
 }
コード例 #51
0
        public virtual void TestProperlyCullAllAncestors_LongHistory()
        {
            RevCommit a = Commit();
            RevCommit b = Commit(a);

            for (int i = 0; i < 24; i++)
            {
                b = Commit(b);
                if ((i & 2) == 0)
                {
                    MarkUninteresting(b);
                }
            }
            RevCommit c = Commit(b);

            MarkStart(c);
            MarkUninteresting(b);
            AssertCommit(c, rw.Next());
            NUnit.Framework.Assert.IsNull(rw.Next());
            // We should have aborted before we got back so far that "a"
            // would be parsed. Thus, its parents shouldn't be allocated.
            //
            NUnit.Framework.Assert.IsNull(a.parents);
        }
コード例 #52
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        } // End Sub ListBranches

        // https://stackoverflow.com/questions/40590039/how-to-get-the-file-list-for-a-commit-with-jgit
        // https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/GetRevCommitFromObjectId.java
        public virtual void ListFilesIncmt(string path, NGit.Revwalk.RevCommit commit)
        {
            NGit.Api.Git  repository = NGit.Api.Git.Open(path);
            NGit.ObjectId treeId     = commit.Tree.Id;

            NGit.Treewalk.TreeWalk treeWalk = new NGit.Treewalk.TreeWalk(repository.GetRepository());

            treeWalk.Reset(treeId);

            while (treeWalk.Next())
            {
                string filePath = treeWalk.PathString;
                System.Console.WriteLine(filePath);
            }

            NGit.Ref      @ref = repository.GetRepository().GetRef("refs/heads/master");
            NGit.ObjectId head = @ref.GetObjectId();
            using (NGit.Revwalk.RevWalk walk = new NGit.Revwalk.RevWalk(repository.GetRepository()))
            {
                NGit.Revwalk.RevCommit headCommit = walk.ParseCommit(head);
            }

            NGit.ObjectId commitIdFromHash = repository.GetRepository().Resolve("revstr");
        }
コード例 #53
0
		private string GetFileContent(RevCommit commit, string path)
		{
			return _git.GetFileContent(commit, path);
		}
コード例 #54
0
		private string GetTextFileContentSafe(RevCommit commit, string path)
		{
			try
			{
				return GetFileContent(commit, path);
			}
			catch
			{
				return string.Empty;
			}
		}
コード例 #55
0
		private DiffResult GetDiff(string path, RevCommit parent, RevCommit commit)
		{
			var fileContent = GetTextFileContentSafe(commit, path);
			var previousRevisionFileContent = GetTextFileContentSafe(parent, path);
			var diff = _diffProcessor.GetDiff(previousRevisionFileContent, fileContent);

			diff.LeftPanRevisionId = parent.Id.Name;
			diff.RightPanRevisionId = commit.Id.Name;

			return diff;
		}
コード例 #56
0
ファイル: BundleWriter.cs プロジェクト: LunarLanding/ngit
		/// <summary>Assume a commit is available on the recipient's side.</summary>
		/// <remarks>
		/// Assume a commit is available on the recipient's side.
		/// <p>
		/// In order to fetch from a bundle the recipient must have any assumed
		/// commit. Each assumed commit is explicitly recorded in the bundle header
		/// to permit the recipient to validate it has these objects.
		/// </remarks>
		/// <param name="c">
		/// the commit to assume being available. This commit should be
		/// parsed and not disposed in order to maximize the amount of
		/// debugging information available in the bundle stream.
		/// </param>
		public virtual void Assume(RevCommit c)
		{
			if (c != null)
			{
				assume.AddItem(c);
			}
		}
コード例 #57
0
ファイル: RevWalkUtils.cs プロジェクト: asperwin/ngit
 /// <summary>
 /// Find commits that are reachable from <code>start</code> until a commit
 /// that is reachable from <code>end</code> is encountered.
 /// </summary>
 /// <remarks>
 /// Find commits that are reachable from <code>start</code> until a commit
 /// that is reachable from <code>end</code> is encountered. In other words,
 /// Find of commits that are in <code>start</code>, but not in
 /// <code>end</code>.
 /// <p>
 /// Note that this method calls
 /// <see cref="RevWalk.Reset()">RevWalk.Reset()</see>
 /// at the beginning.
 /// Also note that the existing rev filter on the walk is left as-is, so be
 /// sure to set the right rev filter before calling this method.
 /// </remarks>
 /// <param name="walk">the rev walk to use</param>
 /// <param name="start">the commit to start counting from</param>
 /// <param name="end">
 /// the commit where counting should end, or null if counting
 /// should be done until there are no more commits
 /// </param>
 /// <returns>the commits found</returns>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 /// 	</exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 /// 	</exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 public static IList<RevCommit> Find(RevWalk walk, RevCommit start, RevCommit end)
 {
     walk.Reset();
     walk.MarkStart(start);
     if (end != null)
     {
         walk.MarkUninteresting(end);
     }
     IList<RevCommit> commits = new AList<RevCommit>();
     foreach (RevCommit c in walk)
     {
         commits.AddItem(c);
     }
     return commits;
 }
コード例 #58
0
ファイル: RevWalkUtils.cs プロジェクト: asperwin/ngit
 // Utility class
 /// <summary>
 /// Count the number of commits that are reachable from <code>start</code>
 /// until a commit that is reachable from <code>end</code> is encountered.
 /// </summary>
 /// <remarks>
 /// Count the number of commits that are reachable from <code>start</code>
 /// until a commit that is reachable from <code>end</code> is encountered. In
 /// other words, count the number of commits that are in <code>start</code>,
 /// but not in <code>end</code>.
 /// <p>
 /// Note that this method calls
 /// <see cref="RevWalk.Reset()">RevWalk.Reset()</see>
 /// at the beginning.
 /// Also note that the existing rev filter on the walk is left as-is, so be
 /// sure to set the right rev filter before calling this method.
 /// </remarks>
 /// <param name="walk">the rev walk to use</param>
 /// <param name="start">the commit to start counting from</param>
 /// <param name="end">
 /// the commit where counting should end, or null if counting
 /// should be done until there are no more commits
 /// </param>
 /// <returns>the number of commits</returns>
 /// <exception cref="NGit.Errors.MissingObjectException">NGit.Errors.MissingObjectException
 /// 	</exception>
 /// <exception cref="NGit.Errors.IncorrectObjectTypeException">NGit.Errors.IncorrectObjectTypeException
 /// 	</exception>
 /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
 public static int Count(RevWalk walk, RevCommit start, RevCommit end)
 {
     return Find(walk, start, end).Count;
 }
コード例 #59
0
		public override void SetUp()
		{
			base.SetUp();
			// Test graph was stolen from git-core t6012-rev-list-simplify
			// (by Junio C Hamano in 65347030590bcc251a9ff2ed96487a0f1b9e9fa8)
			//
			RevBlob zF = Blob("zF");
			RevBlob zH = Blob("zH");
			RevBlob zI = Blob("zI");
			RevBlob zS = Blob("zS");
			RevBlob zY = Blob("zY");
			a = Commit(Tree(File(pF, zH)));
			b = Commit(Tree(File(pF, zI)), a);
			c = Commit(Tree(File(pF, zI)), a);
			d = Commit(Tree(File(pA, zS), File(pF, zI)), c);
			ParseBody(d);
			e = Commit(d.Tree, d, b);
			f = Commit(Tree(File(pA, zS), File(pE, zY), File(pF, zI)), e);
			ParseBody(f);
			g = Commit(Tree(File(pE, zY), File(pF, zI)), b);
			h = Commit(f.Tree, g, f);
			i = Commit(Tree(File(pA, zS), File(pE, zY), File(pF, zF)), h);
			byName = new Dictionary<RevCommit, string>();
			foreach (FieldInfo z in Sharpen.Runtime.GetDeclaredFields(typeof(RevWalkPathFilter6012Test
				)))
			{
				if (z.FieldType == typeof(RevCommit))
				{
					byName.Put((RevCommit)z.GetValue(this), z.Name);
				}
			}
		}
コード例 #60
0
		/// <summary>Obtain the raw text to match against.</summary>
		/// <remarks>Obtain the raw text to match against.</remarks>
		/// <param name="cmit">current commit being evaluated.</param>
		/// <returns>sequence for the commit's content that we need to match on.</returns>
		protected internal abstract RawCharSequence Text(RevCommit cmit);