Community
Participate
Working Groups
When executing the following code with a file changed in the worktree: Repository repo = new RepositoryBuilder().findGitDir(new File("path/to/repo")).setMustExist(true).build(); DiffFormatter diffFormatter = new DiffFormatter(System.out); diffFormatter.setRepository(repo); diffFormatter.format(new Git(repo).diff().setOldTree(new EmptyTreeIterator()).call().iterator().next()); you get a missing object exception. In my case it is org.eclipse.jgit.errors.MissingObjectException: Missing blob cb188f8580dd4e09a90757478e8be4b7b69f7c37 at org.eclipse.jgit.internal.storage.file.WindowCursor.open(WindowCursor.java:170) at org.eclipse.jgit.diff.ContentSource$ObjectReaderSource.open(ContentSource.java:145) at org.eclipse.jgit.diff.ContentSource$Pair.open(ContentSource.java:282) at org.eclipse.jgit.diff.DiffFormatter.open(DiffFormatter.java:1073) at org.eclipse.jgit.diff.DiffFormatter.createFormatResult(DiffFormatter.java:1001) at org.eclipse.jgit.diff.DiffFormatter.format(DiffFormatter.java:706) at org.eclipse.jgit.diff.DiffFormatter$format$3.call(Unknown Source) at ConsoleScript15.run(ConsoleScript15:17) Where the blob that is missing is the blob of the file in the work tree: $ git diff diff --git a/file-in-first-commit.xoo b/file-in-first-commit.xoo index bd4a117..cb188f8 100644 --- a/file-in-first-commit.xoo +++ b/file-in-first-commit.xoo @@ -1,3 +1,4 @@ ...