使用libgit2 / git2go获取补丁的完整索引。

huangapple go评论81阅读模式
英文:

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

huangapple
  • 本文由 发表于 2015年3月4日 12:16:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/28846582.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定