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>
tags/v0.9.1
Shawn O. Pearce 14 years ago
parent
commit
a63494edee

+ 3
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java View File

@@ -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
- 0
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java View File

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