A bare repository cannot be checked out, committed to, etc. as it doesn't have a working directory. Define this as a state since the state enumeration exists only to describe how a working directory can be modified. Change-Id: I0a299013c6e42fef6cae3f6a9446f8f6c8e0514a Signed-off-by: Shawn O. Pearce <spearce@spearce.org>tags/v0.9.1
@@ -1188,6 +1188,9 @@ public class Repository { | |||
* @return an important state | |||
*/ | |||
public RepositoryState getRepositoryState() { | |||
if (isBare()) | |||
return RepositoryState.BARE; | |||
// Pre Git-1.6 logic | |||
if (new File(getWorkDir(), ".dotest").exists()) | |||
return RepositoryState.REBASING; |
@@ -54,6 +54,14 @@ package org.eclipse.jgit.lib; | |||
* on the state are the only supported means of deciding what to do. | |||
*/ | |||
public enum RepositoryState { | |||
/** Has no work tree and cannot be used for normal editing. */ | |||
BARE { | |||
public boolean canCheckout() { return false; } | |||
public boolean canResetHead() { return false; } | |||
public boolean canCommit() { return false; } | |||
public String getDescription() { return "Bare"; } | |||
}, | |||
/** | |||
* A safe state for working normally | |||
* */ |