Do not report ignored directories as untracked
Change-Id: I7e3f6b9fb1ac4b99d2cc9a78c63aad86f4fa5744 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
2f425cf30c
commit
75b31767c4
|
@ -467,6 +467,53 @@ public void testUntrackedFolders() throws Exception {
|
|||
diff.getUntrackedFolders());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that ignored folders aren't listed as untracked
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testUntrackedNotIgnoredFolders() throws Exception {
|
||||
Git git = new Git(db);
|
||||
|
||||
IndexDiff diff = new IndexDiff(db, Constants.HEAD,
|
||||
new FileTreeIterator(db));
|
||||
diff.diff();
|
||||
assertEquals(Collections.EMPTY_SET, diff.getUntrackedFolders());
|
||||
|
||||
writeTrashFile("readme", "");
|
||||
writeTrashFile("sr/com/X.java", "");
|
||||
writeTrashFile("src/com/A.java", "");
|
||||
writeTrashFile("src/org/B.java", "");
|
||||
writeTrashFile("srcs/org/Y.java", "");
|
||||
writeTrashFile("target/com/A.java", "");
|
||||
writeTrashFile("target/org/B.java", "");
|
||||
writeTrashFile(".gitignore", "/target\n/sr");
|
||||
|
||||
git.add().addFilepattern("readme").addFilepattern(".gitignore")
|
||||
.addFilepattern("srcs/").call();
|
||||
git.commit().setMessage("initial").call();
|
||||
|
||||
diff = new IndexDiff(db, Constants.HEAD, new FileTreeIterator(db));
|
||||
diff.diff();
|
||||
assertEquals(new HashSet<String>(Arrays.asList("src")),
|
||||
diff.getUntrackedFolders());
|
||||
|
||||
git.add().addFilepattern("src").call();
|
||||
writeTrashFile("sr/com/X1.java", "");
|
||||
writeTrashFile("src/tst/A.java", "");
|
||||
writeTrashFile("src/tst/B.java", "");
|
||||
writeTrashFile("srcs/com/Y1.java", "");
|
||||
deleteTrashFile(".gitignore");
|
||||
|
||||
diff = new IndexDiff(db, Constants.HEAD, new FileTreeIterator(db));
|
||||
diff.diff();
|
||||
assertEquals(
|
||||
new HashSet<String>(Arrays.asList("srcs/com", "sr", "src/tst",
|
||||
"target")),
|
||||
diff.getUntrackedFolders());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssumeUnchanged() throws Exception {
|
||||
Git git = new Git(db);
|
||||
|
|
|
@ -132,6 +132,7 @@ public boolean include(TreeWalk tw) throws MissingObjectException,
|
|||
IncorrectObjectTypeException, IOException {
|
||||
final int cnt = tw.getTreeCount();
|
||||
final int wm = tw.getRawMode(workingTree);
|
||||
WorkingTreeIterator wi = workingTree(tw);
|
||||
String path = tw.getPathString();
|
||||
|
||||
DirCacheIterator di = tw.getTree(dirCache, DirCacheIterator.class);
|
||||
|
@ -148,7 +149,8 @@ public boolean include(TreeWalk tw) throws MissingObjectException,
|
|||
// contain only untracked files and add it to
|
||||
// untrackedParentFolders. If we later find tracked files we will
|
||||
// remove it from this list
|
||||
if (FileMode.TREE.equals(wm)) {
|
||||
if (FileMode.TREE.equals(wm)
|
||||
&& !(honorIgnores && wi.isEntryIgnored())) {
|
||||
// Clean untrackedParentFolders. This potentially moves entries
|
||||
// from untrackedParentFolders to untrackedFolders
|
||||
copyUntrackedFolders(path);
|
||||
|
@ -179,7 +181,6 @@ public boolean include(TreeWalk tw) throws MissingObjectException,
|
|||
// we can avoid returning a result here, but only if its not in any
|
||||
// other tree.
|
||||
final int dm = tw.getRawMode(dirCache);
|
||||
WorkingTreeIterator wi = workingTree(tw);
|
||||
if (dm == FileMode.TYPE_MISSING) {
|
||||
if (honorIgnores && wi.isEntryIgnored()) {
|
||||
ignoredPaths.add(wi.getEntryPathString());
|
||||
|
|
Loading…
Reference in New Issue