2022-02-26 22:36:28 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
allow pagination on arbitrary position
diff --git a/git.lua b/git.lua index c50422f..7f27c1b 100644 --- a/git.lua +++ b/git.lua @@ -196,8 +196,9 @@ function Repo:find_prev(cid, dist) commit = commit:parent() end if cids[#cids] == cid then - if #cids > dist then - return self:commit(cids[#cids - dist]) + if #cids > 1 then + local index = math.max(1, #cids - dist) + return self:commit(cids[index]) else return nil end