From 741944a966034c2f9a34ece19671eab438caf0d4 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Sat, 29 Mar 2008 21:59:53 -0400 Subject: [PATCH] Teach FileTreeIterator how to recognize a submodule when it sees one If we find a directory and it contains a ".git" child directory then the directory is actually a submodule, and its mode should be GITLINK, not TREE. This prevents the base class iterator from entering into the submodule and showing its associated working directory files as part of this traversal. Signed-off-by: Shawn O. Pearce --- .../src/org/spearce/jgit/treewalk/FileTreeIterator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java b/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java index 88cffe42..b209a71e 100644 --- a/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java +++ b/org.spearce.jgit/src/org/spearce/jgit/treewalk/FileTreeIterator.java @@ -87,9 +87,12 @@ public class FileTreeIterator extends WorkingTreeIterator { FileEntry(final File f) { file = f; - if (f.isDirectory()) - mode = FileMode.TREE; - else if (FS.INSTANCE.canExecute(file)) + if (f.isDirectory()) { + if (new File(f, ".git").isDirectory()) + mode = FileMode.GITLINK; + else + mode = FileMode.TREE; + } else if (FS.INSTANCE.canExecute(file)) mode = FileMode.EXECUTABLE_FILE; else mode = FileMode.REGULAR_FILE; -- 2.11.4.GIT