Consistently use getDirectory() for work tree state

This permits us to leave the implementation of these methods here in
the Repository class, but later refactor how the directory is accessed
into a subclass.

Change-Id: I5785b2009c5b7cca0fb070a968e50814ce847076
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce 2010-06-24 18:41:21 -07:00
parent a63494edee
commit f18b853044
1 changed files with 5 additions and 5 deletions

View File

@ -1194,7 +1194,7 @@ public RepositoryState getRepositoryState() {
// Pre Git-1.6 logic // Pre Git-1.6 logic
if (new File(getWorkDir(), ".dotest").exists()) if (new File(getWorkDir(), ".dotest").exists())
return RepositoryState.REBASING; return RepositoryState.REBASING;
if (new File(gitDir,".dotest-merge").exists()) if (new File(getDirectory(), ".dotest-merge").exists())
return RepositoryState.REBASING_INTERACTIVE; return RepositoryState.REBASING_INTERACTIVE;
// From 1.6 onwards // From 1.6 onwards
@ -1211,7 +1211,7 @@ public RepositoryState getRepositoryState() {
return RepositoryState.REBASING_MERGE; return RepositoryState.REBASING_MERGE;
// Both versions // Both versions
if (new File(gitDir, "MERGE_HEAD").exists()) { if (new File(getDirectory(), "MERGE_HEAD").exists()) {
// we are merging - now check whether we have unmerged paths // we are merging - now check whether we have unmerged paths
try { try {
if (!DirCache.read(this).hasUnmergedPaths()) { if (!DirCache.read(this).hasUnmergedPaths()) {
@ -1227,7 +1227,7 @@ public RepositoryState getRepositoryState() {
return RepositoryState.MERGING; return RepositoryState.MERGING;
} }
if (new File(gitDir,"BISECT_LOG").exists()) if (new File(getDirectory(), "BISECT_LOG").exists())
return RepositoryState.BISECTING; return RepositoryState.BISECTING;
return RepositoryState.SAFE; return RepositoryState.SAFE;
@ -1455,7 +1455,7 @@ public ReflogReader getReflogReader(String refName) throws IOException {
* @throws IOException * @throws IOException
*/ */
public String readMergeCommitMsg() throws IOException { public String readMergeCommitMsg() throws IOException {
File mergeMsgFile = new File(gitDir, 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));
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
@ -1476,7 +1476,7 @@ public String readMergeCommitMsg() throws IOException {
* @throws IOException * @throws IOException
*/ */
public List<ObjectId> readMergeHeads() throws IOException { public List<ObjectId> readMergeHeads() throws IOException {
File mergeHeadFile = new File(gitDir, Constants.MERGE_HEAD); File mergeHeadFile = new File(getDirectory(), Constants.MERGE_HEAD);
byte[] raw; byte[] raw;
try { try {
raw = IO.readFully(mergeHeadFile); raw = IO.readFully(mergeHeadFile);