0

TreeWalk allows to get all changes in single commit or in whole repository and checking changed files for each commit (by RevWalk) works really slow, about 2 minutes. Is there any method to walk through changed files and check in which commit they has been changed last time? Or other faster solution? Here is my code for getting changed files from commit:

TreeWalk treeWalk = prepareTreeWalk(commit, git.getRepository());
List<String> files = new ArrayList<>();
while (treeWalk.next()) {
  if (!hasSimilar(treeWalk)) {
    files.add(treeWalk.getPathString());
  }
}

and for selecting commits (since some special):

return Lists.reverse(StreamSupport.stream(
  git.log()
  .add(git.getRepository().resolve(branch.getName()))
  .call()
  .spliterator(), false)
    .filter(since(sinceCommit::equals))
    .collect(Collectors.toList()));
Vadym Borys
  • 115
  • 2
  • 11
  • Against wich other commit would you compare the 'since commit' to get the changed files? Would that be `HEAD`? – Rüdiger Herrmann Apr 25 '19 at 08:24
  • from some old commit until newest in current branch – Vadym Borys Apr 25 '19 at 09:07
  • 1
    I think your question is answered here: https://stackoverflow.com/questions/28785364/list-of-files-changed-between-commits-with-jgit To find the 'since' commit, I recommend using a plain `RevWalk` with a date filter like shown here: https://stackoverflow.com/questions/31074116/checkout-a-specific-revision-based-on-the-commit-date-with-jgit – Rüdiger Herrmann Apr 25 '19 at 09:20

1 Answers1

-1

I know command line below, it will print the output within ms

git format-patch initial-commit --stdout > output.patch