Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
*/
package org.apache.maven.scm.provider.git.jgit.command.status;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFile;
Expand Down Expand Up @@ -51,7 +54,11 @@ protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFi
git = JGitUtils.openRepo(fileSet.getBasedir());
Status status = git.status().call();
List<ScmFile> changedFiles = getFileStati(status);

if (!fileSet.getFileList().isEmpty()) {
Set<String> fileSetPaths =
fileSet.getFileList().stream().map(File::toString).collect(Collectors.toSet());
changedFiles.removeIf(scmFile -> !fileSetPaths.contains(scmFile.getPath()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base directory of the fileSet is not necessarily the root directory of the working copy, therefore some file adjustments are necessary before comparing with changedFiles.path.

}
return new StatusScmResult("JGit status", changedFiles);
} catch (IOException | GitAPIException e) {
throw new ScmException("JGit status failure!", e);
Expand Down