diff options
author | Ned Twigg <ned.twigg@diffplug.com> | 2018-08-21 14:44:28 -0700 |
---|---|---|
committer | David Pursehouse <david.pursehouse@gmail.com> | 2018-10-20 06:53:23 -0400 |
commit | d056a543846ccf9b8cd0f59cc2f5920427fc4559 (patch) | |
tree | 65a9d3a675825c76b02d8ba0c701351ec8d24db1 /org.eclipse.jgit.test/tst/org | |
parent | 36432ac4e36cf8d59e45877ea69de70354e0ca0b (diff) | |
download | jgit-d056a543846ccf9b8cd0f59cc2f5920427fc4559.tar.gz jgit-d056a543846ccf9b8cd0f59cc2f5920427fc4559.zip |
CheckoutCommand: force flag now allows overwrite
Before this commit, a force checkout would fail if there
were any conflicting files. After this commit, a force
checkout will overwrite the conflicting files, as expected.
Making this work required fixing a bug in DirCacheCheckout.
Before this commit, when DirCacheCheckout had
failOnConflict=false, it would delete all conflicting files
from the working copy and just leave them missing. After
this commit, DirCacheCheckout overwrites conflicting files
with the merge tree.
This change in DirCacheCheckout causes "reset --hard" and
"revert --abort" to behave as expected (previously they
would simply delete conflicting files, now they will be
overwritten from the merge tree).
Change-Id: If7e328ee792ef6511ab7d9c26d8d77c39210ec9f
Signed-off-by: Ned Twigg <ned.twigg@diffplug.com>
Diffstat (limited to 'org.eclipse.jgit.test/tst/org')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java index 71df59e1ff..498005deda 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CheckoutCommandTest.java @@ -154,7 +154,7 @@ public class CheckoutCommandTest extends RepositoryTestCase { } @Test - public void testCheckoutWithConflict() { + public void testCheckoutWithConflict() throws Exception { CheckoutCommand co = git.checkout(); try { writeTrashFile("Test.txt", "Another change"); @@ -165,6 +165,8 @@ public class CheckoutCommandTest extends RepositoryTestCase { assertEquals(Status.CONFLICTS, co.getResult().getStatus()); assertTrue(co.getResult().getConflictList().contains("Test.txt")); } + git.checkout().setName("master").setForce(true).call(); + assertThat(read("Test.txt"), is("Hello world")); } @Test |