mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-191309 git: update staging area using "git add -A" on commit
Unify logic for deleted, new, modified, renamed, etc files. This prevents possible "Deleted-Unversioned" file status when we expected file to be removed, but it is actually a modification on disk. (ex: because pre-commit hook recreated a file that was deleted before) Use "-A" as a parameter for "addPaths", to unify logic between git versions. (This flag is set by default since git 2.0.0)
This commit is contained in:
@@ -646,26 +646,17 @@ public class GitCheckinEnvironment implements CheckinEnvironment {
|
||||
final Collection<FilePath> added,
|
||||
final Collection<FilePath> removed,
|
||||
final List<VcsException> exceptions) {
|
||||
boolean rc = true;
|
||||
if (!added.isEmpty()) {
|
||||
try {
|
||||
GitFileUtils.addPaths(project, root, added);
|
||||
}
|
||||
catch (VcsException ex) {
|
||||
exceptions.add(ex);
|
||||
rc = false;
|
||||
}
|
||||
try {
|
||||
List<FilePath> files = new ArrayList<>();
|
||||
files.addAll(added);
|
||||
files.addAll(removed);
|
||||
GitFileUtils.addPaths(project, root, files);
|
||||
return true;
|
||||
}
|
||||
if (!removed.isEmpty()) {
|
||||
try {
|
||||
GitFileUtils.delete(project, root, removed, "--ignore-unmatch", "--cached");
|
||||
}
|
||||
catch (VcsException ex) {
|
||||
exceptions.add(ex);
|
||||
rc = false;
|
||||
}
|
||||
catch (VcsException ex) {
|
||||
exceptions.add(ex);
|
||||
return false;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,10 @@ import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.vcsUtil.VcsFileUtil;
|
||||
import git4idea.GitUtil;
|
||||
import git4idea.commands.*;
|
||||
import git4idea.commands.Git;
|
||||
import git4idea.commands.GitBinaryHandler;
|
||||
import git4idea.commands.GitCommand;
|
||||
import git4idea.commands.GitLineHandler;
|
||||
import git4idea.repo.GitRepository;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -126,7 +129,7 @@ public class GitFileUtils {
|
||||
continue;
|
||||
}
|
||||
GitLineHandler handler = new GitLineHandler(project, root, GitCommand.ADD);
|
||||
handler.addParameters("--ignore-errors");
|
||||
handler.addParameters("--ignore-errors", "-A");
|
||||
handler.endOptions();
|
||||
handler.addParameters(paths);
|
||||
Git.getInstance().runCommand(handler).getOutputOrThrow();
|
||||
|
||||
Reference in New Issue
Block a user