From 99ec987e681c5a21a4a485b778e990e96c52ac51 Mon Sep 17 00:00:00 2001 From: Jens Baumgart Date: Mon, 28 Nov 2011 10:46:16 +0100 Subject: [PATCH] RepositoryState: add method canAmend The method canAmend was added to RepositoryState. It returns true if amending the HEAD commit is allowed in the current repository state. Change-Id: Idd0c4eea83a23c41340789b7b877959b457d951e Signed-off-by: Jens Baumgart --- .../org/eclipse/jgit/lib/RepositoryState.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java index 10170624b1..7c8f51d043 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java @@ -60,6 +60,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return false; } public boolean canCommit() { return false; } + public boolean canAmend() { return false; } public String getDescription() { return "Bare"; } }, @@ -70,6 +71,7 @@ public enum RepositoryState { public boolean canCheckout() { return true; } public boolean canResetHead() { return true; } public boolean canCommit() { return true; } + public boolean canAmend() { return true; } public String getDescription() { return JGitText.get().repositoryState_normal; } }, @@ -79,6 +81,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return true; } public boolean canCommit() { return false; } + public boolean canAmend() { return false; } public String getDescription() { return JGitText.get().repositoryState_conflicts; } }, @@ -90,6 +93,7 @@ public enum RepositoryState { public boolean canCheckout() { return true; } public boolean canResetHead() { return true; } public boolean canCommit() { return true; } + public boolean canAmend() { return false; } public String getDescription() { return JGitText.get().repositoryState_merged; } }, @@ -99,6 +103,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return true; } public boolean canCommit() { return false; } + public boolean canAmend() { return false; } public String getDescription() { return JGitText.get().repositoryState_conflicts; } }, @@ -110,6 +115,7 @@ public enum RepositoryState { public boolean canCheckout() { return true; } public boolean canResetHead() { return true; } public boolean canCommit() { return true; } + public boolean canAmend() { return false; } public String getDescription() { return JGitText.get().repositoryState_merged; } }, @@ -120,6 +126,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return false; } public boolean canCommit() { return true; } + public boolean canAmend() { return true; } public String getDescription() { return JGitText.get().repositoryState_rebaseOrApplyMailbox; } }, @@ -130,6 +137,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return false; } public boolean canCommit() { return true; } + public boolean canAmend() { return true; } public String getDescription() { return JGitText.get().repositoryState_rebase; } }, @@ -140,6 +148,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return false; } public boolean canCommit() { return true; } + public boolean canAmend() { return true; } public String getDescription() { return JGitText.get().repositoryState_applyMailbox; } }, @@ -150,6 +159,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return false; } public boolean canCommit() { return true; } + public boolean canAmend() { return true; } public String getDescription() { return JGitText.get().repositoryState_rebaseWithMerge; } }, @@ -160,6 +170,7 @@ public enum RepositoryState { public boolean canCheckout() { return false; } public boolean canResetHead() { return false; } public boolean canCommit() { return true; } + public boolean canAmend() { return true; } public String getDescription() { return JGitText.get().repositoryState_rebaseInteractive; } }, @@ -176,6 +187,8 @@ public enum RepositoryState { /* Commit during bisect is useful */ public boolean canCommit() { return true; } + public boolean canAmend() { return false; } + public String getDescription() { return JGitText.get().repositoryState_bisecting; } }; @@ -194,6 +207,11 @@ public enum RepositoryState { */ public abstract boolean canResetHead(); + /** + * @return true if amending is considered SAFE + */ + public abstract boolean canAmend(); + /** * @return a human readable description of the state. */ -- 2.39.5