diff --git a/base/src/com/google/idea/blaze/base/vcs/git/GitBlazeVcsHandlerProvider.java b/base/src/com/google/idea/blaze/base/vcs/git/GitBlazeVcsHandlerProvider.java index aeb60f2fdd5..d222fb186fc 100644 --- a/base/src/com/google/idea/blaze/base/vcs/git/GitBlazeVcsHandlerProvider.java +++ b/base/src/com/google/idea/blaze/base/vcs/git/GitBlazeVcsHandlerProvider.java @@ -125,10 +125,11 @@ private static String getGitUpstreamContent(WorkspaceRoot workspaceRoot, Workspa } private static boolean isGitRepository(WorkspaceRoot workspaceRoot) { - // TODO: What if the git repo root is a parent directory of the workspace root? - // Just call 'git rev-parse --is-inside-work-tree' or similar instead? - File gitDir = new File(workspaceRoot.directory(), ".git"); - return FileOperationProvider.getInstance().isDirectory(gitDir); + ByteArrayOutputStream stdout = new ByteArrayOutputStream(); + + String[] args = new String[] {"git", "rev-parse", "--is-inside-work-tree"}; + int retVal = ExternalTask.builder(workspaceRoot).args(args).stdout(stdout).build().run(); + return retVal == 0 && "true".equals(StringUtil.trimEnd(stdout.toString(), "\n")); } /**