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>
This commit is contained in:
parent
f18b853044
commit
77b39df5ec
|
@ -1453,8 +1453,14 @@ public ReflogReader getReflogReader(String refName) throws IOException {
|
||||||
* @return a String containing the content of the MERGE_MSG file or
|
* @return a String containing the content of the MERGE_MSG file or
|
||||||
* {@code null} if this file doesn't exist
|
* {@code null} if this file doesn't exist
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @throws IllegalStateException
|
||||||
|
* if the repository is "bare"
|
||||||
*/
|
*/
|
||||||
public String readMergeCommitMsg() throws IOException {
|
public String readMergeCommitMsg() throws IOException {
|
||||||
|
if (isBare())
|
||||||
|
throw new IllegalStateException(
|
||||||
|
JGitText.get().bareRepositoryNoWorkdirAndIndex);
|
||||||
|
|
||||||
File mergeMsgFile = new File(getDirectory(), Constants.MERGE_MSG);
|
File mergeMsgFile = new File(getDirectory(), Constants.MERGE_MSG);
|
||||||
try {
|
try {
|
||||||
return new String(IO.readFully(mergeMsgFile));
|
return new String(IO.readFully(mergeMsgFile));
|
||||||
|
@ -1474,8 +1480,14 @@ public String readMergeCommitMsg() throws IOException {
|
||||||
* file or {@code null} if this file doesn't exist. Also if the file
|
* file or {@code null} if this file doesn't exist. Also if the file
|
||||||
* exists but is empty {@code null} will be returned
|
* exists but is empty {@code null} will be returned
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @throws IllegalStateException
|
||||||
|
* if the repository is "bare"
|
||||||
*/
|
*/
|
||||||
public List<ObjectId> readMergeHeads() throws IOException {
|
public List<ObjectId> readMergeHeads() throws IOException {
|
||||||
|
if (isBare())
|
||||||
|
throw new IllegalStateException(
|
||||||
|
JGitText.get().bareRepositoryNoWorkdirAndIndex);
|
||||||
|
|
||||||
File mergeHeadFile = new File(getDirectory(), Constants.MERGE_HEAD);
|
File mergeHeadFile = new File(getDirectory(), Constants.MERGE_HEAD);
|
||||||
byte[] raw;
|
byte[] raw;
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue