[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
This commit is contained in:
Julia Beliaeva
2020-10-20 13:54:36 +00:00
committed by intellij-monorepo-bot
parent 2a6be7f346
commit 35872c8837
@@ -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<GitStageCommitWorkflow>()
private fun GitStageTracker.RootState.getFullyStagedPaths(): Collection<FilePath> =
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) {