From 35872c8837d4620ab123f0efca4b93131355f7ff Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Tue, 20 Oct 2020 16:22:34 +0300 Subject: [PATCH] [git-index] do not try to add paths deleted from index Paths that were fully staged are added to the index again before commit to stage all of the modifications done by the pre-commit checks. However, this should exclude paths deleted from the index: running "git add" for them is unnecessary and will result in error. IDEA-253313 GitOrigin-RevId: 4c1db4c5c882c452169b6a72d41353efd0d9fb05 --- .../git4idea/src/git4idea/index/GitStageCommitWorkflow.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/git4idea/src/git4idea/index/GitStageCommitWorkflow.kt b/plugins/git4idea/src/git4idea/index/GitStageCommitWorkflow.kt index c79546adf19a..03bfa338ecaf 100644 --- a/plugins/git4idea/src/git4idea/index/GitStageCommitWorkflow.kt +++ b/plugins/git4idea/src/git4idea/index/GitStageCommitWorkflow.kt @@ -4,6 +4,7 @@ package git4idea.index import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.project.Project import com.intellij.openapi.vcs.FilePath +import com.intellij.openapi.vcs.FileStatus import com.intellij.openapi.vcs.changes.CommitExecutor import com.intellij.openapi.vcs.changes.CommitSession import com.intellij.openapi.vcs.checkin.CheckinHandler @@ -17,7 +18,9 @@ private val LOG = logger() private fun GitStageTracker.RootState.getFullyStagedPaths(): Collection = statuses.values - .filter { it.getStagedStatus() != null && it.getUnStagedStatus() == null } + .filter { it.getStagedStatus() != null && + it.getStagedStatus() != FileStatus.DELETED && + it.getUnStagedStatus() == null } .map { it.path(ContentVersion.STAGED) } class GitStageCommitWorkflow(project: Project) : NonModalCommitWorkflow(project) {