aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2018-02-12 15:44:04 +0100
committerChristian Halstrick <christian.halstrick@sap.com>2019-01-08 10:01:09 +0100
commite406d500de01b9ae7155e296baebf3ec8024869d (patch)
tree3873d4a07a3c46d662d7ed5d66cd234c2f07188c /org.eclipse.jgit.pgm
parent6c8240a75126013b7f4588d78e66baa54e89cbfc (diff)
downloadjgit-e406d500de01b9ae7155e296baebf3ec8024869d.tar.gz
jgit-e406d500de01b9ae7155e296baebf3ec8024869d.zip
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 <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.pgm')
-rw-r--r--org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties3
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java8
2 files changed, 8 insertions, 3 deletions
diff --git a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
index d7d895ab31..538c87661b 100644
--- a/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
+++ b/org.eclipse.jgit.pgm/resources/org/eclipse/jgit/pgm/internal/CLIText.properties
@@ -341,7 +341,8 @@ usage_fetchThinPack=fetch thin pack
usage_filesToAddContentFrom=Files to add content from
usage_fixAThinPackToBeComplete=fix a thin pack to be complete
usage_forEachRefOutput=for-each-ref output
-usage_forceCheckout=when switching branches, proceed even if the index or the working tree differs from HEAD
+usage_forcedSwitchBranch=when switching branches do it forcefully. Succeed even if resetting an existing branch would cause commits to become unreachable
+usage_forceCheckout=when checking out a commit succeed even if the working tree or the index is dirty. Overwrite the working tree or index in such cases
usage_forceClean=required to delete files or directories
usage_forceCreateBranchEvenExists=force create branch even exists
usage_forcedFetch=force ref update fetch option
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
index 6ff39fab04..7e1737f872 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Checkout.java
@@ -69,8 +69,11 @@ class Checkout extends TextBuiltin {
@Option(name = "-b", usage = "usage_createBranchAndCheckout")
private boolean createBranch = false;
+ @Option(name = "-B", usage = "usage_forcedSwitchBranch")
+ private boolean forceSwitchBranch = false;
+
@Option(name = "--force", aliases = { "-f" }, usage = "usage_forceCheckout")
- private boolean force = false;
+ private boolean forced = false;
@Option(name = "--orphan", usage = "usage_orphan")
private boolean orphan = false;
@@ -103,7 +106,8 @@ class Checkout extends TextBuiltin {
} else {
command.setCreateBranch(createBranch);
command.setName(name);
- command.setForce(force);
+ command.setForceRefUpdate(forceSwitchBranch);
+ command.setForced(forced);
command.setOrphan(orphan);
}
try {