The Unified and Autonomous Development Platform
Able to list tree with diff information.
robin shine28188e75ecf2
diff --git a/commons.git/src/main/java/com/pmease/commons/git/DiffTreeNode.java b/commons.git/src/main/java/com/pmease/commons/git/DiffTreeNode.javanew file mode 100644index 0000000000..b0701017d4--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/DiffTreeNode.java@@ -0,0 +1,62 @@+package com.pmease.commons.git;++import java.io.Serializable;++import org.apache.commons.lang3.StringUtils;++@SuppressWarnings("serial")+public class DiffTreeNode implements Comparable<DiffTreeNode>, Serializable {++ public enum Action {ADD, MODIFY, DELETE, EQUAL};++ private final String path;++ private final boolean folder;++ private final Action action;++ private transient String name;++ public DiffTreeNode(String path, boolean folder, Action action) {+ this.path = path;+ this.folder = folder;+ this.action = action;+ }++ public String getPath() {+ return path;+ }++ public String getName() {+ if (name == null) {+ if (path.contains("/"))+ name = StringUtils.substringAfterLast(path, "/");+ else+ name = path;+ }+ return name;+ }++ public Action getAction() {+ return action;+ }++ public boolean isFolder() {+ return folder;+ }++ @Override+ public int compareTo(DiffTreeNode other) {+ if (isFolder()) {+ if (other.isFolder())+ return getPath().compareTo(other.getPath());+ else+ return -1;+ } else if (other.isFolder()) {+ return 1;+ } else {+ return getPath().compareTo(other.getPath());+ }+ }++}diff --git a/commons.git/src/main/java/com/pmease/commons/git/Git.java b/commons.git/src/main/java/com/pmease/commons/git/Git.javaindex 4202ac11d2..b7cdb67947 100644--- a/commons.git/src/main/java/com/pmease/commons/git/Git.java+++ b/commons.git/src/main/java/com/pmease/commons/git/Git.java@@ -2,13 +2,17 @@ package com.pmease.commons.git;import java.io.File;import java.io.Serializable;+import java.util.ArrayList;import java.util.Collection;import java.util.Date;+import java.util.HashSet;import java.util.List;import java.util.Map;+import java.util.Set;import javax.annotation.Nullable;+import org.eclipse.jgit.lib.FileMode;import org.eclipse.jgit.lib.PersonIdent;import org.eclipse.jgit.util.SystemReader;@@ -31,6 +35,7 @@ import com.pmease.commons.git.command.IsBinaryCommand;import com.pmease.commons.git.command.IsTreeLinkCommand;import com.pmease.commons.git.command.ListBranchesCommand;import com.pmease.commons.git.command.ListChangedFilesCommand;+import com.pmease.commons.git.command.ListFileChangesCommand;import com.pmease.commons.git.command.ListSubModulesCommand;import com.pmease.commons.git.command.ListTagsCommand;import com.pmease.commons.git.command.ListTreeCommand;@@ -139,10 +144,92 @@ public class Git implements Serializable {return commits.get(0);}- public List<TreeNode> listTree(String revision, @Nullable String path, boolean recursive) {- return new ListTreeCommand(repoDir).revision(revision).path(path).recursive(recursive).call();+ public List<TreeNode> listTree(String revision, @Nullable String path) {+ return new ListTreeCommand(repoDir).revision(revision).path(path).call();}++ /**+ * List tree of fromRev, and mark differences from fromRev to toRev in the resulting tree.+ *+ * @param fromRev+ * revision to base the tree off+ * @param toRev+ * revision to calculate file differences since fromRev+ * @param path+ * path to list tree inside+ * @return+ * a list of tree node with appropriate actions set up to mark whether or not this+ * tree node is modified, added, deleted or remaining the same+ */+ public List<DiffTreeNode> listTreeWithDiff(String fromRev, String toRev, @Nullable String path) {+ path = GitUtils.normalizeTreePath(path);++ Collection<FileChange> changes = listFileChanges(fromRev, toRev, path, false, false);+ Set<String> addedFiles = new HashSet<>();+ Set<String> deletedFiles = new HashSet<>();+ Set<String> modifiedFiles = new HashSet<>();+ Set<String> changedFiles = new HashSet<>();++ for (FileChange change: changes) {+ if (change.getAction() == FileChange.Action.ADD) {+ addedFiles.add(change.getNewPath());+ } else if (change.getAction() == FileChange.Action.DELETE) {+ deletedFiles.add(change.getOldPath());+ } else if (change.getAction() == FileChange.Action.MODIFY+ || change.getAction() == FileChange.Action.TYPE) {+ modifiedFiles.add(change.getOldPath());+ } else {+ throw new IllegalStateException("Unexpected action: " + change.getAction());+ }+ }++ changedFiles.addAll(addedFiles);+ changedFiles.addAll(deletedFiles);+ changedFiles.addAll(modifiedFiles);++ List<DiffTreeNode> diffs = new ArrayList<>();++ for (TreeNode treeNode: listTree(fromRev, path)) {+ if (FileMode.TREE.equals(treeNode.getModeBits())) {+ String name = treeNode.getName() + "/";+ DiffTreeNode diff = null;+ for (String changedFile: changedFiles) {+ if (changedFile.startsWith(name)) {+ diff = new DiffTreeNode(treeNode.getPath(), true, DiffTreeNode.Action.MODIFY);+ break;+ }+ }+ if (diff == null)+ diff = new DiffTreeNode(treeNode.getPath(), true, DiffTreeNode.Action.EQUAL);+ diffs.add(diff);+ } else {+ DiffTreeNode diff;+ if (modifiedFiles.contains(treeNode.getName()))+ diff = new DiffTreeNode(treeNode.getName(), false, DiffTreeNode.Action.MODIFY);+ else if (deletedFiles.contains(treeNode.getName()))+ diff = new DiffTreeNode(treeNode.getName(), false, DiffTreeNode.Action.DELETE);+ else+ diff = new DiffTreeNode(treeNode.getName(), false, DiffTreeNode.Action.EQUAL);+ diffs.add(diff);+ }+ }+ Set<String> addedDirs = new HashSet<>();+ for (String addedFile: addedFiles) {+ String relativePath = addedFile.substring(path.length());+ int index = relativePath.indexOf('/');+ if (index != -1)+ addedDirs.add(path + relativePath.substring(0, index));+ else+ diffs.add(new DiffTreeNode(addedFile, false, DiffTreeNode.Action.ADD));+ }++ for (String addedDir: addedDirs)+ diffs.add(new DiffTreeNode(addedDir, true, DiffTreeNode.Action.ADD));++ return diffs;+ }+public Git init(boolean bare) {new InitCommand(repoDir).bare(bare).call();return this;@@ -180,8 +267,14 @@ public class Git implements Serializable {return this;}- public Collection<String> listChangedFiles(String fromRev, String toRev) {- return new ListChangedFilesCommand(repoDir).fromRev(fromRev).toRev(toRev).call();+ public Collection<String> listChangedFiles(String fromRev, String toRev, @Nullable String path) {+ return new ListChangedFilesCommand(repoDir).fromRev(fromRev).toRev(toRev).path(path).call();+ }++ public Collection<FileChange> listFileChanges(String fromRev, String toRev, @Nullable String path,+ boolean findRenames, boolean findCopies) {+ return new ListFileChangesCommand(repoDir).fromRev(fromRev).toRev(toRev).path(path)+ .findRenames(findRenames).findCopies(findCopies).call();}public Git checkout(String revision, @Nullable String newBranch) {@@ -355,7 +448,7 @@ public class Git implements Serializable {public byte[] show(String revision, String path) {return new ShowCommand(repoDir).revision(revision).path(path).call();}-+public List<Commit> log(@Nullable String fromRev, @Nullable String toRev,@Nullable String path, int maxCount, int skip) {return new LogCommand(repoDir).fromRev(fromRev).toRev(toRev)diff --git a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.javaindex d6968ca560..248c6b6cec 100644--- a/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java+++ b/commons.git/src/main/java/com/pmease/commons/git/GitUtils.java@@ -44,5 +44,14 @@ public class GitUtils {return null;}}-++ public static String normalizeTreePath(String treePath) {+ if (treePath == null || treePath.length() == 0 || treePath.equals("/")) {+ return "";+ } else if (!treePath.endsWith("/")) {+ return treePath + "/";+ } else {+ return treePath;+ }+ }}diff --git a/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java b/commons.git/src/main/java/com/pmease/commons/git/TreeNode.javaindex 84e6937063..f7854ac65c 100644--- a/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java+++ b/commons.git/src/main/java/com/pmease/commons/git/TreeNode.java@@ -1,6 +1,5 @@package com.pmease.commons.git;-import java.io.File;import java.io.Serializable;import java.util.List;@@ -9,19 +8,17 @@ import javax.annotation.Nullable;import org.apache.commons.lang3.StringUtils;import org.eclipse.jgit.lib.FileMode;-import com.google.common.base.Optional;-import com.google.common.base.Preconditions;import com.pmease.commons.git.command.ListTreeCommand;@SuppressWarnings("serial")-public class TreeNode implements Serializable {-- protected final File gitDir;+public class TreeNode implements Comparable<TreeNode>, Serializable {private final int modeBits;private final String path;+ private transient String name;+private final String hash;private final String revision;@@ -30,10 +27,21 @@ public class TreeNode implements Serializable {private transient FileMode mode;- private Optional<TreeNode> parentNode;-- public TreeNode(File gitDir, int modeBits, String path, String revision, String hash, int size) {- this.gitDir = gitDir;+ /**+ * Construct a tree node.+ *+ * @param modeBits+ * mode bits of the node object. Pass <tt>0</tt> if unknown+ * @param path+ * path of the node object+ * @param revision+ * revision of the node object+ * @param hash+ * hash of the node object+ * @param size+ * size of the node object+ */+ public TreeNode(int modeBits, String path, String revision, String hash, int size) {this.path = path;this.revision = revision;this.hash = hash;@@ -46,10 +54,13 @@ public class TreeNode implements Serializable {}public String getName() {- if (path.contains("/"))- return StringUtils.substringAfterLast(path, "/");- else- return path;+ if (name == null) {+ if (path.contains("/"))+ name = StringUtils.substringAfterLast(path, "/");+ else+ name = path;+ }+ return name;}public String getRevision() {@@ -69,36 +80,11 @@ public class TreeNode implements Serializable {mode = FileMode.fromBits(modeBits);return mode;}-+public int getSize() {return size;}- /**- * Get parent node of current node.- *- * @return- * parent node of current node, or <tt>null</tt> if current node locates directly- * under the repository root- */- public @Nullable TreeNode getParent() {- if (parentNode == null) {- if (path.contains("/")) {- String parentPath = StringUtils.substringBeforeLast(path, "/");- List<TreeNode> result = new ListTreeCommand(gitDir).revision(getRevision()).path(parentPath).call();- Preconditions.checkArgument(result.size() == 1);- parentNode = Optional.of(result.get(0));- } else {- parentNode = Optional.fromNullable(null);- }- }- return parentNode.orNull();- }-- public void setParent(@Nullable TreeNode parent) {- this.parentNode = Optional.fromNullable(parent);- }-@Overridepublic String toString() {return getPath();@@ -111,13 +97,9 @@ public class TreeNode implements Serializable {* child nodes of current node, or <tt>null</tt> if current node does not represent a* directory.*/- public @Nullable List<TreeNode> listChildren() {+ public @Nullable List<TreeNode> listChildren(Git git) {if (getMode() == FileMode.TREE) {- List<TreeNode> children = new ListTreeCommand(gitDir).revision(getRevision()).path(getPath() + "/").call();- for (TreeNode each: children) {- each.setParent(this);- }- return children;+ return new ListTreeCommand(git.repoDir()).revision(getRevision()).path(getPath() + "/").call();} else {return null;}@@ -132,8 +114,7 @@ public class TreeNode implements Serializable {* represents a symbol link, or contents of the directory if current node* represents a directory*/- public byte[] show() {- Git git = new Git(gitDir);+ public byte[] show(Git git) {if (getMode() == FileMode.GITLINK) {return git.listSubModules(revision).get(path).getBytes();} else {@@ -141,4 +122,18 @@ public class TreeNode implements Serializable {}}+ @Override+ public int compareTo(TreeNode node) {+ if (FileMode.TREE.equals(modeBits)) {+ if (FileMode.TREE.equals(node.getModeBits()))+ return getName().compareTo(node.getName());+ else+ return 1;+ } else if (FileMode.TREE.equals(node.getModeBits())) {+ return -1;+ } else {+ return getName().compareTo(node.getName());+ }+ }+}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListChangedFilesCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListChangedFilesCommand.javaindex a1d70664e7..321f60933a 100644--- a/commons.git/src/main/java/com/pmease/commons/git/command/ListChangedFilesCommand.java+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ListChangedFilesCommand.java@@ -15,6 +15,8 @@ public class ListChangedFilesCommand extends GitCommand<Collection<String>> {private String toRev;+ private String path;+public ListChangedFilesCommand(final File repoDir) {super(repoDir);}@@ -29,6 +31,11 @@ public class ListChangedFilesCommand extends GitCommand<Collection<String>> {return this;}+ public ListChangedFilesCommand path(final String path) {+ this.path = path;+ return this;+ }+@Overridepublic Collection<String> call() {Preconditions.checkNotNull(toRev, "toRev has to be specified.");@@ -40,6 +47,9 @@ public class ListChangedFilesCommand extends GitCommand<Collection<String>> {cmd.addArgs("diff", "--name-only", fromRev + ".." + toRev);+ if (path != null)+ cmd.addArgs("--", path);+cmd.execute(new LineConsumer() {@Overridediff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListFileChangesCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListFileChangesCommand.javanew file mode 100644index 0000000000..11626437b7--- /dev/null+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ListFileChangesCommand.java@@ -0,0 +1,125 @@+package com.pmease.commons.git.command;++import java.io.File;+import java.util.ArrayList;+import java.util.Collection;++import org.apache.commons.lang3.StringUtils;+import org.slf4j.Logger;+import org.slf4j.LoggerFactory;++import com.google.common.base.Preconditions;+import com.pmease.commons.git.FileChange;+import com.pmease.commons.util.execution.Commandline;+import com.pmease.commons.util.execution.LineConsumer;++public class ListFileChangesCommand extends GitCommand<Collection<FileChange>> {++ private static final Logger logger = LoggerFactory.getLogger(ListFileChangesCommand.class);++ private String fromRev;++ private String toRev;++ private String path;++ private boolean findRenames;++ private boolean findCopies;++ public ListFileChangesCommand(final File repoDir) {+ super(repoDir);+ }++ public ListFileChangesCommand fromRev(final String fromRev) {+ this.fromRev = fromRev;+ return this;+ }++ public ListFileChangesCommand toRev(final String toRev) {+ this.toRev = toRev;+ return this;+ }++ public ListFileChangesCommand path(final String path) {+ this.path = path;+ return this;+ }++ public ListFileChangesCommand findRenames(final boolean findRenames) {+ this.findRenames = findRenames;+ return this;+ }++ public ListFileChangesCommand findCopies(final boolean findCopies) {+ this.findCopies = findCopies;+ return this;+ }++ @Override+ public Collection<FileChange> call() {+ Preconditions.checkNotNull(toRev, "toRev has to be specified.");+ Preconditions.checkNotNull(fromRev, "fromRev has to be specified.");++ final Collection<FileChange> fileChanges = new ArrayList<>();++ Commandline cmd = cmd();++ cmd.addArgs("diff", "--name-status");++ if (findRenames)+ cmd.addArgs("--find-renames");+ if (findCopies)+ cmd.addArgs("--find-copies");++ cmd.addArgs(fromRev + ".." + toRev);++ if (path != null)+ cmd.addArgs("--", path);++ cmd.execute(new LineConsumer() {++ @Override+ public void consume(String line) {+ FileChange.Action action = null;+ if (line.startsWith("A"))+ action = FileChange.Action.ADD;+ else if (line.startsWith("M"))+ action = FileChange.Action.MODIFY;+ else if (line.startsWith("D"))+ action = FileChange.Action.DELETE;+ else if (line.startsWith("C"))+ action = FileChange.Action.COPY;+ else if (line.startsWith("R"))+ action = FileChange.Action.RENAME;+ else if (line.startsWith("T"))+ action = FileChange.Action.TYPE;++ if (action != null) {+ String path = StringUtils.substringAfter(line, "\t").trim();+ String path1;+ String path2;+ if (path.indexOf('\t') != -1) {+ path1 = StringUtils.substringBefore(path, "\t").trim();+ path2 = StringUtils.substringAfter(path, "\t").trim();+ } else {+ path1 = path2 = path;+ }+ FileChange fileChange = new FileChange(action, path1, path2);+ fileChanges.add(fileChange);+ }+ }++ }, new LineConsumer() {++ @Override+ public void consume(String line) {+ logger.error(line);+ }++ }).checkReturnCode();++ return fileChanges;+ }++}diff --git a/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java b/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.javaindex 750a3f3507..33304fc2ea 100644--- a/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java+++ b/commons.git/src/main/java/com/pmease/commons/git/command/ListTreeCommand.java@@ -2,12 +2,14 @@ package com.pmease.commons.git.command;import java.io.File;import java.util.ArrayList;+import java.util.Collections;import java.util.List;import org.apache.commons.lang3.StringUtils;import org.apache.commons.lang3.math.NumberUtils;import com.google.common.base.Preconditions;+import com.pmease.commons.git.GitUtils;import com.pmease.commons.git.TreeNode;import com.pmease.commons.util.execution.Commandline;import com.pmease.commons.util.execution.LineConsumer;@@ -16,9 +18,7 @@ public class ListTreeCommand extends GitCommand<List<TreeNode>> {private String revision;- private String path;-- private boolean recursive;+ private String path = "";public ListTreeCommand(final File repoDir) {super(repoDir);@@ -30,12 +30,7 @@ public class ListTreeCommand extends GitCommand<List<TreeNode>> {}public ListTreeCommand path(String path) {- this.path = path;- return this;- }-- public ListTreeCommand recursive(boolean recursive) {- this.recursive = recursive;+ this.path = GitUtils.normalizeTreePath(path);return this;}@@ -44,11 +39,8 @@ public class ListTreeCommand extends GitCommand<List<TreeNode>> {Preconditions.checkNotNull(revision, "revision has to be specified for browse.");Commandline cmd = cmd().addArgs("ls-tree", "-l");- if (recursive)- cmd.addArgs("-r");cmd.addArgs(revision);- if (path != null)- cmd.addArgs(path);+ cmd.addArgs(path);final List<TreeNode> treeNodes = new ArrayList<TreeNode>();@@ -67,11 +59,13 @@ public class ListTreeCommand extends GitCommand<List<TreeNode>> {size = Integer.parseInt(sizeStr);String path = StringUtils.substringAfter(line.trim(), "\t");- treeNodes.add(new TreeNode(repoDir, Integer.parseInt(mode, 8), path, revision, hash, size));+ treeNodes.add(new TreeNode(Integer.parseInt(mode, 8), path, revision, hash, size));}}, errorLogger).checkReturnCode();+ Collections.sort(treeNodes);+return treeNodes;}diff --git a/commons.git/src/test/java/com/pmease/commons/git/AbstractGitTest.java b/commons.git/src/test/java/com/pmease/commons/git/AbstractGitTest.javaindex af1ba1df76..d110437362 100644--- a/commons.git/src/test/java/com/pmease/commons/git/AbstractGitTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/AbstractGitTest.java@@ -25,8 +25,6 @@ public abstract class AbstractGitTest extends AppLoaderMocker {});Assert.assertTrue(GitCommand.checkError("git") == null);--}/**diff --git a/commons.git/src/test/java/com/pmease/commons/git/GitTest.java b/commons.git/src/test/java/com/pmease/commons/git/GitTest.javanew file mode 100644index 0000000000..62c2cf787b--- /dev/null+++ b/commons.git/src/test/java/com/pmease/commons/git/GitTest.java@@ -0,0 +1,14 @@+package com.pmease.commons.git;++import static org.junit.Assert.*;++import org.junit.Test;++public class GitTest {++ @Test+ public void test() {+ fail("Not yet implemented");+ }++}diff --git a/commons.git/src/test/java/com/pmease/commons/git/RepositoryFactory.java b/commons.git/src/test/java/com/pmease/commons/git/RepositoryFactory.javadeleted file mode 100644index 719a54ce6d..0000000000--- a/commons.git/src/test/java/com/pmease/commons/git/RepositoryFactory.java+++ /dev/null@@ -1,12 +0,0 @@-package com.pmease.commons.git;--import java.io.File;--import org.eclipse.jgit.lib.Repository;--import com.google.inject.ImplementedBy;--@ImplementedBy(SimpleRepositoryFactory.class)-public interface RepositoryFactory {- Repository open(File repoDir);-}diff --git a/commons.git/src/test/java/com/pmease/commons/git/SimpleRepositoryFactory.java b/commons.git/src/test/java/com/pmease/commons/git/SimpleRepositoryFactory.javadeleted file mode 100644index 0616708559..0000000000--- a/commons.git/src/test/java/com/pmease/commons/git/SimpleRepositoryFactory.java+++ /dev/null@@ -1,23 +0,0 @@-package com.pmease.commons.git;--import java.io.File;-import java.io.IOException;--import javax.inject.Singleton;--import org.eclipse.jgit.internal.storage.file.FileRepository;-import org.eclipse.jgit.lib.Repository;--@Singleton-public class SimpleRepositoryFactory implements RepositoryFactory {-- @Override- public Repository open(File repoDir) {- try {- return new FileRepository(repoDir);- } catch (IOException e) {- throw new RuntimeException(e);- }- }--}diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/ListChangedFilesCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/ListChangedFilesCommandTest.javaindex 9ae01b39e5..d55cda754e 100644--- a/commons.git/src/test/java/com/pmease/commons/git/command/ListChangedFilesCommandTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/command/ListChangedFilesCommandTest.java@@ -39,7 +39,7 @@ public class ListChangedFilesCommandTest extends AbstractGitTest {git.add("a");git.commit("commit", false, false);- Collection<String> changedFiles = git.listChangedFiles("HEAD~4", "HEAD");+ Collection<String> changedFiles = git.listChangedFiles("HEAD~4", "HEAD", null);Assert.assertTrue(changedFiles.containsAll(Sets.newHashSet("a", "b", "c", "d")));} finally {diff --git a/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java b/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.javaindex dd1368139e..f31982a414 100644--- a/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java+++ b/commons.git/src/test/java/com/pmease/commons/git/command/ListTreeCommandTest.java@@ -64,26 +64,25 @@ public class ListTreeCommandTest extends AbstractGitTest {Git bareGit = new Git(new File(tempDir, "bare"));bareGit.clone(workGit.repoDir().getAbsolutePath(), true, false, false, null);- List<TreeNode> treeNodes = bareGit.listTree("master", null, false);+ List<TreeNode> treeNodes = bareGit.listTree("master", null);assertEquals(7, treeNodes.size());assertEquals("dir", treeNodes.get(5).getPath());assertEquals("dir", treeNodes.get(5).getName());assertEquals(FileMode.TREE, treeNodes.get(5).getMode());+assertEquals(moduleGit.repoDir().getAbsolutePath(),- new File(new String(treeNodes.get(6).show())).getCanonicalPath());+ new File(new String(treeNodes.get(6).show(bareGit))).getCanonicalPath());TreeNode dirNode = treeNodes.get(5);- treeNodes = dirNode.listChildren();+ treeNodes = bareGit.listTree(dirNode.getRevision(), dirNode.getPath());assertEquals(1, treeNodes.size());assertEquals("dir/file", treeNodes.get(0).getPath());assertEquals("file", treeNodes.get(0).getName());TreeNode fileNode = treeNodes.get(0);- assertEquals("hello world", new String(fileNode.show()));- assertEquals("dir", fileNode.getParent().getName());-+ assertEquals("hello world", new String(fileNode.show(bareGit)));} finally {FileUtils.deleteDir(tempDir);}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedDirectories.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedDirectories.javaindex 6f774b27e7..d9b9c082df 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedDirectories.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedDirectories.java@@ -62,7 +62,7 @@ public class IfTouchSpecifiedDirectories extends FileGateKeeper {@Overrideprotected CheckResult doCheckCommit(User user, Branch branch, String commit) {- for (String file: branch.getRepository().git().listChangedFiles(branch.getHeadCommit(), commit)) {+ for (String file: branch.getRepository().git().listChangedFiles(branch.getHeadCommit(), commit, null)) {for (String each: directories) {if (WildcardUtils.matchPath(each + "/**", file))return approved("Touched directory '" + each + "'.");diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFilePatterns.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFilePatterns.javaindex 11268dba20..110accbf9c 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFilePatterns.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/gatekeeper/IfTouchSpecifiedFilePatterns.java@@ -59,7 +59,7 @@ public class IfTouchSpecifiedFilePatterns extends FileGateKeeper {@Overrideprotected CheckResult doCheckCommit(User user, Branch branch, String commit) {- for (String file: branch.getRepository().git().listChangedFiles(branch.getHeadCommit(), commit)) {+ for (String file: branch.getRepository().git().listChangedFiles(branch.getHeadCommit(), commit, null)) {if (WildcardUtils.matchPath(filePatterns, file))return approved("Touched files match patterns '" + filePatterns + "'.");}diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.javaindex 02b0743eb0..a9c1d22f5f 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequest.java@@ -364,7 +364,7 @@ public class PullRequest extends AbstractEntity {public Collection<String> findTouchedFiles() {Git git = getTarget().getRepository().git();- return git.listChangedFiles(getTarget().getHeadCommit(), getLatestUpdate().getHeadCommit());+ return git.listChangedFiles(getTarget().getHeadCommit(), getLatestUpdate().getHeadCommit(), null);}public String getHeadRef() {diff --git a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.javaindex af92cc14e8..ecdb4c8821 100644--- a/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java+++ b/gitplex.core/src/main/java/com/pmease/gitplex/core/model/PullRequestUpdate.java@@ -202,7 +202,7 @@ public class PullRequestUpdate extends AbstractEntity {public Collection<String> getChangedFiles() {if (changedFiles == null)- changedFiles = getRequest().git().listChangedFiles(getReferentialCommit(), getHeadCommit());+ changedFiles = getRequest().git().listChangedFiles(getReferentialCommit(), getHeadCommit(), null);return changedFiles;}diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/directory/DirectoryChooser.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/directory/DirectoryChooser.javaindex 438068b76f..6370b1972a 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/directory/DirectoryChooser.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/directory/DirectoryChooser.java@@ -39,7 +39,7 @@ public abstract class DirectoryChooser extends Panel {public Iterator<? extends TreeNode> getRoots() {if (getBranch() != null) {Git git = getBranch().getRepository().git();- List<TreeNode> roots = git.listTree(getBranch().getName(), null, false);+ List<TreeNode> roots = git.listTree(getBranch().getName(), null);if (roots != null) {for (Iterator<TreeNode> it = roots.iterator(); it.hasNext();) {if (it.next().getMode() != FileMode.TREE)@@ -61,7 +61,7 @@ public abstract class DirectoryChooser extends Panel {@Overridepublic Iterator<? extends TreeNode> getChildren(TreeNode node) {- List<TreeNode> children = node.listChildren();+ List<TreeNode> children = node.listChildren(getBranch().getRepository().git());if (children != null) {for (Iterator<TreeNode> it = children.iterator(); it.hasNext();) {if (it.next().getMode() != FileMode.TREE)diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/tree/RepoTreePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/tree/RepoTreePage.javaindex 5c10e0209c..691ced8a76 100644--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/tree/RepoTreePage.java+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/repository/info/code/tree/RepoTreePage.java@@ -39,7 +39,7 @@ public class RepoTreePage extends RepositoryInfoPage {path = UrlUtils.removeRedundantSlashes(path + "/");}- List<TreeNode> nodes = Lists.newArrayList(git.listTree(getRepository().defaultBranchIfNull(getCurrentRevision()), path, false));+ List<TreeNode> nodes = Lists.newArrayList(git.listTree(getRepository().defaultBranchIfNull(getCurrentRevision()), path));Collections.sort(nodes, new Comparator<TreeNode>() {