From a63494edeead4670ac2d838d346ed0fcdfa2b181 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 24 Jun 2010 12:57:02 -0700 Subject: [PATCH] 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 --- org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java | 3 +++ .../src/org/eclipse/jgit/lib/RepositoryState.java | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java index 4a4969841..0ee0ca9d3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/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; 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 901d1b516..862b7ea0c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryState.java +++ b/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 * */