/// <exception cref="System.IO.IOException"></exception> public override void Checkout() { GitIndex index = db.GetIndex(); wdc = new WorkDirCheckout(db, db.WorkTree, theHead, index, theMerge); wdc.Checkout(); index.Write(); }
public virtual void TestCheckingOutWithConflicts() { GitIndex index = new GitIndex(db); index.Add(trash, WriteTrashFile("bar", "bar")); index.Add(trash, WriteTrashFile("foo/bar/baz/qux", "foo/bar")); RecursiveDelete(new FilePath(trash, "bar")); RecursiveDelete(new FilePath(trash, "foo")); WriteTrashFile("bar/baz/qux/foo", "another nasty one"); WriteTrashFile("foo", "troublesome little bugger"); try { WorkDirCheckout workDirCheckout = new WorkDirCheckout(db, trash, index, index); workDirCheckout.Checkout(); NUnit.Framework.Assert.Fail("Should have thrown exception"); } catch (NGit.Errors.CheckoutConflictException) { } // all is well WorkDirCheckout workDirCheckout_1 = new WorkDirCheckout(db, trash, index, index); workDirCheckout_1.SetFailOnConflict(false); workDirCheckout_1.Checkout(); NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile()); NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile()); GitIndex index2 = new GitIndex(db); RecursiveDelete(new FilePath(trash, "bar")); RecursiveDelete(new FilePath(trash, "foo")); index2.Add(trash, WriteTrashFile("bar/baz/qux/foo", "bar")); WriteTrashFile("bar/baz/qux/bar", "evil? I thought it said WEEVIL!"); index2.Add(trash, WriteTrashFile("foo", "lalala")); workDirCheckout_1 = new WorkDirCheckout(db, trash, index2, index); workDirCheckout_1.SetFailOnConflict(false); workDirCheckout_1.Checkout(); NUnit.Framework.Assert.IsTrue(new FilePath(trash, "bar").IsFile()); NUnit.Framework.Assert.IsTrue(new FilePath(trash, "foo/bar/baz/qux").IsFile()); NUnit.Framework.Assert.IsNotNull(index2.GetEntry("bar")); NUnit.Framework.Assert.IsNotNull(index2.GetEntry("foo/bar/baz/qux")); NUnit.Framework.Assert.IsNull(index2.GetEntry("bar/baz/qux/foo")); NUnit.Framework.Assert.IsNull(index2.GetEntry("foo")); }