Index

resty-gitweb / 0bfe00a

A git web interface for Lua/OpenResty (you're on it right now!)

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
703 Jan 2021 10:11609d330libgit2 binding updates, README updatesJosh Stockin1270G

Blob @ resty-gitweb / git / repo.lua

text/plain651 bytesdownload raw
1-- resty-gitweb@git/repo.lua
2-- git repository utilities
3
4-- Copyright (c) 2020 Joshua 'joshuas3' Stockin
5-- <https://git.joshstock.in/resty-gitweb>
6-- This software is licensed under the MIT License.
7
8local ffi = require("ffi")
9
10local _M = {}
11
12-- Returns [bool exists, git_repository* repo]
13_M.open = function(repo_dir)
14 local repo_obj = ffi.new("git_repository*[1]")
15 err = git2.git_repository_open(ffi.cast("git_repository**", repo_obj), repo_dir)
16 ret_obj = nil
17 if err == 0 then
18 ret_obj = repo_obj[0]
19 end
20 return err == 0, ret_obj
21end
22
23_M.free = function(repo_obj)
24 git2.git_repository_free(repo_obj)
25end
26
27return _M
28