英文:
Getting full indexes of a patch using libgit2 / git2go
问题
git2go的git.Patch或libgit2的git_patch返回以下格式的字符串值:
"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
的等效方式?
英文:
git2go's git.Patch or libgit2's git_patch returns a String value of the following format:
"diff": "diff --git a/test b/test
index 9daeafb..dced80a 100644
--- a/test
+++ b/test
@@ -1 +1,3 @@
test
+
+test"
Notice that index 9daeafb..dced80a 100644
is not the full index. Is there anyway using libgit2 / git2go to return the full index? i.e. the equivalence of running git diff --full-index
?
答案1
得分: 2
所以我设法得到了一些外部帮助。如果有人遇到相同的问题,可以使用以下方法返回:
在libgit2中使用git_diff_options
,并将id_abbrev
设置为40。
https://libgit2.github.com/libgit2/#HEAD/type/git_diff_options
或者在git2go中使用DiffOptions
,并将IdAbbrev
设置为40。
https://godoc.org/github.com/libgit2/git2go#DiffOptions
英文:
So I've managed to get some outside help. If anyone runs into the same issue, it can be returned using:
git_diff_options
in libgit2 and setting id_abbrev
to 40.
https://libgit2.github.com/libgit2/#HEAD/type/git_diff_options
or DiffOptions
in git2go and setting IdAbbrev
to 40.
https://godoc.org/github.com/libgit2/git2go#DiffOptions
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论