1

git2go 的 git.Patch 或 libgit2 的 git_patch 返回以下格式的 String 值:

"diff": "diff --git a/test b/test
         index 9daeafb..dced80a 100644  
         --- a/test 
         +++ b/test 
         @@ -1 +1,3 @@  
         test
         +  
         +test"

请注意,这index 9daeafb..dced80a 100644不是完整的索引。无论如何使用 libgit2 / git2go 来返回完整索引?即跑步的等价性git diff --full-index

4

1 回答 1

2

所以我设法得到了一些外部帮助。如果有人遇到同样的问题,可以使用以下方法返回:

git_diff_options在 libgit2 中并设置id_abbrev为 40。 https://libgit2.github.com/libgit2/#HEAD/type/git_diff_options

DiffOptions在 git2go 中设置IdAbbrev为 40。 https://godoc.org/github.com/libgit2/git2go#DiffOptions

于 2015-03-04T05:18:27.093 回答