diff --git a/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java b/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java index 568102bb9e19..fd922b294bb4 100644 --- a/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java +++ b/plugins/git4idea/src/git4idea/merge/GitMergeUtil.java @@ -184,8 +184,8 @@ public class GitMergeUtil { /** * @return true if merge is going on for the given git root, false if there is no merge operation in progress. - * @deprecated */ + @Deprecated public static boolean isMergeInProgress(@NotNull VirtualFile root) { return getMergeHead(root) != null; } diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java b/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java index b29d29424cef..6afa4b40bc0c 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseUtils.java @@ -48,8 +48,8 @@ public class GitRebaseUtils { * * @param root the git root * @return true if the rebase directory presents in the root - * @deprecated */ + @Deprecated public static boolean isRebaseInTheProgress(VirtualFile root) { return getRebaseDir(root) != null; } diff --git a/plugins/git4idea/src/git4idea/repo/GitRepository.java b/plugins/git4idea/src/git4idea/repo/GitRepository.java index 5b3c8e6f6973..a793d9e30a6c 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepository.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepository.java @@ -174,11 +174,11 @@ public final class GitRepository implements Disposable { myProject = project; Disposer.register(parentDisposable, this); - myReader = new GitRepositoryReader(this); - myGitDir = myRootDir.findChild(".git"); assert myGitDir != null : ".git directory wasn't found under " + rootDir.getPresentableUrl(); + myReader = new GitRepositoryReader(VfsUtil.virtualToIoFile(myGitDir)); + myUntrackedFilesHolder = new GitUntrackedFilesHolder(rootDir, project); Disposer.register(this, myUntrackedFilesHolder); diff --git a/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java b/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java index 2ac47ee239b1..79d1c52e8fe9 100644 --- a/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java +++ b/plugins/git4idea/src/git4idea/repo/GitRepositoryReader.java @@ -17,15 +17,12 @@ package git4idea.repo; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.encoding.EncodingManager; import com.intellij.util.Processor; import com.intellij.vcsUtil.VcsUtil; import git4idea.GitBranch; import git4idea.branch.GitBranchesCollection; -import git4idea.merge.GitMergeUtil; -import git4idea.rebase.GitRebaseUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,19 +61,17 @@ class GitRepositoryReader { private static final String REFS_REMOTES_PREFIX = "refs/remotes/"; private static final int IO_RETRIES = 3; // number of retries before fail if an IOException happens during file read. - private final GitRepository myRepository; private final File myGitDir; // .git/ private final File myHeadFile; // .git/HEAD private final File myRefsHeadsDir; // .git/refs/heads/ private final File myRefsRemotesDir; // .git/refs/remotes/ private final File myPackedRefsFile; // .git/packed-refs - GitRepositoryReader(@NotNull GitRepository repository) { - myRepository = repository; - myGitDir = new File(VfsUtil.virtualToIoFile(myRepository.getRoot()), ".git"); - assertFileExists(myGitDir, ".git directory not found in " + myRepository.getRoot()); + GitRepositoryReader(@NotNull File gitDir) { + myGitDir = gitDir; + assertFileExists(myGitDir, ".git directory not found in " + gitDir); myHeadFile = new File(myGitDir, "HEAD"); - assertFileExists(myHeadFile, ".git/HEAD file not found in " + myRepository.getRoot()); + assertFileExists(myHeadFile, ".git/HEAD file not found in " + gitDir); myRefsHeadsDir = new File(new File(myGitDir, "refs"), "heads"); myRefsRemotesDir = new File(new File(myGitDir, "refs"), "remotes"); myPackedRefsFile = new File(myGitDir, "packed-refs"); @@ -166,11 +161,17 @@ class GitRepositoryReader { } private boolean isMergeInProgress() { - return GitMergeUtil.isMergeInProgress(myRepository.getRoot()); + File mergeHead = new File(myGitDir, "MERGE_HEAD"); + return mergeHead.exists(); } private boolean isRebaseInProgress() { - return GitRebaseUtils.isRebaseInTheProgress(myRepository.getRoot()); + File f = new File(myGitDir, "rebase-apply"); + if (f.exists()) { + return true; + } + f = new File(myGitDir, "rebase-merge"); + return f.exists(); } /**