1
應用diff或補丁文件如何將該diff作爲提交應用到我的dest分支?當我使用堅固的git庫時,如何使用git堅固耐用的
# @param src [Rugged::Object] - the rugged object or string to compare from
# @param dst [Rugged::Object] - the rugged object or string to compare to, defaults to parent
# @return [Rugged::Diff] a rugged diff object between src and dst
def create_diff(src, dst = nil)
src = repo.lookup(find_ref(src))
dst ||= repo.lookup(src.parents.first)
dst = find_ref(dst)
src.diff(dst)
end
# @param sha_or_ref [String] - the name or sha of the ref
# @return [String] the oid of the sha or ref
def find_ref(sha_or_ref)
case sha_or_ref
when Rugged::Object
sha_or_ref.oid
else
repo.rev_parse_oid(sha_or_ref)
end
end
難道沒有簡單的方法來應用補丁或差異嗎?似乎很愚蠢,我需要循環diff中的每個更改並添加/ rm文件。