[vcs][git] override method, to allow get git repository structure without Project instance

GitOrigin-RevId: b4b9b75ea50d584390ce2e8c930be384fb2e4eaf
This commit is contained in:
Alexander Bubenchikov
2024-05-16 10:56:27 +02:00
committed by intellij-monorepo-bot
parent 0839636890
commit 43c39b29af

View File

@@ -95,10 +95,16 @@ public final class GitIndexUtil {
public static @NotNull List<StagedFileOrDirectory> listTreeForRawPaths(@NotNull GitRepository repository,
@NotNull List<String> filePaths,
@NotNull VcsRevisionNumber revision) throws VcsException {
List<StagedFileOrDirectory> result = new ArrayList<>();
VirtualFile root = repository.getRoot();
return listTreeForRawPaths(repository.getProject(), repository.getRoot(), filePaths, revision);
}
GitLineHandler h = new GitLineHandler(repository.getProject(), root, GitCommand.LS_TREE);
public static @NotNull List<StagedFileOrDirectory> listTreeForRawPaths(@Nullable Project project,
@NotNull VirtualFile repositoryRoot,
@NotNull List<String> filePaths,
@NotNull VcsRevisionNumber revision) throws VcsException {
List<StagedFileOrDirectory> result = new ArrayList<>();
GitLineHandler h = new GitLineHandler(project, repositoryRoot, GitCommand.LS_TREE);
h.addParameters(revision.asString());
h.endOptions();
h.addParameters(filePaths);
@@ -107,7 +113,7 @@ public final class GitIndexUtil {
@Override
public void onLineAvailable(String line, Key outputType) {
if (outputType != ProcessOutputTypes.STDOUT) return;
ContainerUtil.addIfNotNull(result, parseListTreeRecord(root, line));
ContainerUtil.addIfNotNull(result, parseListTreeRecord(repositoryRoot, line));
}
});
Git.getInstance().runCommandWithoutCollectingOutput(h).throwOnError();
@@ -115,6 +121,7 @@ public final class GitIndexUtil {
return result;
}
private static @Nullable StagedFile parseListFilesStagedRecord(@NotNull VirtualFile root, @NotNull String line) {
try {
StringScanner s = new StringScanner(line);