slawekjaranowski commented on code in PR #1412:
URL: https://github.com/apache/maven-scm/pull/1412#discussion_r4713503869
##########
maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/status/GitStatusConsumer.java:
##########
@@ -196,7 +224,7 @@ public void consumeLine(String line) {
return;
}
} else {
- if (!isFile(files.get(0))) {
+ if (!isFile(files.get(0)) && !(untracked &&
includeUntrackedEntries && isDirectory(files.get(0)))) {
Review Comment:
An untracked directory is reported as a single `new-dir/` entry, and that
breaks with a pattern-based file set. For `new ScmFileSet(basedir, "**/*.xml",
null)`, the scanned file list contains `new-dir/project.xml`, but git prints
only `?? new-dir/`. `isFileNameInFileList` compares `endsWith(f.getName())`, so
`new-dir` never matches `project.xml` and the entry is dropped. A new file in a
new directory is then still not reported when `includes` is set, which is the
#1170 scenario. The same holds with #1461's pattern matching, since `new-dir/`
does not match `**/*.xml`.
Asking git to list untracked files individually would avoid the directory
special case altogether:
```java
// GitStatusCommand.createCommandLine
cl.addArguments(new String[] {"--porcelain", "--untracked-files=all", "."});
```
Every `??` line is then a file, the `isDirectory` branch here can go away,
and the file-list and pattern filters work as they do for tracked files. It's
also closer to JGit, whose `Status.getUntracked()` lists files individually
(see #1468).
`--untracked-files` is available since git 1.6.0, and `--porcelain` (already
used here) needs 1.7.0, so this adds no new requirement on the git version.
Trade-off: a large untracked, non-ignored directory (e.g. `target/` without
a `.gitignore` entry) produces one line per file instead of one line.
`createCommandLine` is shared with `GitAddCommand` and `GitCheckInCommand`, but
both ignore `??` lines (untracked entries disabled), so their results don't
change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]