Browse Source

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>
stable-0.9
Shawn O. Pearce 15 years ago
parent
commit
a63494edee
  1. 3
      org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java
  2. 8
      org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java

3
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java

@ -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;

8
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java

@ -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
* */

Loading…
Cancel
Save