From fff71c0b4106fd5ac75c49cf48bc476a75577c87 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Mon, 12 Jun 2023 18:19:45 +0200 Subject: [PATCH] [vcs-log] fix getting commit parents for commits without parents GitOrigin-RevId: a893c8ef30ec20278e3b50a25dbc19c7a6283c47 --- .../vcs/log/data/index/SqliteVcsLogStorageBackend.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/SqliteVcsLogStorageBackend.kt b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/SqliteVcsLogStorageBackend.kt index 491cce804edd..59250a32e2ad 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/SqliteVcsLogStorageBackend.kt +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/data/index/SqliteVcsLogStorageBackend.kt @@ -255,7 +255,7 @@ internal class SqliteVcsLogStorageBackend(project: Project, } override fun getParents(commitIds: Collection): Map> { - val result = hashMapOf>() + val result = commitIds.associateWith { mutableListOf() } val paramBinder = ObjectBinder(paramCount = 0) val inClause = commitIds.toInClause() val sql = "select p.rowid, c.hash from commit_hashes c inner join parent p on p.parent = c.rowid where p.commitId in $inClause" @@ -264,8 +264,7 @@ internal class SqliteVcsLogStorageBackend(project: Project, val rs = statement.executeQuery() while (rs.next()) { val commitId = rs.getInt(0) - val hashes = result.getOrPut(commitId) { mutableListOf() } - hashes.add(rs.getString(1)!!.let(HashImpl::build)) + result[commitId]?.add(rs.getString(1)!!.let(HashImpl::build)) } }