Add RepositoryState.BARE

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>
This commit is contained in:
Shawn O. Pearce 2010-06-24 12:57:02 -07:00
parent c9c57d34de
commit a63494edee
2 changed files with 11 additions and 0 deletions

View File

@ -1188,6 +1188,9 @@ static byte[] gitInternalSlash(byte[] bytes) {
* @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;

View File

@ -54,6 +54,14 @@
* 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
* */