当我git show commit在存储库中进行第一次提交时,我会看到所有文件以及文件的差异(即添加的所有行)
$ git show cb5d132
commit cb5d13286cf9d14782f0e10445456dfe41072f55
Author: tw2 tw2LastName <tw2>
Date: Thu Oct 23 05:15:09 2014 -0400
Initial Commit
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..96d156e
--- /dev/null
+++ b/README.txt
@@ -0,0 +1 @@
+First Line in README file!
\ No newline at end of file
Run Code Online (Sandbox Code Playgroud)
似乎jgit show没有获得类似的信息,如何使用 JGit API 获得类似的输出?我可以使用DiffFormatter,但它似乎需要 baseTree 和 commitTree,想知道如何让它们DiffFormatter在存储库中的第一次提交上工作。
ByteArrayOutputStream os = new ByteArrayOutputStream();
DiffFormatter df = new DiffFormatter( os ) …Run Code Online (Sandbox Code Playgroud) jgit ×1