diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-24 18:45:57 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-25 17:46:40 -0700 |
commit | 77b39df5ecdcff4d0ef68e7441526426499914e3 (patch) | |
tree | 75f4d6d47e314aa2292f7c20a6b43e6e4f454f47 /org.eclipse.jgit/src/org | |
parent | f18b853044b57f1ffd1a3698f05b19d51e9b9c1b (diff) | |
download | jgit-77b39df5ecdcff4d0ef68e7441526426499914e3.tar.gz jgit-77b39df5ecdcff4d0ef68e7441526426499914e3.zip |
Consistently fail work tree methods on bare repositories
If the working tree isn't available, it doesn't make any sense to
obtain the merge heads, or the buffered commit message. The
repository shouldn't have a partial merge state to read. Throw back
the same exception we do when invoking getWorkDir() on a bare
repository instance.
Change-Id: I762c55890b7fe272a183da583f910671d1cadf71
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java | 12 |
1 files changed, 12 insertions, 0 deletions
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 4334234891..b4af15a60e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Repository.java @@ -1453,8 +1453,14 @@ public class Repository { * @return a String containing the content of the MERGE_MSG file or * {@code null} if this file doesn't exist * @throws IOException + * @throws IllegalStateException + * if the repository is "bare" */ public String readMergeCommitMsg() throws IOException { + if (isBare()) + throw new IllegalStateException( + JGitText.get().bareRepositoryNoWorkdirAndIndex); + File mergeMsgFile = new File(getDirectory(), Constants.MERGE_MSG); try { return new String(IO.readFully(mergeMsgFile)); @@ -1474,8 +1480,14 @@ public class Repository { * file or {@code null} if this file doesn't exist. Also if the file * exists but is empty {@code null} will be returned * @throws IOException + * @throws IllegalStateException + * if the repository is "bare" */ public List<ObjectId> readMergeHeads() throws IOException { + if (isBare()) + throw new IllegalStateException( + JGitText.get().bareRepositoryNoWorkdirAndIndex); + File mergeHeadFile = new File(getDirectory(), Constants.MERGE_HEAD); byte[] raw; try { |