2022-02-26 18:44:13 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
return nil as parent of first commit
diff --git a/git.lua b/git.lua index 8b14409..be31587 100644 --- a/git.lua +++ b/git.lua @@ -108,8 +108,12 @@ end function Commit:parent(n) n = n or 1 local pcommit = ffi.new("git_commit *[1]") - C.git_commit_parent(pcommit, self.commit, n-1) - return get_commit(pcommit[0]) + local ret = C.git_commit_parent(pcommit, self.commit, n-1) + if ret == 0 then + return get_commit(pcommit[0]) + else + return nil + end end local Repo = {}