diff --git a/platform/configuration-store-impl/src/SchemeManagerImpl.kt b/platform/configuration-store-impl/src/SchemeManagerImpl.kt index a75c2678a53e..23a179713cb8 100644 --- a/platform/configuration-store-impl/src/SchemeManagerImpl.kt +++ b/platform/configuration-store-impl/src/SchemeManagerImpl.kt @@ -662,7 +662,9 @@ class SchemeManagerImpl(val fileSpec: String, override fun toString(): String = fileSpec } -internal fun nameIsMissed(bytes: ByteArray) = RuntimeException("Name is missed:\n${bytes.toString(Charsets.UTF_8)}") +internal fun nameIsMissed(bytes: ByteArray): RuntimeException { + return RuntimeException("Name is missed:\n${bytes.toString(Charsets.UTF_8)}") +} internal class SchemeDataHolderImpl(private val processor: SchemeProcessor, private val bytes: ByteArray, diff --git a/plugins/settings-repository/lib/jgit-sources.jar b/plugins/settings-repository/lib/jgit-sources.jar index 8bfb75209c01..87d28e29292e 100644 Binary files a/plugins/settings-repository/lib/jgit-sources.jar and b/plugins/settings-repository/lib/jgit-sources.jar differ diff --git a/plugins/settings-repository/lib/jgit.jar b/plugins/settings-repository/lib/jgit.jar index ecc97ae5b040..e83c5202396d 100644 Binary files a/plugins/settings-repository/lib/jgit.jar and b/plugins/settings-repository/lib/jgit.jar differ diff --git a/plugins/settings-repository/src/git/GitEx.kt b/plugins/settings-repository/src/git/GitEx.kt index 107ab8af6dec..c13d0d224297 100644 --- a/plugins/settings-repository/src/git/GitEx.kt +++ b/plugins/settings-repository/src/git/GitEx.kt @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.settingsRepository.git import com.intellij.openapi.progress.ProcessCanceledException @@ -35,7 +21,6 @@ import org.eclipse.jgit.transport.RemoteConfig import org.eclipse.jgit.transport.Transport import org.eclipse.jgit.treewalk.FileTreeIterator import org.eclipse.jgit.treewalk.TreeWalk -import org.eclipse.jgit.treewalk.filter.TreeFilter import org.jetbrains.settingsRepository.AuthenticationException import org.jetbrains.settingsRepository.IcsCredentialsStore import org.jetbrains.settingsRepository.LOG @@ -205,16 +190,17 @@ fun Repository.processChildren(path: String, filter: ((name: String) -> Boolean) val lastCommitId = resolve(Constants.FETCH_HEAD) ?: return val reader = newObjectReader() reader.use { - val treeWalk = TreeWalk.forPath(reader, path, RevWalk(reader).parseCommit(lastCommitId).tree) ?: return - if (!treeWalk.isSubtree) { + val rootTreeWalk = TreeWalk.forPath(reader, path, RevWalk(reader).parseCommit(lastCommitId).tree) ?: return + if (!rootTreeWalk.isSubtree) { // not a directory LOG.warn("File $path is not a directory") return } - treeWalk.filter = TreeFilter.ALL - treeWalk.enterSubtree() - + // https://github.com/centic9/jgit-cookbook/blob/master/src/main/java/org/dstadler/jgit/api/ListFilesOfCommitAndTag.java + val treeWalk = TreeWalk(this) + treeWalk.addTree(rootTreeWalk.getObjectId(0)) + treeWalk.isRecursive = false while (treeWalk.next()) { val fileMode = treeWalk.getFileMode(0) if (fileMode == FileMode.REGULAR_FILE || fileMode == FileMode.SYMLINK || fileMode == FileMode.EXECUTABLE_FILE) { diff --git a/plugins/settings-repository/testSrc/BareGitTest.kt b/plugins/settings-repository/testSrc/BareGitTest.kt index 8b8e9af0cb72..43bf3a86b8b4 100644 --- a/plugins/settings-repository/testSrc/BareGitTest.kt +++ b/plugins/settings-repository/testSrc/BareGitTest.kt @@ -1,22 +1,9 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.settingsRepository.test import com.intellij.openapi.util.io.FileUtil import com.intellij.testFramework.TemporaryDirectory +import com.intellij.util.SmartList import gnu.trove.THashMap import org.assertj.core.api.Assertions.assertThat import org.jetbrains.settingsRepository.git.cloneBare @@ -40,10 +27,17 @@ internal class BareGitTest { val remoteRepository = tempDirManager.createRepository() val filePath = "keymaps/Mac OS X from RubyMine.xml" remoteRepository.add(filePath, SAMPLE_FILE_CONTENT) + remoteRepository.add("keymapsZ.xml", "test") remoteRepository.commit("") val repository = cloneBare(remoteRepository.workTree.absolutePath, tempDirManager.newPath()) assertThat(FileUtil.loadTextAndClose(repository.read(filePath)!!)).isEqualTo(SAMPLE_FILE_CONTENT) + + val list = SmartList() + repository.processChildren("keymaps") { name, _ -> + list.add(name) + } + assertThat(list).containsOnly("Mac OS X from RubyMine.xml") } @Test fun processChildren() {