From e406d500de01b9ae7155e296baebf3ec8024869d Mon Sep 17 00:00:00 2001 From: Christian Halstrick Date: Mon, 12 Feb 2018 15:44:04 +0100 Subject: Fix "jgit checkout -f" to overwrite dirty worktree files CheckoutCommand had a setForce() method. But this didn't correspond to native git's 'git checkout -f' option. Deprecate the old setForce() method and move its implementation to a new method setForceRefUpdate() and use it to implement the -B option in the CLI class Checkout. Add a setForced() method and use it to fix the associated '-f' option of the CLI Checkout class to behave like native git's 'git checkout -f' which overwrites dirty worktree files during checkout. This is still not fully matching native git's behavior: updating additionally dirty index entries is not done yet. Bug: 530771 Change-Id: I776b78eb623b6ea0aca42f681788f2e4b1667f15 Signed-off-by: Matthias Sohn --- .../src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'org.eclipse.jgit.ant/src/org/eclipse') diff --git a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java index 0b27cc2645..5f80d00ebb 100644 --- a/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java +++ b/org.eclipse.jgit.ant/src/org/eclipse/jgit/ant/tasks/GitCheckoutTask.java @@ -123,7 +123,7 @@ public class GitCheckoutTask extends Task { } try { - checkout.setCreateBranch(createBranch).setForce(force) + checkout.setCreateBranch(createBranch).setForceRefUpdate(force) .setName(branch); checkout.call(); } catch (Exception e) { -- cgit v1.2.3