├── .gitignore ├── CMakeLists.txt ├── COPYRIGHT ├── README.md ├── cmake └── LuaNativeObjects.cmake ├── docs ├── git2.luadoc ├── git2 │ ├── Blob.luadoc │ ├── Commit.luadoc │ ├── Config.luadoc │ ├── Index.luadoc │ ├── IndexEntry.luadoc │ ├── IndexEntryUnmerged.luadoc │ ├── ODB.luadoc │ ├── ODBBackend.luadoc │ ├── OID.luadoc │ ├── OID_Shorten.luadoc │ ├── Object.luadoc │ ├── OdbObject.luadoc │ ├── Reference.luadoc │ ├── Repository.luadoc │ ├── RevWalk.luadoc │ ├── Signature.luadoc │ ├── StrArray.luadoc │ ├── Tag.luadoc │ ├── Tree.luadoc │ └── TreeEntry.luadoc ├── index.html ├── libgit2.json ├── luadoc.css └── modules │ ├── Blob.html │ ├── Commit.html │ ├── Config.html │ ├── Index.html │ ├── IndexEntry.html │ ├── IndexEntryUnmerged.html │ ├── ODB.html │ ├── ODBBackend.html │ ├── OID.html │ ├── OID_Shorten.html │ ├── Object.html │ ├── OdbObject.html │ ├── Reference.html │ ├── Repository.html │ ├── RevWalk.html │ ├── Signature.html │ ├── StrArray.html │ ├── Tag.html │ ├── Tree.html │ ├── TreeEntry.html │ └── git2.html ├── git2.nobj.lua ├── rockspecs ├── lua-git2-0.1.rockspec └── lua-git2-scm-0.rockspec ├── src ├── blob.nobj.lua ├── commit.nobj.lua ├── config.nobj.lua ├── error.nobj.lua ├── index.nobj.lua ├── index_entry.nobj.lua ├── index_entry_unmerged.nobj.lua ├── object.nobj.lua ├── odb.nobj.lua ├── odb_backend.nobj.lua ├── odb_object.nobj.lua ├── oid.nobj.lua ├── oid_shorten.nobj.lua ├── pre_generated-git2.nobj.c ├── reference.nobj.lua ├── repository.nobj.lua ├── revwalk.nobj.lua ├── signature.nobj.lua ├── strarray.nobj.lua ├── tag.nobj.lua ├── tree.nobj.lua └── tree_entry.nobj.lua ├── tests ├── test_backend.lua ├── test_rep.git.tbz └── test_rep.lua └── utils.lua /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # Lua bindings for libgit2 3 | # 4 | cmake_minimum_required(VERSION 3.18) 5 | 6 | project(lua-git2 C) 7 | 8 | set(BUILD_SHARED_LIBS TRUE) 9 | 10 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) 11 | 12 | set(INSTALL_CMOD share/lua/cmod CACHE PATH "Directory to install Lua binary modules (configure lua via LUA_CPATH)") 13 | 14 | set(COMMON_CFLAGS "${CFLAGS}") 15 | set(COMMON_LIBS) 16 | 17 | ## Lua 5.x 18 | include(FindLua) 19 | if(NOT ${LUA_FOUND}) 20 | message(FATAL_ERROR "The FindLua module could not find lua :-(") 21 | endif() 22 | set(COMMON_LIBS "${COMMON_LIBS};${LUA_LIBRARIES}") 23 | include_directories(${LUA_INCLUDE_DIR}) 24 | 25 | ## LibGit2 26 | include(FindPkgConfig) 27 | pkg_search_module(GIT2 REQUIRED libgit2>=0.17.0) 28 | add_definitions(${GIT2_CFLAGS}) 29 | link_directories(${GIT2_LIBRARY_DIRS}) 30 | include_directories(${GIT2_INCLUDE_DIRS}) 31 | set(COMMON_LIBS "${COMMON_LIBS};${GIT2_LIBRARIES}") 32 | 33 | ## LuaNativeObjects 34 | include(LuaNativeObjects) 35 | 36 | include_directories(${CMAKE_CURRENT_SOURCE_DIR} 37 | ${CMAKE_CURRENT_BINARY_DIR}) 38 | 39 | # 40 | # Setup CMAKE_C_FLAGS* and CMAKE_CXX_FLAGS* 41 | # 42 | if(CMAKE_COMPILER_IS_GNUCC) 43 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -Wextra -Wshadow -W -pedantic -std=gnu99 -fgnu89-inline") 44 | set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -march=native -g") 45 | set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g") 46 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -O2 -g -DNDEBUG") 47 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2 -g") 48 | endif(CMAKE_COMPILER_IS_GNUCC) 49 | 50 | ## LuaGit2 51 | set(LUA_GIT2_SRC 52 | git2.nobj.lua 53 | ) 54 | 55 | if(${USE_PRE_GENERATED_BINDINGS}) 56 | set(LUA_GIT2_SRC src/pre_generated-git2.nobj.c) 57 | else() 58 | # Generate Lua bindings. 59 | GenLuaNativeObjects(LUA_GIT2_SRC) 60 | endif() 61 | 62 | add_library(lua-git2 MODULE ${LUA_GIT2_SRC}) 63 | target_link_libraries(lua-git2 ${COMMON_LIBS}) 64 | set_target_properties(lua-git2 PROPERTIES PREFIX "") 65 | set_target_properties(lua-git2 PROPERTIES COMPILE_FLAGS "${COMMON_CFLAGS}") 66 | set_target_properties(lua-git2 PROPERTIES OUTPUT_NAME git2) 67 | 68 | install(TARGETS lua-git2 69 | DESTINATION "${INSTALL_CMOD}") 70 | 71 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | luagit2 2 | ======= 3 | 4 | LibGit2 bindings for Lua. [API Docs](http://libgit2.github.com/luagit2/) 5 | 6 | libgit2 version 7 | --------------- 8 | 9 | Currently supports version >= 0.17 10 | 11 | Installing 12 | ---------- 13 | 14 | ### Install lua-git2: 15 | 16 | luarocks install https://raw.github.com/libgit2/luagit2/master/lua-git2-scm-0.rockspec 17 | 18 | 19 | To re-generating the bindings 20 | ----------------------------- 21 | 22 | You will need to install LuaNativeObjects and set the CMake variable `USE_PRE_GENERATED_BINDINGS` to FALSE. 23 | By default CMake will use the pre-generated bindings that are include in the project. 24 | 25 | Build Dependencies 26 | ------------------ 27 | 28 | Optional dependency for re-generating Lua bindings from `*.nobj.lua` files: 29 | 30 | * [LuaNativeObjects](https://github.com/Neopallium/LuaNativeObjects), this is the bindings generator used to convert the `*.nobj.lua` files into a native Lua module. 31 | 32 | -------------------------------------------------------------------------------- /cmake/LuaNativeObjects.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Lua Native Objects 3 | # 4 | 5 | find_program(LUA_NATIVE_OBJECTS_EXECUTABLE native_objects.lua 6 | PATHS ${CMAKE_SOURCE_DIR}/../LuaNativeObjects 7 | DOC "LuaNativeObjects executable path") 8 | set(USE_PRE_GENERATED_BINDINGS TRUE CACHE BOOL 9 | "Set this to FALSE to re-generate bindings using LuaNativeObjects") 10 | set(GENERATE_LUADOCS TRUE CACHE BOOL 11 | "Set this to FALSE to avoid generation of docs using LuaDoc") 12 | 13 | macro(GenLuaNativeObjects _src_files_var) 14 | set(_new_src_files) 15 | foreach(_src_file ${${_src_files_var}}) 16 | if(_src_file MATCHES ".nobj.lua") 17 | string(REGEX REPLACE ".nobj.lua" ".nobj.c" _src_file_out ${_src_file}) 18 | string(REGEX REPLACE ".nobj.lua" ".nobj.ffi.lua" _ffi_file_out ${_src_file}) 19 | add_custom_command(OUTPUT ${_src_file_out} ${_ffi_file_out} 20 | COMMAND ${LUA_NATIVE_OBJECTS_EXECUTABLE} -outpath ${CMAKE_CURRENT_BINARY_DIR} -gen lua ${_src_file} 21 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 22 | DEPENDS ${_src_file} 23 | ) 24 | set_source_files_properties(${_src_file_out} PROPERTIES GENERATED TRUE) 25 | set_source_files_properties(${_ffi_file_out} PROPERTIES GENERATED TRUE) 26 | if (${GENERATE_LUADOCS}) 27 | string(REGEX REPLACE ".nobj.lua" "" _doc_base ${_src_file}) 28 | string(REGEX REPLACE ".nobj.lua" ".luadoc" _doc_file_out ${_src_file}) 29 | add_custom_target(${_doc_file_out} ALL 30 | COMMAND ${LUA_NATIVE_OBJECTS_EXECUTABLE} -outpath docs -gen luadoc ${_src_file} 31 | COMMAND luadoc -nofiles -d docs docs 32 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 33 | DEPENDS ${_src_file} 34 | ) 35 | endif() 36 | set_source_files_properties(${_doc_file_out} PROPERTIES GENERATED TRUE) 37 | set(_new_src_files ${_new_src_files} ${_src_file_out}) 38 | else(_src_file MATCHES ".nobj.lua") 39 | set(_new_src_files ${_new_src_files} ${_src_file}) 40 | endif(_src_file MATCHES ".nobj.lua") 41 | endforeach(_src_file) 42 | set(${_src_files_var} ${_new_src_files}) 43 | endmacro(GenLuaNativeObjects _src_files_var) 44 | 45 | -------------------------------------------------------------------------------- /docs/git2.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Module git2. 6 | -- 7 | -- See libgit2 API docs. 8 | -- 9 | --
Class StrArray 10 | --
Class Repository 11 | --
Class Config 12 | --
Class OdbObject 13 | --
Class OID 14 | --
Class OID_Shorten 15 | --
Class ODB 16 | --
Class ODBBackend 17 | --
Class Index 18 | --
Class IndexEntry 19 | --
Class IndexEntryUnmerged 20 | --
Class Object 21 | --
Class Blob 22 | --
Class Signature 23 | --
Class Commit 24 | --
Class Tree 25 | --
Class TreeEntry 26 | --
Class Tag 27 | --
Class RevWalk 28 | --
Class Reference 29 | module("git2") 30 | 31 | --- module function. 32 | -- 33 | -- @return nil. 34 | -- @name git2.version 35 | function git2.version() 36 | end 37 | 38 | -------------------------------------------------------------------------------- /docs/git2/Blob.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Blob". 6 | -- 7 | -- Extends Object
8 | module("Blob") 9 | 10 | --- Create a new Blob object. 11 | -- 12 | --

Calls git_blob_lookup:

13 | -- @param repo the repo to use when locating the blob.. Must be of type Repository. 14 | -- @param id identity of the blob to locate.. Must be of type OID. 15 | -- @return Blob or nil on error. 16 | -- @return Error string. 17 | -- @name Blob.lookup 18 | function Blob.lookup(repo, id) 19 | end 20 | 21 | --- module function. 22 | -- 23 | -- @param repo Must be of type Repository. 24 | -- @param path Must be of type string. 25 | -- @return OID or nil on error. 26 | -- @return Error string. 27 | -- @name Blob.from_disk 28 | function Blob.from_disk(repo, path) 29 | end 30 | 31 | --- module function. 32 | -- 33 | -- @param repo Must be of type Repository. 34 | -- @param buffer Must be of type string. 35 | -- @return OID or nil on error. 36 | -- @return Error string. 37 | -- @name Blob.from_buffer 38 | function Blob.from_buffer(repo, buffer) 39 | end 40 | 41 | --- object method. 42 | -- 43 | --

Calls git_blob_rawcontent:

A pointer to the raw content of a blob is returned; 44 | -- this pointer is owned internally by the object and shall 45 | -- not be free'd. The pointer may be invalidated at a later 46 | -- time. 47 | --

Calls git_blob_rawsize:

48 | -- @return string. 49 | -- @name Blob:rawcontent 50 | function Blob:rawcontent() 51 | end 52 | 53 | --- object method. 54 | -- 55 | --

Calls git_blob_rawsize:

56 | -- @return integer. 57 | -- @name Blob:rawsize 58 | function Blob:rawsize() 59 | end 60 | 61 | --- Destroy this object (will be called by Garbage Collector). 62 | -- 63 | --

Calls git_object_free:

This method instructs the library to close an existing 64 | -- object; note that git_objects are owned and cached by the repository 65 | -- so the object may or may not be freed after this library call, 66 | -- depending on how agressive is the caching mechanism used 67 | -- by the repository.

IMPORTANT: 68 | -- It *is* necessary to call this method when you stop using 69 | -- an object. Failure to do so will cause a memory leak. 70 | -- @name Object:free 71 | function Object:free() 72 | end 73 | 74 | --- object method. 75 | -- 76 | --

Calls git_object_id:

77 | -- @return OID. 78 | -- @name Object:id 79 | function Object:id() 80 | end 81 | 82 | --- object method. 83 | -- 84 | --

Calls git_object_type:

85 | -- @return string. 86 | -- @name Object:type 87 | function Object:type() 88 | end 89 | 90 | --- object method. 91 | -- 92 | --

Calls git_object_owner:

Freeing or calling `git_repository_close` on the 93 | -- returned pointer will invalidate the actual object.

Any other operation may be run on the repository without 94 | -- affecting the object. 95 | -- @return Repository. 96 | -- @name Object:owner 97 | function Object:owner() 98 | end 99 | 100 | -------------------------------------------------------------------------------- /docs/git2/Commit.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Commit". 6 | -- 7 | -- Extends Object
8 | module("Commit") 9 | 10 | --- Create a new Commit object. 11 | -- 12 | --

Calls git_commit_lookup:

13 | -- @param repo the repo to use when locating the commit.. Must be of type Repository. 14 | -- @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit.. Must be of type OID. 15 | -- @return Commit or nil on error. 16 | -- @return Error string. 17 | -- @name Commit.lookup 18 | function Commit.lookup(repo, id) 19 | end 20 | 21 | --- module function. 22 | -- 23 | -- @param oid Must be of type OID. 24 | -- @param repo Must be of type Repository. 25 | -- @param update_ref Must be of type string. 26 | -- @param author Must be of type Signature. 27 | -- @param committer Must be of type Signature. 28 | -- @param message_encoding Must be of type string. 29 | -- @param message Must be of type string. 30 | -- @param tree Must be of type Tree. 31 | -- @param parent Must be of type Commit. 32 | -- @return true if no error. 33 | -- @return Error string. 34 | -- @name Commit.create 35 | function Commit.create(oid, repo, update_ref, author, committer, message_encoding, message, tree, parent) 36 | end 37 | 38 | --- object method. 39 | -- 40 | --

Calls git_commit_id:

41 | -- @return OID. 42 | -- @name Commit:id 43 | function Commit:id() 44 | end 45 | 46 | --- object method. 47 | -- 48 | --

Calls git_commit_message_encoding:

The encoding may be NULL if the `encoding` header 49 | -- in the commit is missing; in that case UTF-8 is assumed. 50 | -- @return string. 51 | -- @name Commit:message_encoding 52 | function Commit:message_encoding() 53 | end 54 | 55 | --- object method. 56 | -- 57 | --

Calls git_commit_message:

58 | -- @return string. 59 | -- @name Commit:message 60 | function Commit:message() 61 | end 62 | 63 | --- object method. 64 | -- 65 | --

Calls git_commit_time:

66 | -- @return integer. 67 | -- @name Commit:time 68 | function Commit:time() 69 | end 70 | 71 | --- object method. 72 | -- 73 | --

Calls git_commit_time_offset:

74 | -- @return integer. 75 | -- @name Commit:time_offset 76 | function Commit:time_offset() 77 | end 78 | 79 | --- object method. 80 | -- 81 | --

Calls git_commit_committer:

82 | -- @return Signature. 83 | -- @name Commit:committer 84 | function Commit:committer() 85 | end 86 | 87 | --- object method. 88 | -- 89 | --

Calls git_commit_author:

90 | -- @return Signature. 91 | -- @name Commit:author 92 | function Commit:author() 93 | end 94 | 95 | --- object method. 96 | -- 97 | --

Calls git_commit_tree:

98 | -- @return Tree or nil on error. 99 | -- @return Error string. 100 | -- @name Commit:tree 101 | function Commit:tree() 102 | end 103 | 104 | --- object method. 105 | -- 106 | --

Calls git_commit_parentcount:

107 | -- @return integer. 108 | -- @name Commit:parentcount 109 | function Commit:parentcount() 110 | end 111 | 112 | --- object method. 113 | -- 114 | --

Calls git_commit_parent:

115 | -- @param n the position of the parent (from 0 to `parentcount`). Must be of type integer. 116 | -- @return Commit or nil on error. 117 | -- @return Error string. 118 | -- @name Commit:parent 119 | function Commit:parent(n) 120 | end 121 | 122 | --- Destroy this object (will be called by Garbage Collector). 123 | -- 124 | --

Calls git_object_free:

This method instructs the library to close an existing 125 | -- object; note that git_objects are owned and cached by the repository 126 | -- so the object may or may not be freed after this library call, 127 | -- depending on how agressive is the caching mechanism used 128 | -- by the repository.

IMPORTANT: 129 | -- It *is* necessary to call this method when you stop using 130 | -- an object. Failure to do so will cause a memory leak. 131 | -- @name Object:free 132 | function Object:free() 133 | end 134 | 135 | --- object method. 136 | -- 137 | --

Calls git_object_id:

138 | -- @return OID. 139 | -- @name Object:id 140 | function Object:id() 141 | end 142 | 143 | --- object method. 144 | -- 145 | --

Calls git_object_type:

146 | -- @return string. 147 | -- @name Object:type 148 | function Object:type() 149 | end 150 | 151 | --- object method. 152 | -- 153 | --

Calls git_object_owner:

Freeing or calling `git_repository_close` on the 154 | -- returned pointer will invalidate the actual object.

Any other operation may be run on the repository without 155 | -- affecting the object. 156 | -- @return Repository. 157 | -- @name Object:owner 158 | function Object:owner() 159 | end 160 | 161 | -------------------------------------------------------------------------------- /docs/git2/Config.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Config". 6 | -- 7 | module("Config") 8 | 9 | --- Create a new Config object. 10 | -- 11 | --

Calls git_config_new:

This object is empty, so you have to add a file to it before you 12 | -- can do anything with it. 13 | -- @return Config or nil on error. 14 | -- @return Error string. 15 | -- @name Config.new 16 | function Config.new() 17 | end 18 | 19 | --- Create a new Config object. 20 | -- 21 | --

Calls git_config_open_ondisk:

This method is a simple utility wrapper for the following sequence 22 | -- of calls: 23 | -- - git_config_new 24 | -- - git_config_add_file_ondisk 25 | -- @param path Path to the on-disk file to open. Must be of type string. 26 | -- @return Config or nil on error. 27 | -- @return Error string. 28 | -- @name Config.open 29 | function Config.open(path) 30 | end 31 | 32 | --- Destroy this object (will be called by Garbage Collector). 33 | -- 34 | --

Calls git_config_free:

35 | -- @name Config:free 36 | function Config:free() 37 | end 38 | 39 | --- object method. 40 | -- 41 | --

Calls git_config_add_file_ondisk:

The on-disk file pointed at by `path` will be opened and 42 | -- parsed; it's expected to be a native Git config file following 43 | -- the default Git config syntax (see man git-config).

Note that the configuration object will free the file 44 | -- automatically.

Further queries on this config object will access each 45 | -- of the config file instances in order (instances with 46 | -- a higher priority will be accessed first). 47 | -- @param path path to the configuration file (backend) to add. Must be of type string. 48 | -- @param level Must be of type integer. 49 | -- @param repo Must be of type Repository. 50 | -- @param force Must be of type integer. 51 | -- @return true if no error. 52 | -- @return Error string. 53 | -- @name Config:add_file_ondisk 54 | function Config:add_file_ondisk(path, level, repo, force) 55 | end 56 | 57 | --- object method. 58 | -- 59 | -- @param name Must be of type string. 60 | -- @return integer or nil on error. 61 | -- @return Error string. 62 | -- @name Config:get_int32 63 | function Config:get_int32(name) 64 | end 65 | 66 | --- object method. 67 | -- 68 | -- @param name Must be of type string. 69 | -- @param value Must be of type integer. 70 | -- @return true if no error. 71 | -- @return Error string. 72 | -- @name Config:set_int32 73 | function Config:set_int32(name, value) 74 | end 75 | 76 | --- object method. 77 | -- 78 | -- @param name Must be of type string. 79 | -- @return integer or nil on error. 80 | -- @return Error string. 81 | -- @name Config:get_int64 82 | function Config:get_int64(name) 83 | end 84 | 85 | --- object method. 86 | -- 87 | -- @param name Must be of type string. 88 | -- @param value Must be of type integer. 89 | -- @return true if no error. 90 | -- @return Error string. 91 | -- @name Config:set_int64 92 | function Config:set_int64(name, value) 93 | end 94 | 95 | --- object method. 96 | -- 97 | --

Calls git_config_get_bool:

This function uses the usual C convention of 0 being false and 98 | -- anything else true. 99 | -- @param name the variable's name. Must be of type string. 100 | -- @return boolean or nil on error. 101 | -- @return Error string. 102 | -- @name Config:get_bool 103 | function Config:get_bool(name) 104 | end 105 | 106 | --- object method. 107 | -- 108 | --

Calls git_config_set_bool:

109 | -- @param value the value to store. Must be of type boolean. 110 | -- @param name the variable's name. Must be of type string. 111 | -- @return true if no error. 112 | -- @return Error string. 113 | -- @name Config:set_bool 114 | function Config:set_bool(value, name) 115 | end 116 | 117 | --- object method. 118 | -- 119 | --

Calls git_config_get_string:

The string is owned by the variable and should not be freed by the 120 | -- user. 121 | -- @param name the variable's name. Must be of type string. 122 | -- @return string or nil on error. 123 | -- @return Error string. 124 | -- @name Config:get_string 125 | function Config:get_string(name) 126 | end 127 | 128 | --- object method. 129 | -- 130 | --

Calls git_config_set_string:

A copy of the string is made and the user is free to use it 131 | -- afterwards. 132 | -- @param name the variable's name. Must be of type string. 133 | -- @param value the string to store.. Must be of type string. 134 | -- @return true if no error. 135 | -- @return Error string. 136 | -- @name Config:set_string 137 | function Config:set_string(name, value) 138 | end 139 | 140 | --- object method. 141 | -- 142 | -- @param name Must be of type string. 143 | -- @return true if no error. 144 | -- @return Error string. 145 | -- @name Config:delete_entry 146 | function Config:delete_entry(name) 147 | end 148 | 149 | --- object method. 150 | -- 151 | -- @param name Must be of type string. 152 | -- @param regexp Must be of type string. 153 | -- @return true if no error. 154 | -- @return Error string. 155 | -- @name Config:delete_multivar 156 | function Config:delete_multivar(name, regexp) 157 | end 158 | 159 | -------------------------------------------------------------------------------- /docs/git2/Index.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Index". 6 | -- 7 | module("Index") 8 | 9 | --- Create a new Index object. 10 | -- 11 | --

Calls git_index_open:

Since there is no ODB or working directory behind this index, 12 | -- any Index methods which rely on these (e.g. index_add) will 13 | -- fail with the GIT_EBAREINDEX error code.

If you need to access the index of an actual repository, 14 | -- use the `git_repository_index` wrapper.

The index must be freed once it's no longer in use. 15 | -- @param index_path the path to the index file in disk. Must be of type string. 16 | -- @return Index or nil on error. 17 | -- @return Error string. 18 | -- @name Index.bare 19 | function Index.bare(index_path) 20 | end 21 | 22 | --- object method. 23 | -- 24 | --

Calls git_index_clear:

25 | -- @name Index:clear 26 | function Index:clear() 27 | end 28 | 29 | --- object method. 30 | -- 31 | --

Calls git_index_read:

32 | -- @param force Must be of type integer. 33 | -- @return true if no error. 34 | -- @return Error string. 35 | -- @name Index:read 36 | function Index:read(force) 37 | end 38 | 39 | --- object method. 40 | -- 41 | --

Calls git_index_write:

42 | -- @return true if no error. 43 | -- @return Error string. 44 | -- @name Index:write 45 | function Index:write() 46 | end 47 | 48 | --- object method. 49 | -- 50 | --

Calls git_index_find:

51 | -- @param at_pos Must be of type lightuserdata. 52 | -- @param path path to search. Must be of type string. 53 | -- @return integer. 54 | -- @name Index:find 55 | function Index:find(at_pos, path) 56 | end 57 | 58 | --- object method. 59 | -- 60 | -- @param path Must be of type string. 61 | -- @return true if no error. 62 | -- @return Error string. 63 | -- @name Index:add_bypath 64 | function Index:add_bypath(path) 65 | end 66 | 67 | --- object method. 68 | -- 69 | --

Calls git_index_add:

The file `path` must be relative to the repository's 70 | -- working folder and must be readable.

This method will fail in bare index instances.

This forces the file to be added to the index, not looking 71 | -- at gitignore rules. Those rules can be evaluated through 72 | -- the git_status APIs (in status.h) before calling this. 73 | -- @param source_entry Must be of type IndexEntry. 74 | -- @return true if no error. 75 | -- @return Error string. 76 | -- @name Index:add 77 | function Index:add(source_entry) 78 | end 79 | 80 | --- object method. 81 | -- 82 | --

Calls git_index_remove:

83 | -- @param path Must be of type string. 84 | -- @param stage Must be of type integer. 85 | -- @return true if no error. 86 | -- @return Error string. 87 | -- @name Index:remove 88 | function Index:remove(path, stage) 89 | end 90 | 91 | --- object method. 92 | -- 93 | -- @param n Must be of type integer. 94 | -- @return IndexEntry. 95 | -- @name Index:get_byindex 96 | function Index:get_byindex(n) 97 | end 98 | 99 | --- object method. 100 | -- 101 | -- @param path Must be of type string. 102 | -- @param stage Must be of type integer. 103 | -- @return IndexEntry. 104 | -- @name Index:get_bypath 105 | function Index:get_bypath(path, stage) 106 | end 107 | 108 | --- object method. 109 | -- 110 | --

Calls git_index_entrycount:

111 | -- @return integer. 112 | -- @name Index:entrycount 113 | function Index:entrycount() 114 | end 115 | 116 | --- object method. 117 | -- 118 | -- @return integer. 119 | -- @name Index:reuc_entrycount 120 | function Index:reuc_entrycount() 121 | end 122 | 123 | --- object method. 124 | -- 125 | -- @param path Must be of type string. 126 | -- @return IndexEntryUnmerged. 127 | -- @name Index:reuc_get_bypath 128 | function Index:reuc_get_bypath(path) 129 | end 130 | 131 | --- object method. 132 | -- 133 | -- @param n Must be of type integer. 134 | -- @return IndexEntryUnmerged. 135 | -- @name Index:reuc_get_byindex 136 | function Index:reuc_get_byindex(n) 137 | end 138 | 139 | --- object method. 140 | -- 141 | --

Calls git_index_read_tree:

The current index contents will be replaced by the specified tree. 142 | -- @param tree tree to read. Must be of type Tree. 143 | -- @return true if no error. 144 | -- @return Error string. 145 | -- @name Index:read_tree 146 | function Index:read_tree(tree) 147 | end 148 | 149 | -------------------------------------------------------------------------------- /docs/git2/IndexEntry.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "IndexEntry". 6 | -- 7 | module("IndexEntry") 8 | 9 | --- Create a new IndexEntry object. 10 | -- 11 | -- @return IndexEntry. 12 | -- @name IndexEntry.new 13 | function IndexEntry.new() 14 | end 15 | 16 | --- object method. 17 | -- 18 | --

Calls git_index_entry_stage:

This entry is calculated from the entrie's flag 19 | -- attribute like this:

(entry->flags & GIT_IDXENTRY_STAGEMASK) >> GIT_IDXENTRY_STAGESHIFT

@returns the stage number 20 | -- @return integer. 21 | -- @name IndexEntry:stage 22 | function IndexEntry:stage() 23 | end 24 | 25 | --- object method. 26 | -- 27 | -- @return integer. 28 | -- @return integer. 29 | -- @name IndexEntry:ctime 30 | function IndexEntry:ctime() 31 | end 32 | 33 | --- object method. 34 | -- 35 | -- @param secs Must be of type integer. 36 | -- @param nanosecs Must be of type integer. 37 | -- @name IndexEntry:set_ctime 38 | function IndexEntry:set_ctime(secs, nanosecs) 39 | end 40 | 41 | --- object method. 42 | -- 43 | -- @return integer. 44 | -- @return integer. 45 | -- @name IndexEntry:mtime 46 | function IndexEntry:mtime() 47 | end 48 | 49 | --- object method. 50 | -- 51 | -- @param secs Must be of type integer. 52 | -- @param nanosecs Must be of type integer. 53 | -- @name IndexEntry:set_mtime 54 | function IndexEntry:set_mtime(secs, nanosecs) 55 | end 56 | 57 | --- object method. 58 | -- 59 | -- @return string. 60 | -- @name IndexEntry:path 61 | function IndexEntry:path() 62 | end 63 | 64 | --- object method. 65 | -- 66 | -- @param val Must be of type string. 67 | -- @name IndexEntry:set_path 68 | function IndexEntry:set_path(val) 69 | end 70 | 71 | --- object method. 72 | -- 73 | -- @return integer. 74 | -- @name IndexEntry:dev 75 | function IndexEntry:dev() 76 | end 77 | 78 | --- object method. 79 | -- 80 | -- @return integer. 81 | -- @name IndexEntry:ino 82 | function IndexEntry:ino() 83 | end 84 | 85 | --- object method. 86 | -- 87 | -- @return integer. 88 | -- @name IndexEntry:mode 89 | function IndexEntry:mode() 90 | end 91 | 92 | --- object method. 93 | -- 94 | -- @return integer. 95 | -- @name IndexEntry:uid 96 | function IndexEntry:uid() 97 | end 98 | 99 | --- object method. 100 | -- 101 | -- @return integer. 102 | -- @name IndexEntry:gid 103 | function IndexEntry:gid() 104 | end 105 | 106 | --- object method. 107 | -- 108 | -- @return integer. 109 | -- @name IndexEntry:file_size 110 | function IndexEntry:file_size() 111 | end 112 | 113 | --- object method. 114 | -- 115 | -- @return OID. 116 | -- @name IndexEntry:id 117 | function IndexEntry:id() 118 | end 119 | 120 | --- object method. 121 | -- 122 | -- @return integer. 123 | -- @name IndexEntry:flags 124 | function IndexEntry:flags() 125 | end 126 | 127 | --- object method. 128 | -- 129 | -- @return integer. 130 | -- @name IndexEntry:flags_extended 131 | function IndexEntry:flags_extended() 132 | end 133 | 134 | -------------------------------------------------------------------------------- /docs/git2/IndexEntryUnmerged.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "IndexEntryUnmerged". 6 | -- 7 | module("IndexEntryUnmerged") 8 | 9 | --- object method. 10 | -- 11 | -- @param idx Must be of type integer. 12 | -- @return integer. 13 | -- @name IndexEntryUnmerged:mode 14 | function IndexEntryUnmerged:mode(idx) 15 | end 16 | 17 | --- object method. 18 | -- 19 | -- @param idx Must be of type integer. 20 | -- @return OID. 21 | -- @name IndexEntryUnmerged:oid 22 | function IndexEntryUnmerged:oid(idx) 23 | end 24 | 25 | --- object method. 26 | -- 27 | -- @return string. 28 | -- @name IndexEntryUnmerged:path 29 | function IndexEntryUnmerged:path() 30 | end 31 | 32 | -------------------------------------------------------------------------------- /docs/git2/ODB.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "ODB". 6 | -- 7 | module("ODB") 8 | 9 | --- Create a new ODB object. 10 | -- 11 | --

Calls git_odb_new:

Before the ODB can be used for read/writing, a custom database 12 | -- backend must be manually added using `git_odb_add_backend()` 13 | -- @return ODB or nil on error. 14 | -- @return Error string. 15 | -- @name ODB.new 16 | function ODB.new() 17 | end 18 | 19 | --- Create a new ODB object. 20 | -- 21 | --

Calls git_odb_open:

- git_odb_backend_loose: read and write loose object files 22 | -- from disk, assuming `objects_dir` as the Objects folder

- git_odb_backend_pack: read objects from packfiles, 23 | -- assuming `objects_dir` as the Objects folder which 24 | -- contains a 'pack/' folder with the corresponding data 25 | -- @param object_dir Must be of type string. 26 | -- @return ODB or nil on error. 27 | -- @return Error string. 28 | -- @name ODB.open 29 | function ODB.open(object_dir) 30 | end 31 | 32 | --- Destroy this object (will be called by Garbage Collector). 33 | -- 34 | --

Calls git_odb_free:

35 | -- @name ODB:free 36 | function ODB:free() 37 | end 38 | 39 | --- object method. 40 | -- 41 | -- @param backend Must be of type ODBBackend. 42 | -- @param priority Must be of type integer. 43 | -- @return true if no error. 44 | -- @return Error string. 45 | -- @name ODB:add_backend 46 | function ODB:add_backend(backend, priority) 47 | end 48 | 49 | --- object method. 50 | -- 51 | -- @param backend Must be of type ODBBackend. 52 | -- @param priority Must be of type integer. 53 | -- @return true if no error. 54 | -- @return Error string. 55 | -- @name ODB:add_alternate 56 | function ODB:add_alternate(backend, priority) 57 | end 58 | 59 | --- object method. 60 | -- 61 | --

Calls git_odb_read:

This method queries all available ODB backends 62 | -- trying to read the given OID.

The returned object is reference counted and 63 | -- internally cached, so it should be closed 64 | -- by the user once it's no longer in use.

@return 65 | -- - 0 if the object was read; 66 | -- - GIT_ENOTFOUND if the object is not in the database. 67 | -- @param id identity of the object to read.. Must be of type OID. 68 | -- @return OdbObject or nil on error. 69 | -- @return Error string. 70 | -- @name ODB:read 71 | function ODB:read(id) 72 | end 73 | 74 | --- object method. 75 | -- 76 | --

Calls git_odb_read_prefix:

This method queries all available ODB backends 77 | -- trying to match the 'len' first hexadecimal 78 | -- characters of the 'short_id'. 79 | -- The remaining (GIT_OID_HEXSZ-len)*4 bits of 80 | -- 'short_id' must be 0s. 81 | -- 'len' must be at least GIT_OID_MINPREFIXLEN, 82 | -- and the prefix must be long enough to identify 83 | -- a unique object in all the backends; the 84 | -- method will fail otherwise.

The returned object is reference counted and 85 | -- internally cached, so it should be closed 86 | -- by the user once it's no longer in use. 87 | -- @param short_id a prefix of the id of the object to read.. Must be of type OID. 88 | -- @param len the length of the prefix. Must be of type integer. 89 | -- @return OdbObject or nil on error. 90 | -- @return Error string. 91 | -- @name ODB:read_prefix 92 | function ODB:read_prefix(short_id, len) 93 | end 94 | 95 | --- object method. 96 | -- 97 | --

Calls git_odb_read_header:

The header includes the length and the type of an object.

Note that most backends do not support reading only the header 98 | -- of an object, so the whole object will be read and then the 99 | -- header will be returned.

@return 100 | -- - 0 if the object was read; 101 | -- - GIT_ENOTFOUND if the object is not in the database. 102 | -- @param id identity of the object to read.. Must be of type OID. 103 | -- @return integer or nil on error. 104 | -- @return string or nil on error. 105 | -- @return Error string. 106 | -- @name ODB:read_header 107 | function ODB:read_header(id) 108 | end 109 | 110 | --- object method. 111 | -- 112 | --

Calls git_odb_exists:

@return 113 | -- - 1, if the object was found 114 | -- - 0, otherwise 115 | -- @param id the object to search for.. Must be of type OID. 116 | -- @return true if no error. 117 | -- @return Error string. 118 | -- @name ODB:exists 119 | function ODB:exists(id) 120 | end 121 | 122 | --- object method. 123 | -- 124 | --

Calls git_odb_write:

This method writes a full object straight into the ODB. 125 | -- For most cases, it is preferred to write objects through a write 126 | -- stream, which is both faster and less memory intensive, specially 127 | -- for big objects.

This method is provided for compatibility with custom backends 128 | -- which are not able to support streaming writes 129 | -- @param data buffer with the data to storr. Must be of type string. 130 | -- @param type type of the data to store. Must be of type string. 131 | -- @return OID or nil on error. 132 | -- @return Error string. 133 | -- @name ODB:write 134 | function ODB:write(data, type) 135 | end 136 | 137 | --- module function. 138 | -- 139 | --

Calls git_odb_hash:

The resulting SHA-1 OID will the itentifier for the data 140 | -- buffer as if the data buffer it were to written to the ODB. 141 | -- @param data data to hash. Must be of type string. 142 | -- @param otype Must be of type integer. 143 | -- @return OID or nil on error. 144 | -- @return Error string. 145 | -- @name ODB.hash 146 | function ODB.hash(data, otype) 147 | end 148 | 149 | --- module function. 150 | -- 151 | --

Calls git_odb_hashfile:

152 | -- @param path file to read and determine object id for. Must be of type string. 153 | -- @param otype Must be of type integer. 154 | -- @return OID or nil on error. 155 | -- @return Error string. 156 | -- @name ODB.hashfile 157 | function ODB.hashfile(path, otype) 158 | end 159 | 160 | -------------------------------------------------------------------------------- /docs/git2/ODBBackend.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "ODBBackend". 6 | -- 7 | module("ODBBackend") 8 | 9 | --- Create a new ODBBackend object. 10 | -- 11 | -- @return ODBBackend. 12 | -- @name ODBBackend.new 13 | function ODBBackend.new() 14 | end 15 | 16 | -------------------------------------------------------------------------------- /docs/git2/OID.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "OID". 6 | -- 7 | module("OID") 8 | 9 | --- Create a new OID object. 10 | -- 11 | --

Calls git_oid_fromstrn:

If N is odd, N-1 characters will be parsed instead. 12 | -- The remaining space in the git_oid will be set to zero. 13 | -- @param str input hex string of at least size `length`. Must be of type string. 14 | -- @return OID or nil on error. 15 | -- @return Error string. 16 | -- @name OID.hex 17 | function OID.hex(str) 18 | end 19 | 20 | --- Create a new OID object. 21 | -- 22 | --

Calls git_oid_fromraw:

23 | -- @param raw the raw input bytes to be copied.. Must be of type string. 24 | -- @return OID. 25 | -- @name OID.raw 26 | function OID.raw(raw) 27 | end 28 | 29 | --- object method. 30 | -- 31 | -- @return string. 32 | -- @name OID:pathfmt 33 | function OID:pathfmt() 34 | end 35 | 36 | --- object method. 37 | -- 38 | -- @return string. 39 | -- @name OID:fmt 40 | function OID:fmt() 41 | end 42 | 43 | --- object meta method. 44 | -- 45 | -- @return string. 46 | -- @name OID_mt:__tostring 47 | function OID_mt:__tostring() 48 | end 49 | 50 | --- object meta method. 51 | -- 52 | --

Calls git_oid_cmp:

53 | -- @param id Must be of type OID. 54 | -- @return integer. 55 | -- @name OID_mt:__eq 56 | function OID_mt:__eq(id) 57 | end 58 | 59 | -------------------------------------------------------------------------------- /docs/git2/OID_Shorten.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "OID_Shorten". 6 | -- 7 | module("OID_Shorten") 8 | 9 | --- Create a new OID_Shorten object. 10 | -- 11 | --

Calls git_oid_shorten_new:

The OID shortener is used to process a list of OIDs 12 | -- in text form and return the shortest length that would 13 | -- uniquely identify all of them.

E.g. look at the result of `git log --abbrev`. 14 | -- @param min_length The minimal length for all identifiers, which will be used even if shorter OIDs would still be unique.. Must be of type integer. 15 | -- @return OID_Shorten. 16 | -- @name OID_Shorten.new 17 | function OID_Shorten.new(min_length) 18 | end 19 | 20 | --- object method. 21 | -- 22 | --

Calls git_oid_shorten_add:

The OID is expected to be a 40-char hexadecimal string. 23 | -- The OID is owned by the user and will not be modified 24 | -- or freed.

For performance reasons, there is a hard-limit of how many 25 | -- OIDs can be added to a single set (around ~22000, assuming 26 | -- a mostly randomized distribution), which should be enough 27 | -- for any kind of program, and keeps the algorithm fast and 28 | -- memory-efficient.

Attempting to add more than those OIDs will result in a 29 | -- GIT_ENOMEM error 30 | -- @param text_oid an OID in text form. Must be of type string. 31 | -- @return true if no error. 32 | -- @return Error string. 33 | -- @name OID_Shorten:add 34 | function OID_Shorten:add(text_oid) 35 | end 36 | 37 | -------------------------------------------------------------------------------- /docs/git2/Object.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Object". 6 | -- 7 | module("Object") 8 | 9 | --- Destroy this object (will be called by Garbage Collector). 10 | -- 11 | --

Calls git_object_free:

This method instructs the library to close an existing 12 | -- object; note that git_objects are owned and cached by the repository 13 | -- so the object may or may not be freed after this library call, 14 | -- depending on how agressive is the caching mechanism used 15 | -- by the repository.

IMPORTANT: 16 | -- It *is* necessary to call this method when you stop using 17 | -- an object. Failure to do so will cause a memory leak. 18 | -- @name Object:free 19 | function Object:free() 20 | end 21 | 22 | --- object method. 23 | -- 24 | --

Calls git_object_id:

25 | -- @return OID. 26 | -- @name Object:id 27 | function Object:id() 28 | end 29 | 30 | --- object method. 31 | -- 32 | --

Calls git_object_type:

33 | -- @return string. 34 | -- @name Object:type 35 | function Object:type() 36 | end 37 | 38 | --- object method. 39 | -- 40 | --

Calls git_object_owner:

Freeing or calling `git_repository_close` on the 41 | -- returned pointer will invalidate the actual object.

Any other operation may be run on the repository without 42 | -- affecting the object. 43 | -- @return Repository. 44 | -- @name Object:owner 45 | function Object:owner() 46 | end 47 | 48 | --- module function. 49 | -- 50 | -- @param otype Must be of type integer. 51 | -- @return string. 52 | -- @name Object.type2string 53 | function Object.type2string(otype) 54 | end 55 | 56 | --- module function. 57 | -- 58 | -- @param str Must be of type string. 59 | -- @return integer. 60 | -- @name Object.string2type 61 | function Object.string2type(str) 62 | end 63 | 64 | -------------------------------------------------------------------------------- /docs/git2/OdbObject.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "OdbObject". 6 | -- 7 | module("OdbObject") 8 | 9 | --- Destroy this object (will be called by Garbage Collector). 10 | -- 11 | --

Calls git_odb_object_free:

This method must always be called once a `git_odb_object` is no 12 | -- longer needed, otherwise memory will leak. 13 | -- @name OdbObject:free 14 | function OdbObject:free() 15 | end 16 | 17 | --- object method. 18 | -- 19 | --

Calls git_odb_object_id:

This is the OID from which the object was read from 20 | -- @return OID. 21 | -- @name OdbObject:id 22 | function OdbObject:id() 23 | end 24 | 25 | --- object method. 26 | -- 27 | --

Calls git_odb_object_data:

This is the uncompressed, raw data as read from the ODB, 28 | -- without the leading header.

This pointer is owned by the object and shall not be free'd. 29 | --

Calls git_odb_object_size:

This is the real size of the `data` buffer, not the 30 | -- actual size of the object. 31 | -- @return string. 32 | -- @name OdbObject:data 33 | function OdbObject:data() 34 | end 35 | 36 | --- object method. 37 | -- 38 | --

Calls git_odb_object_size:

This is the real size of the `data` buffer, not the 39 | -- actual size of the object. 40 | -- @return integer. 41 | -- @name OdbObject:size 42 | function OdbObject:size() 43 | end 44 | 45 | --- object method. 46 | -- 47 | --

Calls git_odb_object_type:

48 | -- @return string. 49 | -- @name OdbObject:type 50 | function OdbObject:type() 51 | end 52 | 53 | -------------------------------------------------------------------------------- /docs/git2/Reference.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Reference". 6 | -- 7 | module("Reference") 8 | 9 | --- Create a new Reference object. 10 | -- 11 | --

Calls git_reference_lookup:

The generated reference must be freed by the user. 12 | -- @param repo the repository to look up the reference. Must be of type Repository. 13 | -- @param name the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...). Must be of type string. 14 | -- @return Reference or nil on error. 15 | -- @return Error string. 16 | -- @name Reference.lookup 17 | function Reference.lookup(repo, name) 18 | end 19 | 20 | --- object method. 21 | -- 22 | --

Calls git_reference_target:

Only available if the reference is symbolic 23 | -- @return OID. 24 | -- @name Reference:target 25 | function Reference:target() 26 | end 27 | 28 | --- object method. 29 | -- 30 | --

Calls git_reference_set_target:

The reference must be a symbolic reference, otherwise 31 | -- this method will fail.

The reference will be automatically updated in 32 | -- memory and on disk. 33 | -- @param oid Must be of type OID. 34 | -- @param log_message Must be of type string. 35 | -- @return Reference or nil on error. 36 | -- @return Error string. 37 | -- @name Reference:set_target 38 | function Reference:set_target(oid, log_message) 39 | end 40 | 41 | --- object method. 42 | -- 43 | --

Calls git_reference_type:

Either direct (GIT_REF_OID) or symbolic (GIT_REF_SYMBOLIC) 44 | -- @return integer. 45 | -- @name Reference:type 46 | function Reference:type() 47 | end 48 | 49 | --- object method. 50 | -- 51 | --

Calls git_reference_name:

52 | -- @return string. 53 | -- @name Reference:name 54 | function Reference:name() 55 | end 56 | 57 | --- object method. 58 | -- 59 | --

Calls git_reference_resolve:

Thie method iteratively peels a symbolic reference 60 | -- until it resolves to a direct reference to an OID.

The peeled reference is returned in the `resolved_ref` 61 | -- argument, and must be freed manually once it's no longer 62 | -- needed.

If a direct reference is passed as an argument, 63 | -- a copy of that reference is returned. This copy must 64 | -- be manually freed too. 65 | -- @return Reference or nil on error. 66 | -- @return Error string. 67 | -- @name Reference:resolve 68 | function Reference:resolve() 69 | end 70 | 71 | --- object method. 72 | -- 73 | --

Calls git_reference_owner:

74 | -- @return Repository. 75 | -- @name Reference:owner 76 | function Reference:owner() 77 | end 78 | 79 | --- object method. 80 | -- 81 | --

Calls git_reference_rename:

This method works for both direct and symbolic references. 82 | -- The new name will be checked for validity and may be 83 | -- modified into a normalized form.

The given git_reference will be updated in place.

The reference will be immediately renamed in-memory 84 | -- and on disk.

If the `force` flag is not enabled, and there's already 85 | -- a reference with the given name, the renaming will fail.

IMPORTANT: 86 | -- The user needs to write a proper reflog entry if the 87 | -- reflog is enabled for the repository. We only rename 88 | -- the reflog if it exists. 89 | -- @param new_name The new name for the reference. Must be of type string. 90 | -- @param force Overwrite an existing reference. Must be of type integer. 91 | -- @param log_message Must be of type string. 92 | -- @return Reference or nil on error. 93 | -- @return Error string. 94 | -- @name Reference:rename 95 | function Reference:rename(new_name, force, log_message) 96 | end 97 | 98 | --- object method. 99 | -- 100 | --

Calls git_reference_delete:

This method works for both direct and symbolic references.

The reference will be immediately removed on disk and from 101 | -- memory. The given reference pointer will no longer be valid. 102 | -- @return true if no error. 103 | -- @return Error string. 104 | -- @name Reference:delete 105 | function Reference:delete() 106 | end 107 | 108 | --- module function. 109 | -- 110 | -- @param repo Must be of type Repository. 111 | -- @return StrArray or nil on error. 112 | -- @return Error string. 113 | -- @name Reference.list 114 | function Reference.list(repo) 115 | end 116 | 117 | -------------------------------------------------------------------------------- /docs/git2/RevWalk.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "RevWalk". 6 | -- 7 | module("RevWalk") 8 | 9 | --- Create a new RevWalk object. 10 | -- 11 | --

Calls git_revwalk_new:

This revision walker uses a custom memory pool and an internal 12 | -- commit cache, so it is relatively expensive to allocate.

For maximum performance, this revision walker should be 13 | -- reused for different walks.

This revision walker is *not* thread safe: it may only be 14 | -- used to walk a repository on a single thread; however, 15 | -- it is possible to have several revision walkers in 16 | -- several different threads walking the same repository. 17 | -- @param repo the repo to walk through. Must be of type Repository. 18 | -- @return RevWalk or nil on error. 19 | -- @return Error string. 20 | -- @name RevWalk.new 21 | function RevWalk.new(repo) 22 | end 23 | 24 | --- Destroy this object (will be called by Garbage Collector). 25 | -- 26 | --

Calls git_revwalk_free:

27 | -- @name RevWalk:close 28 | function RevWalk:close() 29 | end 30 | 31 | --- object method. 32 | -- 33 | --

Calls git_revwalk_reset:

This will clear all the pushed and hidden commits, and 34 | -- leave the walker in a blank state (just like at 35 | -- creation) ready to receive new commit pushes and 36 | -- start a new walk.

The revision walk is automatically reset when a walk 37 | -- is over. 38 | -- @name RevWalk:reset 39 | function RevWalk:reset() 40 | end 41 | 42 | --- object method. 43 | -- 44 | --

Calls git_revwalk_push:

The given OID must belong to a commit on the walked 45 | -- repository.

The given commit will be used as one of the roots 46 | -- when starting the revision walk. At least one commit 47 | -- must be pushed the repository before a walk can 48 | -- be started. 49 | -- @param id Must be of type OID. 50 | -- @return true if no error. 51 | -- @return Error string. 52 | -- @name RevWalk:push 53 | function RevWalk:push(id) 54 | end 55 | 56 | --- object method. 57 | -- 58 | --

Calls git_revwalk_hide:

The given OID must belong to a commit on the walked 59 | -- repository.

The resolved commit and all its parents will be hidden from the 60 | -- output on the revision walk. 61 | -- @param id Must be of type OID. 62 | -- @return true if no error. 63 | -- @return Error string. 64 | -- @name RevWalk:hide 65 | function RevWalk:hide(id) 66 | end 67 | 68 | --- object method. 69 | -- 70 | --

Calls git_revwalk_next:

The initial call to this method is *not* blocking when 71 | -- iterating through a repo with a time-sorting mode.

Iterating with Topological or inverted modes makes the initial 72 | -- call blocking to preprocess the commit list, but this block should be 73 | -- mostly unnoticeable on most repositories (topological preprocessing 74 | -- times at 0.3s on the git.git repo).

The revision walker is reset when the walk is over. 75 | -- @return OID or nil on error. 76 | -- @return Error string. 77 | -- @name RevWalk:next 78 | function RevWalk:next() 79 | end 80 | 81 | --- object method. 82 | -- 83 | --

Calls git_revwalk_sorting:

Changing the sorting mode resets the walker. 84 | -- @param sort_mode combination of GIT_SORT_XXX flags. Must be of type integer. 85 | -- @name RevWalk:sorting 86 | function RevWalk:sorting(sort_mode) 87 | end 88 | 89 | --- object method. 90 | -- 91 | --

Calls git_revwalk_repository:

92 | -- @return Repository. 93 | -- @name RevWalk:repository 94 | function RevWalk:repository() 95 | end 96 | 97 | -------------------------------------------------------------------------------- /docs/git2/Signature.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Signature". 6 | -- 7 | module("Signature") 8 | 9 | --- Create a new Signature object. 10 | -- 11 | --

Calls git_signature_new:

12 | -- @param name name of the person. Must be of type string. 13 | -- @param email email of the person. Must be of type string. 14 | -- @param time time when the action happened. Must be of type integer. 15 | -- @param offset timezone offset in minutes for the time. Must be of type integer. 16 | -- @return Signature or nil on error. 17 | -- @return Error string. 18 | -- @name Signature.new 19 | function Signature.new(name, email, time, offset) 20 | end 21 | 22 | --- Create a new Signature object. 23 | -- 24 | --

Calls git_signature_now:

25 | -- @param name name of the person. Must be of type string. 26 | -- @param email email of the person. Must be of type string. 27 | -- @return Signature or nil on error. 28 | -- @return Error string. 29 | -- @name Signature.now 30 | function Signature.now(name, email) 31 | end 32 | 33 | --- object method. 34 | -- 35 | -- @return string. 36 | -- @name Signature:name 37 | function Signature:name() 38 | end 39 | 40 | --- object method. 41 | -- 42 | -- @return string. 43 | -- @name Signature:email 44 | function Signature:email() 45 | end 46 | 47 | --- object method. 48 | -- 49 | -- @return integer. 50 | -- @return integer. 51 | -- @name Signature:when 52 | function Signature:when() 53 | end 54 | 55 | -------------------------------------------------------------------------------- /docs/git2/StrArray.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "StrArray". 6 | -- 7 | module("StrArray") 8 | 9 | --- Create a new StrArray object. 10 | -- 11 | -- @return StrArray. 12 | -- @name StrArray.new 13 | function StrArray.new() 14 | end 15 | 16 | --- Destroy this object (will be called by Garbage Collector). 17 | -- 18 | -- @name StrArray:free 19 | function StrArray:free() 20 | end 21 | 22 | --- object method. 23 | -- 24 | -- @param n Must be of type integer. 25 | -- @return string. 26 | -- @name StrArray:str 27 | function StrArray:str(n) 28 | end 29 | 30 | --- object method. 31 | -- 32 | -- @return nil. 33 | -- @name StrArray:get_array 34 | function StrArray:get_array() 35 | end 36 | 37 | --- object method. 38 | -- 39 | -- @return integer. 40 | -- @name StrArray:count 41 | function StrArray:count() 42 | end 43 | 44 | -------------------------------------------------------------------------------- /docs/git2/Tag.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Tag". 6 | -- 7 | -- Extends Object
8 | module("Tag") 9 | 10 | --- Create a new Tag object. 11 | -- 12 | --

Calls git_tag_lookup:

13 | -- @param repo the repo to use when locating the tag.. Must be of type Repository. 14 | -- @param id identity of the tag to locate.. Must be of type OID. 15 | -- @return Tag or nil on error. 16 | -- @return Error string. 17 | -- @name Tag.lookup 18 | function Tag.lookup(repo, id) 19 | end 20 | 21 | --- object method. 22 | -- 23 | --

Calls git_tag_target:

This method performs a repository lookup for the 24 | -- given object and returns it 25 | -- @return Object or nil on error. 26 | -- @return Error string. 27 | -- @name Tag:target 28 | function Tag:target() 29 | end 30 | 31 | --- object method. 32 | -- 33 | --

Calls git_tag_name:

34 | -- @return string. 35 | -- @name Tag:name 36 | function Tag:name() 37 | end 38 | 39 | --- object method. 40 | -- 41 | --

Calls git_tag_tagger:

42 | -- @return Signature. 43 | -- @name Tag:tagger 44 | function Tag:tagger() 45 | end 46 | 47 | --- object method. 48 | -- 49 | --

Calls git_tag_message:

50 | -- @return string. 51 | -- @name Tag:message 52 | function Tag:message() 53 | end 54 | 55 | --- Destroy this object (will be called by Garbage Collector). 56 | -- 57 | --

Calls git_object_free:

This method instructs the library to close an existing 58 | -- object; note that git_objects are owned and cached by the repository 59 | -- so the object may or may not be freed after this library call, 60 | -- depending on how agressive is the caching mechanism used 61 | -- by the repository.

IMPORTANT: 62 | -- It *is* necessary to call this method when you stop using 63 | -- an object. Failure to do so will cause a memory leak. 64 | -- @name Object:free 65 | function Object:free() 66 | end 67 | 68 | --- object method. 69 | -- 70 | --

Calls git_object_id:

71 | -- @return OID. 72 | -- @name Object:id 73 | function Object:id() 74 | end 75 | 76 | --- object method. 77 | -- 78 | --

Calls git_object_type:

79 | -- @return string. 80 | -- @name Object:type 81 | function Object:type() 82 | end 83 | 84 | --- object method. 85 | -- 86 | --

Calls git_object_owner:

Freeing or calling `git_repository_close` on the 87 | -- returned pointer will invalidate the actual object.

Any other operation may be run on the repository without 88 | -- affecting the object. 89 | -- @return Repository. 90 | -- @name Object:owner 91 | function Object:owner() 92 | end 93 | 94 | -------------------------------------------------------------------------------- /docs/git2/Tree.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "Tree". 6 | -- 7 | -- Extends Object
8 | module("Tree") 9 | 10 | --- Create a new Tree object. 11 | -- 12 | --

Calls git_tree_lookup:

13 | -- @param repo the repo to use when locating the tree.. Must be of type Repository. 14 | -- @param id identity of the tree to locate.. Must be of type OID. 15 | -- @return Tree or nil on error. 16 | -- @return Error string. 17 | -- @name Tree.lookup 18 | function Tree.lookup(repo, id) 19 | end 20 | 21 | --- object method. 22 | -- 23 | --

Calls git_tree_entrycount:

24 | -- @return integer. 25 | -- @name Tree:entrycount 26 | function Tree:entrycount() 27 | end 28 | 29 | --- object method. 30 | -- 31 | --

Calls git_tree_entry_byname:

32 | -- @param filename the filename of the desired entry. Must be of type string. 33 | -- @return TreeEntry. 34 | -- @name Tree:entry_byname 35 | function Tree:entry_byname(filename) 36 | end 37 | 38 | --- object method. 39 | -- 40 | --

Calls git_tree_entry_byindex:

41 | -- @param index Must be of type integer. 42 | -- @return TreeEntry. 43 | -- @name Tree:entry_byindex 44 | function Tree:entry_byindex(index) 45 | end 46 | 47 | --- Destroy this object (will be called by Garbage Collector). 48 | -- 49 | --

Calls git_object_free:

This method instructs the library to close an existing 50 | -- object; note that git_objects are owned and cached by the repository 51 | -- so the object may or may not be freed after this library call, 52 | -- depending on how agressive is the caching mechanism used 53 | -- by the repository.

IMPORTANT: 54 | -- It *is* necessary to call this method when you stop using 55 | -- an object. Failure to do so will cause a memory leak. 56 | -- @name Object:free 57 | function Object:free() 58 | end 59 | 60 | --- object method. 61 | -- 62 | --

Calls git_object_id:

63 | -- @return OID. 64 | -- @name Object:id 65 | function Object:id() 66 | end 67 | 68 | --- object method. 69 | -- 70 | --

Calls git_object_type:

71 | -- @return string. 72 | -- @name Object:type 73 | function Object:type() 74 | end 75 | 76 | --- object method. 77 | -- 78 | --

Calls git_object_owner:

Freeing or calling `git_repository_close` on the 79 | -- returned pointer will invalidate the actual object.

Any other operation may be run on the repository without 80 | -- affecting the object. 81 | -- @return Repository. 82 | -- @name Object:owner 83 | function Object:owner() 84 | end 85 | 86 | -------------------------------------------------------------------------------- /docs/git2/TreeEntry.luadoc: -------------------------------------------------------------------------------- 1 | -- 2 | -- Warning: AUTOGENERATED DOCS. 3 | -- 4 | 5 | --- Class "TreeEntry". 6 | -- 7 | module("TreeEntry") 8 | 9 | --- object method. 10 | -- 11 | --

Calls git_tree_entry_name:

12 | -- @return string. 13 | -- @name TreeEntry:name 14 | function TreeEntry:name() 15 | end 16 | 17 | --- object method. 18 | -- 19 | -- @return integer. 20 | -- @name TreeEntry:filemode 21 | function TreeEntry:filemode() 22 | end 23 | 24 | --- object method. 25 | -- 26 | -- @return OID. 27 | -- @name TreeEntry:id 28 | function TreeEntry:id() 29 | end 30 | 31 | --- object method. 32 | -- 33 | --

Calls git_tree_entry_to_object:

@param object pointer to the converted object 34 | -- @param repo repository where to lookup the pointed object. Must be of type Repository. 35 | -- @return Object or nil on error. 36 | -- @return Error string. 37 | -- @name TreeEntry:object 38 | function TreeEntry:object(repo) 39 | end 40 | 41 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |

12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 133 | 134 |
135 | 136 | 137 | 138 |

Modules

139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 |
BlobClass "Blob".
CommitClass "Commit".
ConfigClass "Config".
IndexClass "Index".
IndexEntryClass "IndexEntry".
IndexEntryUnmergedClass "IndexEntryUnmerged".
ODBClass "ODB".
ODBBackendClass "ODBBackend".
OIDClass "OID".
OID_ShortenClass "OID_Shorten".
ObjectClass "Object".
OdbObjectClass "OdbObject".
ReferenceClass "Reference".
RepositoryClass "Repository".
RevWalkClass "RevWalk".
SignatureClass "Signature".
StrArrayClass "StrArray".
TagClass "Tag".
TreeClass "Tree".
TreeEntryClass "TreeEntry".
git2Module git2.
248 | 249 | 250 | 251 | 252 | 253 | 254 |
255 | 256 |
257 | 258 |
259 |

Valid XHTML 1.0!

260 |
261 | 262 |
263 | 264 | 265 | -------------------------------------------------------------------------------- /docs/luadoc.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin-left: 1em; 3 | margin-right: 1em; 4 | font-family: arial, helvetica, geneva, sans-serif; 5 | background-color:#ffffff; margin:0px; 6 | } 7 | 8 | code { 9 | font-family: "Andale Mono", monospace; 10 | } 11 | 12 | tt { 13 | font-family: "Andale Mono", monospace; 14 | } 15 | 16 | body, td, th { font-size: 11pt; } 17 | 18 | h1, h2, h3, h4 { margin-left: 0em; } 19 | 20 | textarea, pre, tt { font-size:10pt; } 21 | body, td, th { color:#000000; } 22 | small { font-size:0.85em; } 23 | h1 { font-size:1.5em; } 24 | h2 { font-size:1.25em; } 25 | h3 { font-size:1.15em; } 26 | h4 { font-size:1.06em; } 27 | 28 | a:link { font-weight:bold; color: #004080; text-decoration: none; } 29 | a:visited { font-weight:bold; color: #006699; text-decoration: none; } 30 | a:link:hover { text-decoration:underline; } 31 | hr { color:#cccccc } 32 | img { border-width: 0px; } 33 | 34 | 35 | h3 { padding-top: 1em; } 36 | 37 | p { margin-left: 1em; } 38 | 39 | p.name { 40 | font-family: "Andale Mono", monospace; 41 | padding-top: 1em; 42 | margin-left: 0em; 43 | } 44 | 45 | blockquote { margin-left: 3em; } 46 | 47 | pre.example { 48 | background-color: rgb(245, 245, 245); 49 | border-top-width: 1px; 50 | border-right-width: 1px; 51 | border-bottom-width: 1px; 52 | border-left-width: 1px; 53 | border-top-style: solid; 54 | border-right-style: solid; 55 | border-bottom-style: solid; 56 | border-left-style: solid; 57 | border-top-color: silver; 58 | border-right-color: silver; 59 | border-bottom-color: silver; 60 | border-left-color: silver; 61 | padding: 1em; 62 | margin-left: 1em; 63 | margin-right: 1em; 64 | font-family: "Andale Mono", monospace; 65 | font-size: smaller; 66 | } 67 | 68 | 69 | hr { 70 | margin-left: 0em; 71 | background: #00007f; 72 | border: 0px; 73 | height: 1px; 74 | } 75 | 76 | ul { list-style-type: disc; } 77 | 78 | table.index { border: 1px #00007f; } 79 | table.index td { text-align: left; vertical-align: top; } 80 | table.index ul { padding-top: 0em; margin-top: 0em; } 81 | 82 | table { 83 | border: 1px solid black; 84 | border-collapse: collapse; 85 | margin-left: auto; 86 | margin-right: auto; 87 | } 88 | th { 89 | border: 1px solid black; 90 | padding: 0.5em; 91 | } 92 | td { 93 | border: 1px solid black; 94 | padding: 0.5em; 95 | } 96 | div.header, div.footer { margin-left: 0em; } 97 | 98 | #container 99 | { 100 | margin-left: 1em; 101 | margin-right: 1em; 102 | background-color: #f0f0f0; 103 | } 104 | 105 | #product 106 | { 107 | text-align: center; 108 | border-bottom: 1px solid #cccccc; 109 | background-color: #ffffff; 110 | } 111 | 112 | #product big { 113 | font-size: 2em; 114 | } 115 | 116 | #product_logo 117 | { 118 | } 119 | 120 | #product_name 121 | { 122 | } 123 | 124 | #product_description 125 | { 126 | } 127 | 128 | #main 129 | { 130 | background-color: #f0f0f0; 131 | border-left: 2px solid #cccccc; 132 | } 133 | 134 | #navigation 135 | { 136 | float: left; 137 | width: 18em; 138 | margin: 0; 139 | vertical-align: top; 140 | background-color: #f0f0f0; 141 | overflow:visible; 142 | } 143 | 144 | #navigation h1 { 145 | background-color:#e7e7e7; 146 | font-size:1.1em; 147 | color:#000000; 148 | text-align:left; 149 | margin:0px; 150 | padding:0.2em; 151 | border-top:1px solid #dddddd; 152 | border-bottom:1px solid #dddddd; 153 | } 154 | 155 | #navigation ul 156 | { 157 | font-size:1em; 158 | list-style-type: none; 159 | padding: 0; 160 | margin: 1px; 161 | } 162 | 163 | #navigation li 164 | { 165 | text-indent: -1em; 166 | margin: 0em 0em 0em 0.5em; 167 | display: block; 168 | padding: 3px 0px 0px 12px; 169 | } 170 | 171 | #navigation li li a 172 | { 173 | padding: 0px 3px 0px -1em; 174 | } 175 | 176 | #content 177 | { 178 | margin-left: 18em; 179 | padding: 1em; 180 | border-left: 2px solid #cccccc; 181 | border-right: 2px solid #cccccc; 182 | background-color: #ffffff; 183 | } 184 | 185 | #about 186 | { 187 | clear: both; 188 | margin: 0; 189 | padding: 5px; 190 | border-top: 2px solid #cccccc; 191 | background-color: #ffffff; 192 | } 193 | 194 | @media print { 195 | body { 196 | font: 12pt "Times New Roman", "TimeNR", Times, serif; 197 | } 198 | a { font-weight:bold; color: #004080; text-decoration: underline; } 199 | 200 | #main { background-color: #ffffff; border-left: 0px; } 201 | #container { margin-left: 2%; margin-right: 2%; background-color: #ffffff; } 202 | 203 | #content { margin-left: 0px; padding: 1em; border-left: 0px; border-right: 0px; background-color: #ffffff; } 204 | 205 | #navigation { display: none; 206 | } 207 | pre.example { 208 | font-family: "Andale Mono", monospace; 209 | font-size: 10pt; 210 | page-break-inside: avoid; 211 | } 212 | } 213 | 214 | table.module_list td 215 | { 216 | border-width: 1px; 217 | padding: 3px; 218 | border-style: solid; 219 | border-color: #cccccc; 220 | } 221 | table.module_list td.name { background-color: #f0f0f0; } 222 | table.module_list td.summary { width: 100%; } 223 | 224 | table.file_list 225 | { 226 | border-width: 1px; 227 | border-style: solid; 228 | border-color: #cccccc; 229 | border-collapse: collapse; 230 | } 231 | table.file_list td 232 | { 233 | border-width: 1px; 234 | padding: 3px; 235 | border-style: solid; 236 | border-color: #cccccc; 237 | } 238 | table.file_list td.name { background-color: #f0f0f0; } 239 | table.file_list td.summary { width: 100%; } 240 | 241 | 242 | table.function_list 243 | { 244 | border-width: 1px; 245 | border-style: solid; 246 | border-color: #cccccc; 247 | border-collapse: collapse; 248 | } 249 | table.function_list td 250 | { 251 | border-width: 1px; 252 | padding: 3px; 253 | border-style: solid; 254 | border-color: #cccccc; 255 | } 256 | table.function_list td.name { background-color: #f0f0f0; } 257 | table.function_list td.summary { width: 100%; } 258 | 259 | 260 | table.table_list 261 | { 262 | border-width: 1px; 263 | border-style: solid; 264 | border-color: #cccccc; 265 | border-collapse: collapse; 266 | } 267 | table.table_list td 268 | { 269 | border-width: 1px; 270 | padding: 3px; 271 | border-style: solid; 272 | border-color: #cccccc; 273 | } 274 | table.table_list td.name { background-color: #f0f0f0; } 275 | table.table_list td.summary { width: 100%; } 276 | 277 | dl.function dt {border-top: 1px solid #ccc; padding-top: 1em;} 278 | dl.function dd {padding-bottom: 1em;} 279 | dl.function h3 {padding: 0; margin: 0; font-size: medium;} 280 | 281 | dl.table dt {border-top: 1px solid #ccc; padding-top: 1em;} 282 | dl.table dd {padding-bottom: 1em;} 283 | dl.table h3 {padding: 0; margin: 0; font-size: medium;} 284 | 285 | #TODO: make module_list, file_list, function_list, table_list inherit from a list 286 | 287 | -------------------------------------------------------------------------------- /docs/modules/IndexEntryUnmerged.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module IndexEntryUnmerged

135 | 136 |

Class "IndexEntryUnmerged".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 |
IndexEntryUnmerged:mode (idx)object method.
IndexEntryUnmerged:oid (idx)object method.
IndexEntryUnmerged:path ()object method.
161 | 162 | 163 | 164 | 165 | 166 | 167 |
168 |
169 | 170 | 171 | 172 |

Functions

173 |
174 | 175 | 176 | 177 |
IndexEntryUnmerged:mode (idx)
178 |
179 | object method. 180 | 181 | 182 |

Parameters

183 |
    184 | 185 |
  • 186 | idx: Must be of type integer. 187 |
  • 188 | 189 |
190 | 191 | 192 | 193 | 194 | 195 | 196 |

Return value:

197 | integer. 198 | 199 | 200 | 201 |
202 | 203 | 204 | 205 | 206 |
IndexEntryUnmerged:oid (idx)
207 |
208 | object method. 209 | 210 | 211 |

Parameters

212 |
    213 | 214 |
  • 215 | idx: Must be of type integer. 216 |
  • 217 | 218 |
219 | 220 | 221 | 222 | 223 | 224 | 225 |

Return value:

226 | OID. 227 | 228 | 229 | 230 |
231 | 232 | 233 | 234 | 235 |
IndexEntryUnmerged:path ()
236 |
237 | object method. 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 |

Return value:

246 | string. 247 | 248 | 249 | 250 |
251 | 252 | 253 |
254 | 255 | 256 | 257 | 258 | 259 | 260 |
261 | 262 |
263 | 264 |
265 |

Valid XHTML 1.0!

266 |
267 | 268 |
269 | 270 | 271 | -------------------------------------------------------------------------------- /docs/modules/ODBBackend.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module ODBBackend

135 | 136 |

Class "ODBBackend".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 |
ODBBackend.new ()Create a new ODBBackend object.
151 | 152 | 153 | 154 | 155 | 156 | 157 |
158 |
159 | 160 | 161 | 162 |

Functions

163 |
164 | 165 | 166 | 167 |
ODBBackend.new ()
168 |
169 | Create a new ODBBackend object. 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |

Return value:

178 | ODBBackend. 179 | 180 | 181 | 182 |
183 | 184 | 185 |
186 | 187 | 188 | 189 | 190 | 191 | 192 |
193 | 194 |
195 | 196 |
197 |

Valid XHTML 1.0!

198 |
199 | 200 |
201 | 202 | 203 | -------------------------------------------------------------------------------- /docs/modules/OID.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module OID

135 | 136 |

Class "OID".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |
OID.hex (str)Create a new OID object.
OID.raw (raw)Create a new OID object.
OID:fmt ()object method.
OID:pathfmt ()object method.
OID_mt:__eq (id)object meta method.
OID_mt:__tostring ()object meta method.
176 | 177 | 178 | 179 | 180 | 181 | 182 |
183 |
184 | 185 | 186 | 187 |

Functions

188 |
189 | 190 | 191 | 192 |
OID.hex (str)
193 |
194 | Create a new OID object.

Calls git_oid_fromstrn:

If N is odd, N-1 characters will be parsed instead. The remaining space in the git_oid will be set to zero. 195 | 196 | 197 |

Parameters

198 |
    199 | 200 |
  • 201 | str: input hex string of at least size `length`. Must be of type string. 202 |
  • 203 | 204 |
205 | 206 | 207 | 208 | 209 | 210 | 211 |

Return values:

212 |
    213 | 214 |
  1. OID or nil on error. 215 | 216 |
  2. Error string. 217 | 218 |
219 | 220 | 221 | 222 |
223 | 224 | 225 | 226 | 227 |
OID.raw (raw)
228 |
229 | Create a new OID object.

Calls git_oid_fromraw:

230 | 231 | 232 |

Parameters

233 |
    234 | 235 |
  • 236 | raw: the raw input bytes to be copied.. Must be of type string. 237 |
  • 238 | 239 |
240 | 241 | 242 | 243 | 244 | 245 | 246 |

Return value:

247 | OID. 248 | 249 | 250 | 251 |
252 | 253 | 254 | 255 | 256 |
OID:fmt ()
257 |
258 | object method. 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 |

Return value:

267 | string. 268 | 269 | 270 | 271 |
272 | 273 | 274 | 275 | 276 |
OID:pathfmt ()
277 |
278 | object method. 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 |

Return value:

287 | string. 288 | 289 | 290 | 291 |
292 | 293 | 294 | 295 | 296 |
OID_mt:__eq (id)
297 |
298 | object meta method.

Calls git_oid_cmp:

299 | 300 | 301 |

Parameters

302 |
    303 | 304 |
  • 305 | id: Must be of type OID. 306 |
  • 307 | 308 |
309 | 310 | 311 | 312 | 313 | 314 | 315 |

Return value:

316 | integer. 317 | 318 | 319 | 320 |
321 | 322 | 323 | 324 | 325 |
OID_mt:__tostring ()
326 |
327 | object meta method. 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 |

Return value:

336 | string. 337 | 338 | 339 | 340 |
341 | 342 | 343 |
344 | 345 | 346 | 347 | 348 | 349 | 350 |
351 | 352 |
353 | 354 |
355 |

Valid XHTML 1.0!

356 |
357 | 358 |
359 | 360 | 361 | -------------------------------------------------------------------------------- /docs/modules/OID_Shorten.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module OID_Shorten

135 | 136 |

Class "OID_Shorten".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 |
OID_Shorten.new (min_length)Create a new OID_Shorten object.
OID_Shorten:add (text_oid)object method.
156 | 157 | 158 | 159 | 160 | 161 | 162 |
163 |
164 | 165 | 166 | 167 |

Functions

168 |
169 | 170 | 171 | 172 |
OID_Shorten.new (min_length)
173 |
174 | Create a new OID_Shorten object.

Calls git_oid_shorten_new:

The OID shortener is used to process a list of OIDs in text form and return the shortest length that would uniquely identify all of them.

E.g. look at the result of `git log --abbrev`. 175 | 176 | 177 |

Parameters

178 |
    179 | 180 |
  • 181 | min_length: The minimal length for all identifiers, which will be used even if shorter OIDs would still be unique.. Must be of type integer. 182 |
  • 183 | 184 |
185 | 186 | 187 | 188 | 189 | 190 | 191 |

Return value:

192 | OID_Shorten. 193 | 194 | 195 | 196 |
197 | 198 | 199 | 200 | 201 |
OID_Shorten:add (text_oid)
202 |
203 | object method.

Calls git_oid_shorten_add:

The OID is expected to be a 40-char hexadecimal string. The OID is owned by the user and will not be modified or freed.

For performance reasons, there is a hard-limit of how many OIDs can be added to a single set (around ~22000, assuming a mostly randomized distribution), which should be enough for any kind of program, and keeps the algorithm fast and memory-efficient.

Attempting to add more than those OIDs will result in a GIT_ENOMEM error 204 | 205 | 206 |

Parameters

207 |
    208 | 209 |
  • 210 | text_oid: an OID in text form. Must be of type string. 211 |
  • 212 | 213 |
214 | 215 | 216 | 217 | 218 | 219 | 220 |

Return values:

221 |
    222 | 223 |
  1. true if no error. 224 | 225 |
  2. Error string. 226 | 227 |
228 | 229 | 230 | 231 |
232 | 233 | 234 |
235 | 236 | 237 | 238 | 239 | 240 | 241 |
242 | 243 |
244 | 245 |
246 |

Valid XHTML 1.0!

247 |
248 | 249 |
250 | 251 | 252 | -------------------------------------------------------------------------------- /docs/modules/Object.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module Object

135 | 136 |

Class "Object".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |
Object.string2type (str)module function.
Object.type2string (otype)module function.
Object:free ()Destroy this object (will be called by Garbage Collector).
Object:id ()object method.
Object:owner ()object method.
Object:type ()object method.
176 | 177 | 178 | 179 | 180 | 181 | 182 |
183 |
184 | 185 | 186 | 187 |

Functions

188 |
189 | 190 | 191 | 192 |
Object.string2type (str)
193 |
194 | module function. 195 | 196 | 197 |

Parameters

198 |
    199 | 200 |
  • 201 | str: Must be of type string. 202 |
  • 203 | 204 |
205 | 206 | 207 | 208 | 209 | 210 | 211 |

Return value:

212 | integer. 213 | 214 | 215 | 216 |
217 | 218 | 219 | 220 | 221 |
Object.type2string (otype)
222 |
223 | module function. 224 | 225 | 226 |

Parameters

227 |
    228 | 229 |
  • 230 | otype: Must be of type integer. 231 |
  • 232 | 233 |
234 | 235 | 236 | 237 | 238 | 239 | 240 |

Return value:

241 | string. 242 | 243 | 244 | 245 |
246 | 247 | 248 | 249 | 250 |
Object:free ()
251 |
252 | Destroy this object (will be called by Garbage Collector).

Calls git_object_free:

This method instructs the library to close an existing object; note that git_objects are owned and cached by the repository so the object may or may not be freed after this library call, depending on how agressive is the caching mechanism used by the repository.

IMPORTANT: It *is* necessary to call this method when you stop using an object. Failure to do so will cause a memory leak. 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 |

263 | 264 | 265 | 266 | 267 |
Object:id ()
268 |
269 | object method.

Calls git_object_id:

270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 |

Return value:

278 | OID. 279 | 280 | 281 | 282 |
283 | 284 | 285 | 286 | 287 |
Object:owner ()
288 |
289 | object method.

Calls git_object_owner:

Freeing or calling `git_repository_close` on the returned pointer will invalidate the actual object.

Any other operation may be run on the repository without affecting the object. 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 |

Return value:

298 | Repository. 299 | 300 | 301 | 302 |
303 | 304 | 305 | 306 | 307 |
Object:type ()
308 |
309 | object method.

Calls git_object_type:

310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 |

Return value:

318 | string. 319 | 320 | 321 | 322 |
323 | 324 | 325 |
326 | 327 | 328 | 329 | 330 | 331 | 332 |
333 | 334 |
335 | 336 |
337 |

Valid XHTML 1.0!

338 |
339 | 340 |
341 | 342 | 343 | -------------------------------------------------------------------------------- /docs/modules/OdbObject.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module OdbObject

135 | 136 |

Class "OdbObject".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 |
OdbObject:data ()object method.
OdbObject:free ()Destroy this object (will be called by Garbage Collector).
OdbObject:id ()object method.
OdbObject:size ()object method.
OdbObject:type ()object method.
171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 |
179 | 180 | 181 | 182 |

Functions

183 |
184 | 185 | 186 | 187 |
OdbObject:data ()
188 |
189 | object method.

Calls git_odb_object_data:

This is the uncompressed, raw data as read from the ODB, without the leading header.

This pointer is owned by the object and shall not be free'd.

Calls git_odb_object_size:

This is the real size of the `data` buffer, not the actual size of the object. 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 |

Return value:

198 | string. 199 | 200 | 201 | 202 |
203 | 204 | 205 | 206 | 207 |
OdbObject:free ()
208 |
209 | Destroy this object (will be called by Garbage Collector).

Calls git_odb_object_free:

This method must always be called once a `git_odb_object` is no longer needed, otherwise memory will leak. 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 |

220 | 221 | 222 | 223 | 224 |
OdbObject:id ()
225 |
226 | object method.

Calls git_odb_object_id:

This is the OID from which the object was read from 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 |

Return value:

235 | OID. 236 | 237 | 238 | 239 |
240 | 241 | 242 | 243 | 244 |
OdbObject:size ()
245 |
246 | object method.

Calls git_odb_object_size:

This is the real size of the `data` buffer, not the actual size of the object. 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 |

Return value:

255 | integer. 256 | 257 | 258 | 259 |
260 | 261 | 262 | 263 | 264 |
OdbObject:type ()
265 |
266 | object method.

Calls git_odb_object_type:

267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 |

Return value:

275 | string. 276 | 277 | 278 | 279 |
280 | 281 | 282 |
283 | 284 | 285 | 286 | 287 | 288 | 289 |
290 | 291 |
292 | 293 |
294 |

Valid XHTML 1.0!

295 |
296 | 297 |
298 | 299 | 300 | -------------------------------------------------------------------------------- /docs/modules/Signature.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module Signature

135 | 136 |

Class "Signature".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 |
Signature.new (name, email, time, offset)Create a new Signature object.
Signature.now (name, email)Create a new Signature object.
Signature:email ()object method.
Signature:name ()object method.
Signature:when ()object method.
171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 |
179 | 180 | 181 | 182 |

Functions

183 |
184 | 185 | 186 | 187 |
Signature.new (name, email, time, offset)
188 |
189 | Create a new Signature object.

Calls git_signature_new:

190 | 191 | 192 |

Parameters

193 |
    194 | 195 |
  • 196 | name: name of the person. Must be of type string. 197 |
  • 198 | 199 |
  • 200 | email: email of the person. Must be of type string. 201 |
  • 202 | 203 |
  • 204 | time: time when the action happened. Must be of type integer. 205 |
  • 206 | 207 |
  • 208 | offset: timezone offset in minutes for the time. Must be of type integer. 209 |
  • 210 | 211 |
212 | 213 | 214 | 215 | 216 | 217 | 218 |

Return values:

219 |
    220 | 221 |
  1. Signature or nil on error. 222 | 223 |
  2. Error string. 224 | 225 |
226 | 227 | 228 | 229 |
230 | 231 | 232 | 233 | 234 |
Signature.now (name, email)
235 |
236 | Create a new Signature object.

Calls git_signature_now:

237 | 238 | 239 |

Parameters

240 |
    241 | 242 |
  • 243 | name: name of the person. Must be of type string. 244 |
  • 245 | 246 |
  • 247 | email: email of the person. Must be of type string. 248 |
  • 249 | 250 |
251 | 252 | 253 | 254 | 255 | 256 | 257 |

Return values:

258 |
    259 | 260 |
  1. Signature or nil on error. 261 | 262 |
  2. Error string. 263 | 264 |
265 | 266 | 267 | 268 |
269 | 270 | 271 | 272 | 273 |
Signature:email ()
274 |
275 | object method. 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 |

Return value:

284 | string. 285 | 286 | 287 | 288 |
289 | 290 | 291 | 292 | 293 |
Signature:name ()
294 |
295 | object method. 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 |

Return value:

304 | string. 305 | 306 | 307 | 308 |
309 | 310 | 311 | 312 | 313 |
Signature:when ()
314 |
315 | object method. 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 |

Return values:

324 |
    325 | 326 |
  1. integer. 327 | 328 |
  2. integer. 329 | 330 |
331 | 332 | 333 | 334 |
335 | 336 | 337 |
338 | 339 | 340 | 341 | 342 | 343 | 344 |
345 | 346 |
347 | 348 |
349 |

Valid XHTML 1.0!

350 |
351 | 352 |
353 | 354 | 355 | -------------------------------------------------------------------------------- /docs/modules/StrArray.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module StrArray

135 | 136 |

Class "StrArray".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 |
StrArray.new ()Create a new StrArray object.
StrArray:count ()object method.
StrArray:free ()Destroy this object (will be called by Garbage Collector).
StrArray:get_array ()object method.
StrArray:str (n)object method.
171 | 172 | 173 | 174 | 175 | 176 | 177 |
178 |
179 | 180 | 181 | 182 |

Functions

183 |
184 | 185 | 186 | 187 |
StrArray.new ()
188 |
189 | Create a new StrArray object. 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 |

Return value:

198 | StrArray. 199 | 200 | 201 | 202 |
203 | 204 | 205 | 206 | 207 |
StrArray:count ()
208 |
209 | object method. 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 |

Return value:

218 | integer. 219 | 220 | 221 | 222 |
223 | 224 | 225 | 226 | 227 |
StrArray:free ()
228 |
229 | Destroy this object (will be called by Garbage Collector). 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 |
240 | 241 | 242 | 243 | 244 |
StrArray:get_array ()
245 |
246 | object method. 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 |

Return value:

255 | nil. 256 | 257 | 258 | 259 |
260 | 261 | 262 | 263 | 264 |
StrArray:str (n)
265 |
266 | object method. 267 | 268 | 269 |

Parameters

270 |
    271 | 272 |
  • 273 | n: Must be of type integer. 274 |
  • 275 | 276 |
277 | 278 | 279 | 280 | 281 | 282 | 283 |

Return value:

284 | string. 285 | 286 | 287 | 288 |
289 | 290 | 291 |
292 | 293 | 294 | 295 | 296 | 297 | 298 |
299 | 300 |
301 | 302 |
303 |

Valid XHTML 1.0!

304 |
305 | 306 |
307 | 308 | 309 | -------------------------------------------------------------------------------- /docs/modules/TreeEntry.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module TreeEntry

135 | 136 |

Class "TreeEntry".

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 |
TreeEntry:filemode ()object method.
TreeEntry:id ()object method.
TreeEntry:name ()object method.
TreeEntry:object (repo, object)object method.
166 | 167 | 168 | 169 | 170 | 171 | 172 |
173 |
174 | 175 | 176 | 177 |

Functions

178 |
179 | 180 | 181 | 182 |
TreeEntry:filemode ()
183 |
184 | object method. 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 |

Return value:

193 | integer. 194 | 195 | 196 | 197 |
198 | 199 | 200 | 201 | 202 |
TreeEntry:id ()
203 |
204 | object method. 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 |

Return value:

213 | OID. 214 | 215 | 216 | 217 |
218 | 219 | 220 | 221 | 222 |
TreeEntry:name ()
223 |
224 | object method.

Calls git_tree_entry_name:

225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 |

Return value:

233 | string. 234 | 235 | 236 | 237 |
238 | 239 | 240 | 241 | 242 |
TreeEntry:object (repo, object)
243 |
244 | object method. 245 | 246 | 247 |

Parameters

248 |
    249 | 250 |
  • 251 | repo: repository where to lookup the pointed object. Must be of type Repository. 252 |
  • 253 | 254 |
  • 255 | object: pointer to the converted object 256 |
  • 257 | 258 |
259 | 260 | 261 | 262 | 263 | 264 | 265 |

Return values:

266 |
    267 | 268 |
  1. Object or nil on error. 269 | 270 |
  2. Error string. 271 | 272 |
273 | 274 | 275 | 276 |
277 | 278 | 279 |
280 | 281 | 282 | 283 | 284 | 285 | 286 |
287 | 288 |
289 | 290 |
291 |

Valid XHTML 1.0!

292 |
293 | 294 |
295 | 296 | 297 | -------------------------------------------------------------------------------- /docs/modules/git2.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | Reference 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 |
14 | 15 |
16 |
17 |
18 | 19 |
20 | 21 | 131 | 132 |
133 | 134 |

Module git2

135 | 136 |

Module git2. See libgit2 API docs.
Class StrArray
Class Repository
Class Config
Class OdbObject
Class OID
Class OID_Shorten
Class ODB
Class ODBBackend
Class Index
Class IndexEntry
Class IndexEntryUnmerged
Class Object
Class Blob
Class Signature
Class Commit
Class Tree
Class TreeEntry
Class Tag
Class RevWalk
Class Reference

137 | 138 | 139 | 140 | 141 | 142 |

Functions

143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 |
git2.version ()module function.
151 | 152 | 153 | 154 | 155 | 156 | 157 |
158 |
159 | 160 | 161 | 162 |

Functions

163 |
164 | 165 | 166 | 167 |
git2.version ()
168 |
169 | module function. 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 |

Return value:

178 | nil. 179 | 180 | 181 | 182 |
183 | 184 | 185 |
186 | 187 | 188 | 189 | 190 | 191 | 192 |
193 | 194 |
195 | 196 |
197 |

Valid XHTML 1.0!

198 |
199 | 200 |
201 | 202 | 203 | -------------------------------------------------------------------------------- /git2.nobj.lua: -------------------------------------------------------------------------------- 1 | 2 | basetype "git_time_t" "integer" "0" 3 | -- really? is this it? 4 | basetype "git_config_level_t" "integer" "0" 5 | 6 | c_module "git2" { 7 | -- module settings. 8 | use_globals = false, 9 | hide_meta_info = false, --true, 10 | 11 | include "git2.h", 12 | 13 | c_source "module_init_src" [[ 14 | git_libgit2_init(); 15 | ]], 16 | 17 | doc[[ 18 | See libgit2 API docs. 19 | ]], 20 | 21 | -- Error codes 22 | export_definitions { 23 | OK = "GIT_OK", 24 | ERROR = "GIT_ERROR", 25 | ENOTFOUND = "GIT_ENOTFOUND", 26 | EEXISTS = "GIT_EEXISTS", 27 | EAMBIGUOUS = "GIT_EAMBIGUOUS", 28 | EBUFS = "GIT_EBUFS", 29 | 30 | PASSTHROUGH = "GIT_PASSTHROUGH", 31 | REVWALKOVER = "GIT_REVWALKOVER", 32 | }, 33 | 34 | -- reference types 35 | constants { 36 | REF_INVALID = 0, -- Invalid reference */ 37 | REF_OID = 1, -- A reference which points at an object id */ 38 | REF_SYMBOLIC = 2, -- A reference which points at another reference */ 39 | REF_PACKED = 4, 40 | REF_HAS_PEEL = 8, 41 | REF_LISTALL = 0x07, -- GIT_REF_OID|GIT_REF_SYMBOLIC|GIT_REF_PACKED, 42 | }, 43 | 44 | c_function "version" { 45 | var_out{ "", "ver" }, 46 | c_source[[ 47 | int major, minor, patch; 48 | git_libgit2_version(&(major), &(minor), &(patch)); 49 | 50 | /* return version as a table: { major, minor, patch } */ 51 | lua_createtable(L, 3, 0); 52 | lua_pushinteger(L, major); 53 | lua_rawseti(L, -2, 1); 54 | lua_pushinteger(L, minor); 55 | lua_rawseti(L, -2, 2); 56 | lua_pushinteger(L, patch); 57 | lua_rawseti(L, -2, 3); 58 | ]], 59 | }, 60 | subfiles { 61 | "src/strarray.nobj.lua", 62 | "src/error.nobj.lua", 63 | "src/repository.nobj.lua", 64 | "src/config.nobj.lua", 65 | "src/odb_object.nobj.lua", 66 | "src/oid.nobj.lua", 67 | "src/oid_shorten.nobj.lua", 68 | "src/odb.nobj.lua", 69 | "src/odb_backend.nobj.lua", 70 | "src/index.nobj.lua", 71 | "src/index_entry.nobj.lua", 72 | "src/index_entry_unmerged.nobj.lua", 73 | "src/object.nobj.lua", 74 | "src/blob.nobj.lua", 75 | "src/signature.nobj.lua", 76 | "src/commit.nobj.lua", 77 | "src/tree.nobj.lua", 78 | "src/tree_entry.nobj.lua", 79 | "src/tag.nobj.lua", 80 | "src/revwalk.nobj.lua", 81 | "src/reference.nobj.lua", 82 | }, 83 | } 84 | 85 | -- 86 | -- Load parsed libgit2 docs. 87 | -- 88 | local json = require"json" 89 | local file = io.open("docs/libgit2.json", "r") 90 | local libgit2_docs = json.decode(file:read("*a")) 91 | file:close() 92 | 93 | local lg_funcs = libgit2_docs.functions 94 | 95 | -- Copy docs from libgit2 96 | reg_stage_parser("pre_gen",{ 97 | c_call = function(self, rec, parent) 98 | local func = lg_funcs[rec.cfunc] 99 | if not func then return end 100 | -- copy C function description 101 | parent:add_record(doc( 102 | '

Calls ' .. rec.cfunc .. ':

' .. 104 | '

' .. func.comments:gsub("\n\n", "

") 105 | )) 106 | -- copy C arg description 107 | local var_map = parent.var_map 108 | local args = func.args 109 | for i=1,#args do 110 | local arg = args[i] 111 | local name = arg.name 112 | local var = var_map[name] 113 | if var then 114 | var.desc = arg.comment 115 | end 116 | end 117 | end, 118 | }) 119 | 120 | -------------------------------------------------------------------------------- /rockspecs/lua-git2-0.1.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'lua-git2' 4 | version = '0.1' 5 | source = { 6 | url = 'git://github.com/libgit2/luagit2.git', 7 | branch = "v0.1" 8 | } 9 | description = { 10 | summary = "LibGit2 bindings for Lua.", 11 | detailed = '', 12 | homepage = 'https://github.com/libgit2/luagit2', 13 | license = 'MIT', 14 | maintainer = "Robert G. Jakabosky", 15 | } 16 | dependencies = { 17 | 'lua >= 5.1, < 5.5', 18 | } 19 | external_dependencies = { 20 | GIT2 = { 21 | header = "git2.h", 22 | library = "git2", 23 | } 24 | } 25 | build = { 26 | type = "builtin", 27 | modules = { 28 | git2 = { 29 | sources = { "src/pre_generated-git2.nobj.c" }, 30 | libraries = { "git2" }, 31 | incdirs = { "$(GIT2_INCDIR)" }, 32 | libdirs = { "$(GIT2_LIBDIR)" }, 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /rockspecs/lua-git2-scm-0.rockspec: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | package = 'lua-git2' 4 | version = 'scm-0' 5 | source = { 6 | url = 'git://github.com/libgit2/luagit2.git' 7 | } 8 | description = { 9 | summary = "LibGit2 bindings for Lua.", 10 | detailed = '', 11 | homepage = 'https://github.com/libgit2/luagit2', 12 | license = 'MIT', 13 | maintainer = "Robert G. Jakabosky", 14 | } 15 | dependencies = { 16 | 'lua >= 5.1, < 5.5', 17 | } 18 | external_dependencies = { 19 | GIT2 = { 20 | header = "git2.h", 21 | library = "git2", 22 | } 23 | } 24 | build = { 25 | type = "builtin", 26 | modules = { 27 | git2 = { 28 | sources = { "src/pre_generated-git2.nobj.c" }, 29 | libraries = { "git2" }, 30 | incdirs = { "$(GIT2_INCDIR)" }, 31 | libdirs = { "$(GIT2_LIBDIR)" }, 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/blob.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Blob" { 22 | c_source [[ 23 | typedef git_blob Blob; 24 | ]], 25 | extends "Object", 26 | constructor "lookup" { 27 | c_call { "GitError", "err" } "git_blob_lookup" 28 | { "Blob *", "&this", "Repository *", "repo", "OID", "&id" }, 29 | }, 30 | c_function "from_disk" { 31 | c_call { "GitError", "err>2" } "git_blob_create_from_disk" 32 | { "OID", "&written_id>1", "Repository *", "repo", "const char *", "path" }, 33 | }, 34 | c_function "from_buffer" { 35 | c_call { "GitError", "err" } "git_blob_create_from_buffer" 36 | { "OID", "&written_id>1", "Repository *", "repo", 37 | "const char *", "buffer", "size_t", "#buffer" }, 38 | }, 39 | method "rawcontent" { 40 | c_method_call { "const char *", "buff" } "git_blob_rawcontent" {}, 41 | c_method_call { "size_t", "#buff" } "git_blob_rawsize" {}, 42 | }, 43 | method "rawsize" { 44 | c_method_call "int" "git_blob_rawsize" {} 45 | }, 46 | } 47 | 48 | -------------------------------------------------------------------------------- /src/commit.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Commit" { 22 | c_source [[ 23 | typedef git_commit Commit; 24 | ]], 25 | extends "Object", 26 | constructor "lookup" { 27 | c_call {"GitError", "err"} "git_commit_lookup" 28 | { "Commit *", "&this", "Repository *", "repo", "OID", "&id" }, 29 | }, 30 | c_function "create" { 31 | var_in{ "OID", "oid" }, 32 | var_in{ "Repository *", "repo" }, 33 | var_in{ "const char *", "update_ref" }, 34 | var_in{ "Signature *", "author" }, 35 | var_in{ "Signature *", "committer" }, 36 | var_in{ "const char *", "message_encoding" }, 37 | var_in{ "const char *", "message" }, 38 | var_in{ "Tree *", "tree" }, 39 | var_in{ "Commit *", "parent" }, 40 | var_out{"GitError", "err"}, 41 | c_source "pre" [[ 42 | int parent_count = 0; 43 | #if LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR == 8 44 | git_commit **parents; 45 | #else 46 | const git_commit **parents; 47 | #endif 48 | int n; 49 | ]], 50 | c_source[[ 51 | /* count parents. */ 52 | parent_count = lua_gettop(L) - ${parent::idx} + 1; 53 | /* valid parents. The first parent commit is already validated. */ 54 | for(n = 1; n < parent_count; n++) { 55 | obj_type_Commit_check(L, ${parent::idx} + n); 56 | } 57 | /* now it is safe to allocate oid array. */ 58 | parents = malloc(parent_count * sizeof(git_commit *)); 59 | 60 | /* copy oids from all parents into oid array. */ 61 | parents[0] = ${parent}; 62 | for(n = 1; n < parent_count; n++) { 63 | parents[n] = obj_type_Commit_check(L, ${parent::idx} + n); 64 | } 65 | 66 | ${err} = git_commit_create(&(${oid}), ${repo}, ${update_ref}, 67 | ${author}, ${committer}, ${message_encoding}, ${message}, 68 | ${tree}, parent_count, parents); 69 | /* free parent oid array. */ 70 | free(parents); 71 | ]] 72 | }, 73 | method "id" { 74 | c_method_call { "OID", "*id" } "git_commit_id" {} 75 | }, 76 | method "message_encoding" { 77 | c_method_call "const char *" "git_commit_message_encoding" {} 78 | }, 79 | method "message" { 80 | c_method_call "const char *" "git_commit_message" {} 81 | }, 82 | method "time" { 83 | c_method_call "git_time_t" "git_commit_time" {} 84 | }, 85 | method "time_offset" { 86 | c_method_call "int" "git_commit_time_offset" {} 87 | }, 88 | method "committer" { 89 | c_method_call "const Signature *" "git_commit_committer" {} 90 | }, 91 | method "author" { 92 | c_method_call "const Signature *" "git_commit_author" {} 93 | }, 94 | method "tree" { 95 | c_call "GitError" "git_commit_tree" { "!Tree *", "&tree>1", "Commit *", "this" } 96 | }, 97 | method "parentcount" { 98 | c_method_call "unsigned int" "git_commit_parentcount" {} 99 | }, 100 | method "parent" { 101 | c_call "GitError" "git_commit_parent" 102 | { "Commit *", "&parent>1", "Commit *", "this", "unsigned int", "n" } 103 | }, 104 | } 105 | 106 | -------------------------------------------------------------------------------- /src/config.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Config" { 22 | c_source [[ 23 | typedef git_config Config; 24 | ]], 25 | constructor "new" { 26 | c_call { "GitError", "err"} "git_config_new" { "Config *", "&this" }, 27 | }, 28 | constructor "open" { 29 | c_call { "GitError", "err"} "git_config_open_ondisk" 30 | { "Config *", "&this", "const char *", "path" }, 31 | }, 32 | destructor "free" { 33 | c_method_call "void" "git_config_free" {}, 34 | }, 35 | method "add_file_ondisk" { 36 | c_method_call { "GitError", "err"} "git_config_add_file_ondisk" 37 | { "const char *", "path", "git_config_level_t", "level", "Repository *", "repo", "int", "force" }, 38 | }, 39 | method "get_int32" { 40 | c_call { "GitError", "err"} "git_config_get_int32" 41 | { "int32_t>1", "&out", "Config *", "this", "const char *", "name", }, 42 | }, 43 | method "set_int32" { 44 | c_method_call { "GitError", "err"} "git_config_set_int32" 45 | { "const char *", "name", "int32_t", "value" }, 46 | }, 47 | method "get_int64" { 48 | c_call { "GitError", "err"} "git_config_get_int64" 49 | { "int64_t>1", "&out", "Config *", "this", "const char *", "name", }, 50 | }, 51 | method "set_int64" { 52 | c_method_call { "GitError", "err"} "git_config_set_int64" 53 | { "const char *", "name", "int64_t", "value" }, 54 | }, 55 | method "get_bool" { 56 | var_out{"bool", "out"}, 57 | c_call { "GitError", "err"} "git_config_get_bool" 58 | { "int", "(&out_int)", "Config *", "this", "const char *", "name", }, 59 | c_source[[ 60 | ${out} = ${out_int}; 61 | ]], 62 | }, 63 | method "set_bool" { 64 | var_in{"bool", "value"}, 65 | c_source[[ 66 | ${value_int} = ${value} ? 1 : 0; 67 | ]], 68 | c_method_call { "GitError", "err"} "git_config_set_bool" 69 | { "const char *", "name", "int", "(value_int)" }, 70 | }, 71 | method "get_string" { 72 | c_call { "GitError", "err"} "git_config_get_string" 73 | { "const char *>1", "&out", "Config *", "this", "const char *", "name", }, 74 | }, 75 | method "set_string" { 76 | c_method_call { "GitError", "err"} "git_config_set_string" 77 | { "const char *", "name", "const char *", "value" }, 78 | }, 79 | method "delete_entry" { 80 | c_method_call { "GitError", "err"} "git_config_delete_entry" { "const char *", "name" }, 81 | }, 82 | method "delete_multivar" { 83 | c_method_call { "GitError", "err"} "git_config_delete_multivar" { "const char *", "name", "const char *", "regexp"}, 84 | }, 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/error.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | -- Convert Git Error codes into strings. 22 | error_code "GitError" "int" { 23 | is_error_check = function(rec) return "(GIT_OK != ${" .. rec.name .. "})" end, 24 | default = "GIT_OK", 25 | c_source [[ 26 | const git_error *giterr; 27 | switch(err) { 28 | case GIT_ERROR: 29 | giterr = giterr_last(); 30 | err_str = giterr->message; 31 | break; 32 | case GIT_ENOTFOUND: 33 | err_str = "ENOTFOUND"; 34 | break; 35 | case GIT_EEXISTS: 36 | err_str = "EEXISTS"; 37 | break; 38 | case GIT_EAMBIGUOUS: 39 | err_str = "EAMBIGUOUS"; 40 | break; 41 | case GIT_EBUFS: 42 | err_str = "EBUFS"; 43 | break; 44 | case GIT_PASSTHROUGH: 45 | err_str = "PASSTHROUGH"; 46 | break; 47 | case GIT_ITEROVER: 48 | err_str = "ITEROVER"; 49 | break; 50 | case GIT_OK: 51 | default: 52 | break; 53 | } 54 | ]], 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/index.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Index" { 22 | c_source [[ 23 | typedef git_index Index; 24 | ]], 25 | constructor "bare" { 26 | c_call {"GitError", "err"} "git_index_open" 27 | { "Index *", "&this", "const char *", "index_path" }, 28 | }, 29 | destructor { 30 | c_method_call "void" "git_index_free" {} 31 | }, 32 | method "clear" { 33 | c_method_call "void" "git_index_clear" {} 34 | }, 35 | method "read" { 36 | c_method_call "GitError" "git_index_read" { "int", "force" } 37 | }, 38 | method "write" { 39 | c_method_call "GitError" "git_index_write" {} 40 | }, 41 | method "find" { 42 | c_call "int" "git_index_find" { "size_t *", "at_pos", "Index *", "this", "const char *", "path" } 43 | }, 44 | method "add_bypath" { 45 | c_method_call "GitError" "git_index_add_bypath" { "const char *", "path"} 46 | }, 47 | method "add" { 48 | c_method_call "GitError" "git_index_add" { "IndexEntry *", "source_entry" } 49 | }, 50 | -- TODO: add_conflict? 51 | method "remove" { 52 | c_method_call "GitError" "git_index_remove" { "const char *", "path", "int", "stage" } 53 | }, 54 | method "get_byindex" { 55 | c_method_call "const IndexEntry *" "git_index_get_byindex" { "size_t", "n" } 56 | }, 57 | method "get_bypath" { 58 | c_method_call "const IndexEntry *" "git_index_get_bypath" { "const char *", "path", "int", "stage" } 59 | }, 60 | method "entrycount" { 61 | c_method_call "unsigned int" "git_index_entrycount" {} 62 | }, 63 | method "reuc_entrycount" { 64 | c_method_call "unsigned int" "git_index_reuc_entrycount" {} 65 | }, 66 | method "reuc_get_bypath" { 67 | c_method_call "const IndexEntryUnmerged *" "git_index_reuc_get_bypath" { "const char *", "path" } 68 | }, 69 | method "reuc_get_byindex" { 70 | c_method_call "const IndexEntryUnmerged *" "git_index_reuc_get_byindex" { "int", "n" } 71 | }, 72 | method "read_tree" { 73 | c_method_call "GitError" "git_index_read_tree" { "Tree *", "tree" } 74 | }, 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/index_entry.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "IndexEntry" { 22 | c_source [[ 23 | typedef git_index_entry IndexEntry; 24 | ]], 25 | constants { 26 | NAMEMASK = 0x0fff, 27 | STAGEMASK = 0x3000, 28 | EXTENDED = 0x4000, 29 | VALID = 0x8000, 30 | STAGESHIFT = 12, 31 | }, 32 | constructor { 33 | c_source [[ 34 | ${this} = calloc(1, sizeof(IndexEntry)); 35 | ]], 36 | }, 37 | destructor { 38 | c_source [[ 39 | if(${this}->path != NULL) { 40 | free((void *)${this}->path); 41 | } 42 | free(${this}); 43 | ]] 44 | }, 45 | method "stage" { 46 | c_method_call "int" "git_index_entry_stage" {}, 47 | }, 48 | method "ctime" { 49 | var_out{"git_time_t", "secs"}, 50 | var_out{"unsigned int", "nanosecs"}, 51 | c_source [[ 52 | ${secs} = ${this}->ctime.seconds; 53 | ${nanosecs} = ${this}->ctime.nanoseconds; 54 | ]] 55 | }, 56 | method "set_ctime" { 57 | var_in{"git_time_t", "secs"}, 58 | var_in{"unsigned int", "nanosecs"}, 59 | c_source [[ 60 | ${this}->ctime.seconds = ${secs}; 61 | ${this}->ctime.nanoseconds = ${nanosecs}; 62 | ]] 63 | }, 64 | method "mtime" { 65 | var_out{"git_time_t", "secs"}, 66 | var_out{"unsigned int", "nanosecs"}, 67 | c_source [[ 68 | ${secs} = ${this}->mtime.seconds; 69 | ${nanosecs} = ${this}->mtime.nanoseconds; 70 | ]] 71 | }, 72 | method "set_mtime" { 73 | var_in{"git_time_t", "secs"}, 74 | var_in{"unsigned int", "nanosecs"}, 75 | c_source [[ 76 | ${this}->mtime.seconds = ${secs}; 77 | ${this}->mtime.nanoseconds = ${nanosecs}; 78 | ]] 79 | }, 80 | field "unsigned int" "dev", 81 | field "unsigned int" "ino", 82 | field "unsigned int" "mode", 83 | field "unsigned int" "uid", 84 | field "unsigned int" "gid", 85 | field "off_t" "file_size", 86 | field "OID" "id", 87 | field "unsigned int" "flags", 88 | field "unsigned int" "flags_extended", 89 | method "path" { 90 | var_out{"const char *", "ret"}, 91 | c_source "${ret} = ${this}->path;" 92 | }, 93 | method "set_path" { 94 | var_in{"const char *", "val"}, 95 | c_source [[ 96 | if(${this}->path != NULL) { 97 | free((void *)${this}->path); 98 | } 99 | char * path_buf = malloc(${val_len}); 100 | strncpy(path_buf, ${val}, ${val_len}); 101 | path_buf[${val_len}] = 0; 102 | ${this}->path = path_buf; 103 | ]] 104 | }, 105 | } 106 | 107 | -------------------------------------------------------------------------------- /src/index_entry_unmerged.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "IndexEntryUnmerged" { 22 | c_source [[ 23 | #include 24 | typedef git_index_reuc_entry IndexEntryUnmerged; 25 | ]], 26 | method "mode" { 27 | var_in{"int", "idx"}, 28 | var_out{"unsigned int", "mode"}, 29 | c_source [[ 30 | if(${idx} < 0 || ${idx} >=3) { 31 | return luaL_argerror(L, ${idx::idx}, "Index out-of-bounds (0-2)"); 32 | } 33 | ${mode} = ${this}->mode[${idx}]; 34 | ]] 35 | }, 36 | method "oid" { 37 | var_in{"int", "idx"}, 38 | var_out{"OID", "oid"}, 39 | c_source [[ 40 | if(${idx} < 0 || ${idx} >=3) { 41 | return luaL_argerror(L, ${idx::idx}, "Index out-of-bounds (0-2)"); 42 | } 43 | ${oid} = ${this}->oid[${idx}]; 44 | ]] 45 | }, 46 | method "path" { 47 | var_out{"const char *", "ret"}, 48 | c_source "${ret} = ${this}->path;" 49 | }, 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/object.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Object" { 22 | basetype "git_otype" "integer", 23 | c_source [[ 24 | typedef git_object Object; 25 | ]], 26 | dyn_caster { 27 | caster_type = "switch", 28 | value_function = "git_object_type", 29 | value_map = { 30 | GIT_OBJ_BLOB = "Blob", 31 | GIT_OBJ_COMMIT = "Commit", 32 | GIT_OBJ_TREE = "Tree", 33 | GIT_OBJ_TAG = "Tag", 34 | }, 35 | }, 36 | destructor "free" { 37 | c_method_call "void" "git_object_free" {} 38 | }, 39 | method "id" { 40 | c_method_call { "OID", "*id" } "git_object_id" {}, 41 | }, 42 | method "type" { 43 | c_method_call { "git_otype", "(otype)" } "git_object_type" {}, 44 | c_call { "const char *", "type" } "git_object_type2string" { "git_otype", "otype" }, 45 | }, 46 | method "owner" { 47 | c_method_call "Repository *" "git_object_owner" {} 48 | }, 49 | c_function "type2string" { 50 | c_call "const char *" "git_object_type2string" { "git_otype", "otype" }, 51 | }, 52 | c_function "string2type" { 53 | c_call "git_otype" "git_object_string2type" { "const char *", "str" }, 54 | }, 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/odb.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "ODB" { 22 | c_source [[ 23 | typedef git_odb ODB; 24 | ]], 25 | constructor "new" { 26 | c_call {"GitError", "err"} "git_odb_new" { "ODB *", "&this" }, 27 | }, 28 | constructor "open" { 29 | c_call {"GitError", "err"} "git_odb_open" 30 | { "ODB *", "&this", "const char *", "object_dir" }, 31 | }, 32 | destructor "free" { 33 | c_method_call "void" "git_odb_free" {} 34 | }, 35 | method "add_backend" { 36 | var_in{"ODBBackend *", "backend"}, 37 | var_in{"int", "priority"}, 38 | var_out{"GitError", "err"}, 39 | c_source [[ 40 | ${err} = git_odb_add_backend(${this}, &(${backend}->backend), ${priority}); 41 | ODBBackend_ref(${backend}); 42 | ]], 43 | }, 44 | method "add_alternate" { 45 | var_in{"ODBBackend *", "backend"}, 46 | var_in{"int", "priority"}, 47 | var_out{"GitError", "err"}, 48 | c_source [[ 49 | ${err} = git_odb_add_alternate(${this}, &(${backend}->backend), ${priority}); 50 | ODBBackend_ref(${backend}); 51 | ]], 52 | }, 53 | method "read" { 54 | c_call "GitError" "git_odb_read" 55 | { "!OdbObject *", "&out>1", "ODB *", "this", "OID", "&id"}, 56 | }, 57 | method "read_prefix" { 58 | c_call "GitError" "git_odb_read_prefix" 59 | { "!OdbObject *", "&out>1", "ODB *", "this", "OID", "&short_id", "unsigned int", "len"}, 60 | }, 61 | method "read_header" { 62 | c_call { "GitError", "err>3" } "git_odb_read_header" 63 | { "size_t", "&len_p>1", "git_otype", "&(otype)", "ODB *", "this", "OID", "&id"}, 64 | c_call { "const char *", "type>2" } "git_object_type2string" { "git_otype", "otype" }, 65 | }, 66 | method "exists" { 67 | c_method_call { "GitError", "err" } "git_odb_exists" { "OID", "&id" } 68 | }, 69 | method "write" { 70 | c_call { "git_otype", "(otype)" } "git_object_string2type" { "const char *", "type<3" }, 71 | c_call "GitError" "git_odb_write" 72 | { "OID", "&id>1", "ODB *", "this<1", "const char *", "data<2", "size_t", "#data", 73 | "git_otype", "otype"}, 74 | }, 75 | c_function "hash" { 76 | c_call { "GitError", "err" } "git_odb_hash" 77 | { "OID", "&id>1", "const char *", "data", "size_t", "#data", "git_otype", "otype"} 78 | }, 79 | c_function "hashfile" { 80 | c_call { "GitError", "err" } "git_odb_hashfile" 81 | { "OID", "&id>1", "const char *", "path", "git_otype", "otype"} 82 | }, 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/odb_backend.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "ODBBackend" { 22 | c_source [[ 23 | #include 24 | #include 25 | 26 | typedef struct ODBBackend { 27 | git_odb_backend backend; 28 | lua_State *L; 29 | int read; 30 | int read_prefix; 31 | int read_header; 32 | int write; 33 | int exists; 34 | int free; 35 | int ref_count; 36 | } ODBBackend; 37 | 38 | static void ODBBackend_ref(ODBBackend *backend) { 39 | backend->ref_count++; 40 | } 41 | 42 | static void ODBBackend_unref(ODBBackend *backend) { 43 | lua_State *L = backend->L; 44 | assert(backend->ref_count > 0); 45 | if((--backend->ref_count) == 0) { 46 | luaL_unref(L, LUA_REGISTRYINDEX, backend->read); 47 | luaL_unref(L, LUA_REGISTRYINDEX, backend->read_prefix); 48 | luaL_unref(L, LUA_REGISTRYINDEX, backend->read_header); 49 | luaL_unref(L, LUA_REGISTRYINDEX, backend->write); 50 | luaL_unref(L, LUA_REGISTRYINDEX, backend->exists); 51 | luaL_unref(L, LUA_REGISTRYINDEX, backend->free); 52 | free(backend); 53 | } 54 | } 55 | 56 | static int odb_backend_read_cb(void **data_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) 57 | { 58 | ODBBackend *lua_backend = (ODBBackend *)backend; 59 | lua_State *L = lua_backend->L; 60 | const char *ldata; 61 | size_t len; 62 | int err; 63 | 64 | /* get Lua callback function. */ 65 | lua_rawgeti(L, LUA_REGISTRYINDEX, lua_backend->read); 66 | 67 | obj_type_OID_push(L, *((OID *)oid)); 68 | /* call Lua function. */ 69 | lua_call(L, 1, 2); 70 | ldata = lua_tolstring(L, -2, &len); 71 | if(ldata) { 72 | char *data; 73 | /* parse otype value. */ 74 | int arg_type = lua_type(L, -1); 75 | if(arg_type == LUA_TNUMBER) { 76 | *type_p = lua_tointeger(L, -1); 77 | } else if(arg_type == LUA_TSTRING) { 78 | *type_p = git_object_string2type(lua_tostring(L, -1)); 79 | } 80 | *len_p = len; 81 | /* allocate buffer for data. */ 82 | data = malloc(len); 83 | *data_p = data; 84 | if(data == NULL) { 85 | return GIT_EBUFS; //GIT_ENOMEM; 86 | } 87 | /* copy data. */ 88 | memcpy(data, ldata, len); 89 | err = GIT_OK; 90 | } else if(lua_isnil(L, -2)) { 91 | *data_p = NULL; 92 | /* backend returned an error. */ 93 | err = lua_tointeger(L, -1); 94 | } else { 95 | *data_p = NULL; 96 | /* bad return value from lua backend. */ 97 | err = GIT_EAMBIGUOUS; //GIT_EOBJTYPE; 98 | } 99 | 100 | return err; 101 | } 102 | 103 | static int odb_backend_read_prefix_cb(git_oid *out_oid, void **data_p, size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *short_oid, size_t len) 104 | { 105 | *data_p = NULL; 106 | if(len >= GIT_OID_HEXSZ) { 107 | int rc = odb_backend_read_cb(data_p, len_p, type_p, backend, short_oid); 108 | if(rc == GIT_OK) { 109 | git_oid_cpy(out_oid, short_oid); 110 | } 111 | return rc; 112 | } 113 | return GIT_EAMBIGUOUS; //GIT_ENOTIMPLEMENTED; 114 | } 115 | 116 | static int odb_backend_read_header_cb(size_t *len_p, git_otype *type_p, git_odb_backend *backend, const git_oid *oid) 117 | { 118 | ODBBackend *lua_backend = (ODBBackend *)backend; 119 | lua_State *L = lua_backend->L; 120 | int err; 121 | int arg_type; 122 | 123 | /* get Lua callback function. */ 124 | lua_rawgeti(L, LUA_REGISTRYINDEX, lua_backend->read_header); 125 | 126 | obj_type_OID_push(L, *((OID *)oid)); 127 | /* call Lua function. */ 128 | lua_call(L, 1, 2); 129 | 130 | arg_type = lua_type(L, -2); 131 | if(arg_type == LUA_TSTRING || arg_type == LUA_TNUMBER) { 132 | /* parse data length. */ 133 | *len_p = lua_tonumber(L, -2); 134 | /* parse otype value. */ 135 | lua_type(L, -1); 136 | if(arg_type == LUA_TNUMBER) { 137 | *type_p = lua_tointeger(L, -1); 138 | } else if(arg_type == LUA_TSTRING) { 139 | *type_p = git_object_string2type(lua_tostring(L, -1)); 140 | } 141 | err = GIT_OK; 142 | } else if(arg_type == LUA_TNIL) { 143 | /* backend returned an error. */ 144 | err = lua_tointeger(L, -1); 145 | } else { 146 | /* bad return value from lua backend. */ 147 | err = GIT_EAMBIGUOUS; //GIT_EOBJTYPE; 148 | } 149 | 150 | return err; 151 | } 152 | 153 | static int odb_backend_write_cb(git_odb_backend *backend, const git_oid *oid, const void *data, size_t len, git_otype type) 154 | { 155 | ODBBackend *lua_backend = (ODBBackend *)backend; 156 | lua_State *L = lua_backend->L; 157 | 158 | /* get Lua callback function. */ 159 | lua_rawgeti(L, LUA_REGISTRYINDEX, lua_backend->write); 160 | 161 | /* push oid */ 162 | obj_type_OID_push(L, *((OID *)oid)); 163 | /* push data onto stack. */ 164 | lua_pushlstring(L, data, len); 165 | /* push otype */ 166 | lua_pushstring(L, git_object_type2string(type)); 167 | 168 | /* call Lua function. */ 169 | lua_call(L, 3, 1); 170 | return lua_tointeger(L, -1); 171 | } 172 | 173 | static int odb_backend_exists_cb(git_odb_backend *backend, const git_oid *oid) 174 | { 175 | ODBBackend *lua_backend = (ODBBackend *)backend; 176 | lua_State *L = lua_backend->L; 177 | 178 | /* get Lua callback function. */ 179 | lua_rawgeti(L, LUA_REGISTRYINDEX, lua_backend->exists); 180 | 181 | obj_type_OID_push(L, *((OID *)oid)); 182 | /* call Lua function. */ 183 | lua_call(L, 1, 1); 184 | return lua_tointeger(L, -1); 185 | } 186 | 187 | static void odb_backend_free_cb(git_odb_backend *backend) 188 | { 189 | ODBBackend *lua_backend = (ODBBackend *)backend; 190 | lua_State *L = lua_backend->L; 191 | 192 | /* get Lua callback function. */ 193 | lua_rawgeti(L, LUA_REGISTRYINDEX, lua_backend->free); 194 | 195 | /* call Lua function. */ 196 | lua_call(L, 0, 0); 197 | 198 | ODBBackend_unref(lua_backend); 199 | } 200 | 201 | ]], 202 | constructor { 203 | var_in{"lua_State *", "L"}, 204 | c_source [[ 205 | luaL_checktype(L, 1, LUA_TTABLE); 206 | lua_settop(L, 1); 207 | /* create backend object. */ 208 | ${this} = calloc(1, sizeof(ODBBackend)); 209 | ${this}->ref_count = 1; 210 | ${this}->L = L; 211 | /* get each callback from table. */ 212 | #define REF_CB(_name) \ 213 | lua_getfield(L, 1, "on_" #_name); \ 214 | ${this}->_name = luaL_ref(L, LUA_REGISTRYINDEX); \ 215 | ${this}->backend._name = odb_backend_ ## _name ## _cb; 216 | 217 | REF_CB(read) 218 | REF_CB(read_prefix) 219 | REF_CB(read_header) 220 | REF_CB(write) 221 | REF_CB(exists) 222 | REF_CB(free) 223 | #undef REF_CB 224 | 225 | #ifdef GIT_ODB_BACKEND_VERSION 226 | ${this}->backend.version = GIT_ODB_BACKEND_VERSION; 227 | #endif 228 | ]] 229 | }, 230 | destructor { 231 | c_source [[ 232 | ODBBackend_unref(${this}); 233 | ]] 234 | }, 235 | } 236 | 237 | -------------------------------------------------------------------------------- /src/odb_object.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2011-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "OdbObject" { 22 | c_source [[ 23 | typedef git_odb_object OdbObject; 24 | ]], 25 | destructor "free" { 26 | c_method_call "void" "git_odb_object_free" {}, 27 | }, 28 | method "id" { 29 | c_method_call { "OID", "*id" } "git_odb_object_id" {}, 30 | }, 31 | method "data" { 32 | c_method_call { "const char *", "data" } "git_odb_object_data" {}, 33 | c_method_call { "size_t", "#data" } "git_odb_object_size" {}, 34 | }, 35 | method "size" { 36 | c_method_call "size_t" "git_odb_object_size" {}, 37 | }, 38 | method "type" { 39 | c_method_call { "git_otype", "(otype)" } "git_odb_object_type" {}, 40 | c_call { "const char *", "type" } "git_object_type2string" { "git_otype", "otype" }, 41 | }, 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/oid.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "OID" { 22 | export_definitions { 23 | RAWSZ = "GIT_OID_RAWSZ", 24 | HEXSZ = "GIT_OID_HEXSZ", 25 | MINPREFIXLEN = "GIT_OID_MINPREFIXLEN", 26 | }, 27 | c_source [[ 28 | typedef git_oid OID; 29 | ]], 30 | userdata_type = 'simple', 31 | constructor "hex" { 32 | c_call {"GitError", "err"} "git_oid_fromstrn" 33 | { "OID", "&this", "const char *", "str", "size_t", "#str" }, 34 | }, 35 | constructor "raw" { 36 | c_source[[ 37 | if(${raw_len} < GIT_OID_RAWSZ) { 38 | lua_pushnil(L); 39 | lua_pushliteral(L, "Invalid RAW OID"); 40 | return 2; 41 | } 42 | ]], 43 | c_call "void" "git_oid_fromraw" { "OID", "&this", "const unsigned char *", "raw" }, 44 | }, 45 | method "pathfmt" { 46 | var_out{"const char *", "ret"}, 47 | c_source [[ 48 | char buf[GIT_OID_HEXSZ+1+1]; 49 | git_oid_pathfmt(buf, &(${this})); 50 | buf[GIT_OID_HEXSZ] = 0; 51 | ${ret} = buf; 52 | ]], 53 | }, 54 | method "fmt" { 55 | var_out{"const char *", "ret"}, 56 | c_source [[ 57 | char buf[GIT_OID_HEXSZ+1]; 58 | git_oid_fmt(buf, &(${this})); 59 | buf[GIT_OID_HEXSZ] = 0; 60 | ${ret} = buf; 61 | ]], 62 | }, 63 | method "__str__" { 64 | var_out{"const char *", "ret"}, 65 | c_source [[ 66 | char buf[GIT_OID_HEXSZ+1]; 67 | git_oid_fmt(buf, &(${this})); 68 | buf[GIT_OID_HEXSZ] = 0; 69 | ${ret} = buf; 70 | ]], 71 | }, 72 | method "__eq__" { 73 | c_call {"int", "ret"} "git_oid_cmp" { "OID", "&this", "OID", "&id" }, 74 | }, 75 | } 76 | 77 | -------------------------------------------------------------------------------- /src/oid_shorten.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "OID_Shorten" { 22 | c_source [[ 23 | typedef git_oid_shorten OID_Shorten; 24 | ]], 25 | constructor "new" { 26 | c_call "OID_Shorten *" "git_oid_shorten_new" { "size_t", "min_length" }, 27 | }, 28 | destructor { 29 | c_method_call "void" "git_oid_shorten_free" {} 30 | }, 31 | method "add" { 32 | c_method_call { "GitError", "rc"} "git_oid_shorten_add" { "const char *", "text_oid" }, 33 | c_source[[ 34 | if(${rc} >= 0) { 35 | lua_pushinteger(L, ${rc}); 36 | return 1; 37 | } 38 | ]] 39 | }, 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/reference.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Reference" { 22 | basetype "git_ref_t" "integer", 23 | c_source [[ 24 | typedef git_reference Reference; 25 | ]], 26 | constructor "lookup" { 27 | c_call { "GitError", "err" } "git_reference_lookup" 28 | { "Reference *", "&this>1", "Repository *", "repo", "const char *", "name" }, 29 | }, 30 | method "target" { 31 | c_method_call "*OID" "git_reference_target" {} 32 | }, 33 | method "set_target" { 34 | c_call "GitError" "git_reference_set_target" { "Reference *", "&ref_out>1", "Reference *", "this", "OID", "&oid", "const char *", "log_message" } 35 | }, 36 | method "type" { 37 | c_method_call "git_ref_t" "git_reference_type" {} 38 | }, 39 | method "name" { 40 | c_method_call "const char *" "git_reference_name" {} 41 | }, 42 | method "resolve" { 43 | c_call "GitError" "git_reference_resolve" 44 | { "Reference *", "&resolved_ref>1", "Reference *", "this" } 45 | }, 46 | method "owner" { 47 | c_method_call "Repository *" "git_reference_owner" {} 48 | }, 49 | method "rename" { 50 | c_call "GitError" "git_reference_rename" { "Reference *", "&ref_out>1", "Reference *", "this", "const char *", "new_name", "int", "force", "const char *", "log_message" } 51 | }, 52 | method "delete" { 53 | c_method_call "GitError" "git_reference_delete" {} 54 | }, 55 | -- TODO: replacement for git_reference_packall ? 56 | c_function "list" { 57 | var_in{ "Repository *", "repo" }, 58 | var_out{ "StrArray *", "array" }, 59 | var_out{ "GitError", "err" }, 60 | c_source "pre" [[ 61 | git_strarray tmp_array = { .strings = NULL, .count = 0 }; 62 | ]], 63 | c_source[[ 64 | /* push this onto stack now, just encase there is a out-of-memory error. */ 65 | ${array} = obj_type_StrArray_push(L, &tmp_array); 66 | ${err} = git_reference_list(${array}, ${repo}); 67 | if(${err} == GIT_OK) { 68 | return 1; /* array is already on the stack. */ 69 | } else { 70 | /* there is an error remove the temp array from stack. */ 71 | lua_pop(L, 1); 72 | ${array} = NULL; 73 | } 74 | ]] 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /src/repository.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Repository" { 22 | c_source [[ 23 | #include 24 | typedef git_repository Repository; 25 | ]], 26 | constructor "open" { 27 | c_call { "GitError", "err" } "git_repository_open" 28 | { "Repository *", "&this>1", "const char *", "path" }, 29 | }, 30 | --[=[ 31 | constructor "discover" { 32 | c_source[[ 33 | ]], 34 | c_call { "GitError", "err" } "git_repository_open" 35 | { "Repository *", "&this>1", "const char *", "path" }, 36 | }, 37 | --]=] 38 | constructor "init" { 39 | c_call { "GitError", "err" } "git_repository_init" 40 | { "Repository *", "&this>1", "const char *", "path", "unsigned int", "is_bare" }, 41 | }, 42 | destructor { 43 | c_method_call "void" "git_repository_free" {} 44 | }, 45 | method "head" { 46 | c_call { "GitError", "err" } "git_repository_head" 47 | { "!Reference *", "&head>1", "Repository *", "this" }, 48 | }, 49 | method "head_detached" { 50 | c_method_call "bool" "git_repository_head_detached" {} 51 | }, 52 | method "head_unborn" { 53 | c_method_call "bool" "git_repository_head_unborn" {} 54 | }, 55 | method "is_empty" { 56 | c_method_call "bool" "git_repository_is_empty" {} 57 | }, 58 | method "is_bare" { 59 | c_method_call "bool" "git_repository_is_bare" {} 60 | }, 61 | method "path" { 62 | c_method_call "const char *" "git_repository_path" {} 63 | }, 64 | method "workdir" { 65 | c_method_call "const char *" "git_repository_workdir" {} 66 | }, 67 | method "set_workdir" { 68 | c_method_call "GitError" "git_repository_set_workdir" { "const char *", "workdir", "int", "update_gitlink"} 69 | }, 70 | method "config" { 71 | c_call { "GitError", "err" } "git_repository_config" 72 | { "!Config *", "&config>1", "Repository *", "this" }, 73 | }, 74 | method "set_config" { 75 | c_method_call "void" "git_repository_set_config" { "Config *", "config"} 76 | }, 77 | method "odb" { 78 | c_call { "GitError", "err" } "git_repository_odb" 79 | { "!ODB *", "&odb>1", "Repository *", "this" }, 80 | }, 81 | method "set_odb" { 82 | c_method_call "void" "git_repository_set_odb" { "ODB *", "odb"} 83 | }, 84 | method "index" { 85 | c_call { "GitError", "err" } "git_repository_index" 86 | { "!Index *", "&index>1", "Repository *", "this" }, 87 | }, 88 | method "set_index" { 89 | c_method_call "void" "git_repository_set_index" { "Index *", "index"} 90 | }, 91 | } 92 | 93 | -------------------------------------------------------------------------------- /src/revwalk.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "RevWalk" { 22 | c_source [[ 23 | typedef git_revwalk RevWalk; 24 | ]], 25 | constants { 26 | SORT_NONE = 0x00, 27 | SORT_TOPOLOGICAL = 0x01, 28 | SORT_TIME = 0x02, 29 | SORT_REVERSE = 0x04, 30 | }, 31 | constructor "new" { 32 | c_call { "GitError", "err" } "git_revwalk_new" 33 | { "RevWalk *", "&this>1", "Repository *", "repo" }, 34 | }, 35 | destructor "close" { 36 | c_method_call "void" "git_revwalk_free" {} 37 | }, 38 | method "reset" { 39 | c_method_call "void" "git_revwalk_reset" {} 40 | }, 41 | method "push" { 42 | c_method_call "GitError" "git_revwalk_push" { "OID", "&id" } 43 | }, 44 | method "hide" { 45 | c_method_call "GitError" "git_revwalk_hide" { "OID", "&id" } 46 | }, 47 | method "next" { 48 | c_call "GitError" "git_revwalk_next" { "OID", "&id>1", "RevWalk *", "this<1" } 49 | }, 50 | method "sorting" { 51 | c_method_call "void" "git_revwalk_sorting" { "unsigned int", "sort_mode" } 52 | }, 53 | method "repository" { 54 | c_method_call "Repository *" "git_revwalk_repository" {} 55 | }, 56 | } 57 | 58 | -------------------------------------------------------------------------------- /src/signature.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Signature" { 22 | c_source [[ 23 | typedef git_signature Signature; 24 | ]], 25 | constructor "new" { 26 | c_call "GitError" "git_signature_new" 27 | { "Signature *", "&this>1", "const char *", "name", "const char *", "email", "git_time_t", "time", "int", "offset" }, 28 | }, 29 | constructor "now" { 30 | c_call "GitError" "git_signature_now" 31 | { "Signature *", "&this>1", "const char *", "name", "const char *", "email" }, 32 | }, 33 | destructor { 34 | c_method_call "void" "git_signature_free" {}, 35 | }, 36 | method "name" { 37 | var_out{"const char *", "name"}, 38 | c_source "${name} = ${this}->name;", 39 | }, 40 | method "email" { 41 | var_out{"const char *", "email"}, 42 | c_source "${email} = ${this}->email;", 43 | }, 44 | method "when" { 45 | var_out{"git_time_t", "time"}, 46 | var_out{"int", "offset"}, 47 | c_source "${time} = ${this}->when.time; ${offset} = ${this}->when.offset;", 48 | }, 49 | } 50 | 51 | -------------------------------------------------------------------------------- /src/strarray.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "StrArray" { 22 | userdata_type = "embed", 23 | c_source [[ 24 | typedef git_strarray StrArray; 25 | ]], 26 | constructor "new" { 27 | c_source[[ 28 | StrArray array; 29 | array.strings = NULL; 30 | array.count = 0; 31 | ${this} = &array; 32 | ]] 33 | }, 34 | destructor "free" { 35 | c_source[[ 36 | if(${this}->strings != 0) { 37 | git_strarray_free(${this}); 38 | ${this}->strings = NULL; 39 | } 40 | ]] 41 | }, 42 | field "size_t" "count" { "ro" }, 43 | method "str" { 44 | var_in{ "size_t", "n" }, 45 | var_out{ "const char *", "str" }, 46 | c_source[[ 47 | if(${n} < ${this}->count) { 48 | ${str} = ${this}->strings[${n}]; 49 | } 50 | ]], 51 | }, 52 | method "get_array" { 53 | var_out{ "", "array" }, 54 | c_source "pre" [[ 55 | size_t n; 56 | ]], 57 | c_source[[ 58 | lua_createtable(L, ${this}->count, 0); 59 | for(n = 0; n < ${this}->count; n++) { 60 | lua_pushstring(L, ${this}->strings[n]); 61 | lua_rawseti(L, -2, n+1); 62 | } 63 | ]] 64 | } 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/tag.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Tag" { 22 | c_source [[ 23 | typedef git_tag Tag; 24 | ]], 25 | extends "Object", 26 | constructor "lookup" { 27 | c_call { "GitError", "err" } "git_tag_lookup" 28 | { "Tag *", "&this>1", "Repository *", "repo", "OID", "&id" }, 29 | }, 30 | method "target" { 31 | c_call "GitError" "git_tag_target" { "Object *", "&out>1", "Tag *", "this" } 32 | }, 33 | method "name" { 34 | c_method_call "const char *" "git_tag_name" {} 35 | }, 36 | method "tagger" { 37 | c_method_call "const Signature *" "git_tag_tagger" {} 38 | }, 39 | method "message" { 40 | c_method_call "const char *" "git_tag_message" {} 41 | }, 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/tree.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "Tree" { 22 | c_source [[ 23 | typedef git_tree Tree; 24 | ]], 25 | extends "Object", 26 | constructor "lookup" { 27 | c_call { "GitError", "err" } "git_tree_lookup" 28 | { "Tree *", "&this>1", "Repository *", "repo", "OID", "&id" }, 29 | }, 30 | method "entrycount" { 31 | c_method_call "size_t" "git_tree_entrycount" {} 32 | }, 33 | method "entry_byname" { 34 | c_method_call "const TreeEntry *" "git_tree_entry_byname" { "const char *", "filename" } 35 | }, 36 | method "entry_byindex" { 37 | c_method_call "const TreeEntry *" "git_tree_entry_byindex" { "int", "index" } 38 | }, 39 | } 40 | 41 | -------------------------------------------------------------------------------- /src/tree_entry.nobj.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010-2012 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | object "TreeEntry" { 22 | c_source [[ 23 | typedef git_tree_entry TreeEntry; 24 | ]], 25 | method "name" { 26 | c_method_call "const char *" "git_tree_entry_name" {} 27 | }, 28 | method "filemode" { 29 | c_method_call "unsigned int" "git_tree_entry_filemode" {} 30 | }, 31 | method "id" { 32 | var_out{"OID", "id"}, 33 | c_source "${id} = *(git_tree_entry_id(${this}));" 34 | }, 35 | method "object" { 36 | c_call "GitError" "git_tree_entry_to_object" 37 | { "!Object *", "&obj>1", "Repository *", "repo", "TreeEntry *", "this" } 38 | }, 39 | } 40 | 41 | -------------------------------------------------------------------------------- /tests/test_backend.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local build_dir = arg[1] 4 | local git_path = arg[2] or "./tests/test_rep/.git/" 5 | -- Make it easier to test 6 | if ( build_dir ) then 7 | package.cpath = build_dir .. "?.so;" .. package.cpath 8 | end 9 | 10 | local git2 = require"git2" 11 | require"utils" 12 | 13 | --print(dump(git2)) 14 | local function dump_obj(obj) 15 | print('dump OdbObject:', obj) 16 | if obj == nil then 17 | return 18 | end 19 | print('id = ', obj:id()) 20 | print('type = ', obj:type()) 21 | local data = obj:data() 22 | print('data = ', data) 23 | if data then 24 | print('hash = ', git2.ODB.hash(data,git2.Object.string2type(obj:type()))) 25 | end 26 | end 27 | 28 | -- create odb 29 | local db = assert(git2.ODB.new()) 30 | print("=============================================== new db=", db) 31 | print("dump ODB interface") 32 | --print(dbg_dump(db)) 33 | 34 | -- create backend 35 | local obj_cache = {} 36 | local function get_obj(oid) 37 | print("------------------- exists callback:", oid) 38 | if not oid then 39 | return nil 40 | end 41 | -- convert oid to string. 42 | oid = tostring(oid) 43 | return obj_cache[oid] 44 | end 45 | local cbs = { 46 | on_read = function(oid) 47 | print("------------------- read callback:", oid) 48 | local obj = get_obj(oid) 49 | if not obj then 50 | return nil, git2.ENOTFOUND 51 | end 52 | return obj.data, obj.otype 53 | end, 54 | on_read_prefix = function(short_oid, len) 55 | print("------------------- read_prefix callback:", oid) 56 | local obj = get_obj(short_oid) 57 | if not obj then 58 | if len ~= git2.OID.HEXSZ then 59 | return nil, git2.ENOTIMPLEMENTED 60 | end 61 | return nil, git2.ENOTFOUND 62 | end 63 | return obj.data, obj.otype, short_oid 64 | end, 65 | on_read_header = function(oid) 66 | print("------------------- read_header callback:", oid) 67 | local obj = get_obj(oid) 68 | if not obj then 69 | return nil, git2.ENOTFOUND 70 | end 71 | return obj.len, obj.otype 72 | end, 73 | on_write = function(oid, data, otype) 74 | print("------------------- write callback:", oid, data, otype) 75 | if not oid then 76 | return nil, -1 77 | end 78 | -- convert oid to string. 79 | local oid_str = tostring(oid) 80 | -- put raw object in cache 81 | obj_cache[oid_str] = { data = data, len = #data, otype = otype} 82 | return oid 83 | end, 84 | on_exists = function(oid) 85 | print("------------------- exists callback:", oid) 86 | local obj = get_obj(oid) 87 | if not obj then 88 | return false 89 | end 90 | return true 91 | end, 92 | on_free = function() 93 | print("------------------- free callback:") 94 | end, 95 | } 96 | 97 | local backend = git2.ODBBackend(cbs) 98 | 99 | print('add backend:', assert(db:add_backend(backend, 0))) 100 | backend = nil 101 | collectgarbage"collect" 102 | 103 | print("test writing test blob to odb:") 104 | local oid, err = db:write("any ol content will do", 'blob') 105 | print('write:', oid, err) 106 | 107 | print() 108 | print("test reading RawObjects from odb:") 109 | local object_ids = { 110 | {'tree', "31f3d5703ce27f0b63c3eb0d829abdc95b51deae"}, 111 | {'commit', "d5a93c463d4cca0068750eb6af7b4b54eea8599b"}, 112 | {'blob', "f534deb63f967cddd4bd440d05d3f6f075e55fca"}, 113 | {'blob', "275a4019807c7bb7bc80c0ca8903bf84345e1bdf"}, 114 | } 115 | for _,obj in ipairs(object_ids) do 116 | local oid = git2.OID.hex(obj[2]) 117 | local obj, err = db:read(oid) 118 | print('read', obj, err) 119 | dump_obj(obj) 120 | print() 121 | end 122 | 123 | print("Creating repository from git repository:", git_path) 124 | local status, rep = pcall(git2.Repository.open_no_backend, 125 | git_path, git_path .. 'objects', git_path .. 'index', git_path .. '../') 126 | 127 | if not status then 128 | rep = assert(git2.Repository.open(git_path)) 129 | else 130 | print("Created repository with no backends from git repository:", git_path) 131 | end 132 | db = rep:odb() 133 | print("=============================================== repo db=", db) 134 | backend = git2.ODBBackend(cbs) 135 | print("add backend repository's odb:", assert(db:add_backend(backend, 0))) 136 | backend = nil 137 | collectgarbage"collect" 138 | 139 | print() 140 | print("try reading objects from repository:") 141 | local object_ids = { 142 | {'tree', "31f3d5703ce27f0b63c3eb0d829abdc95b51deae"}, 143 | {'commit', "d5a93c463d4cca0068750eb6af7b4b54eea8599b"}, 144 | {'blob', "f534deb63f967cddd4bd440d05d3f6f075e55fca"}, 145 | {'blob', "275a4019807c7bb7bc80c0ca8903bf84345e1bdf"}, 146 | } 147 | for _,obj in ipairs(object_ids) do 148 | local oid = git2.OID.hex(obj[2]) 149 | --local obj, err = rep:lookup(oid, obj[1]) 150 | local obj, err = db:read(oid) 151 | print('read', obj, err) 152 | print() 153 | end 154 | 155 | db = nil 156 | backend = nil 157 | obj_cache = nil 158 | 159 | collectgarbage"collect" 160 | collectgarbage"collect" 161 | collectgarbage"collect" 162 | 163 | 164 | print() 165 | print() 166 | print("finished") 167 | 168 | -------------------------------------------------------------------------------- /tests/test_rep.git.tbz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libgit2/luagit2/5440a5e9a620e19e69a5d9b2d34e2190e9767f4a/tests/test_rep.git.tbz -------------------------------------------------------------------------------- /tests/test_rep.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | 3 | local build_dir = arg[1] 4 | local git_path = arg[2] or "./tests/test_rep/.git" 5 | -- Make it easier to test 6 | if ( build_dir ) then 7 | package.cpath = build_dir .. "?.so;" .. package.cpath 8 | end 9 | 10 | local git2 = require"git2" 11 | require"utils" 12 | 13 | print("dump git2 interface") 14 | -- print(dbg_dump(git2)) 15 | 16 | local rep = assert(git2.Repository(git_path)) 17 | 18 | print("dump Repository interface") 19 | -- print(dbg_dump(rep)) 20 | 21 | local oid = git2.OID.hex("d5a93c463d4cca0068750eb6af7b4b54eea8599b") 22 | print("dump OID interface") 23 | -- print(dbg_dump(oid)) 24 | print('convert OID value to string = <' .. tostring(oid) .. '>') 25 | 26 | local db = rep:odb() 27 | print("dump Database interface") 28 | -- print(dbg_dump(db)) 29 | 30 | print() 31 | print('test writing to the object database:') 32 | local oid, err = db:write("any ol content will do", 'blob') 33 | print(oid, err) 34 | 35 | print("read written object out of the database.") 36 | local odb_obj = db:read(oid) 37 | print() 38 | print("dump OdbObject interface") 39 | -- print(dbg_dump(odb_obj)) 40 | local function dump_odb_obj(obj) 41 | -- check obj type 42 | if obj == nil or not tostring(obj):match('^OdbObject: ') then 43 | print('dump invalid OdbObject: ', obj) 44 | return 45 | end 46 | print('dump OdbObject:', obj) 47 | print('oid = ', obj:id()) 48 | print('data = "' .. tostring(obj:data()) .. '"') 49 | print('size = ', obj:size()) 50 | print('type = ', obj:type()) 51 | end 52 | print() 53 | print("dump OdbObject info:") 54 | dump_odb_obj(odb_obj) 55 | 56 | print() 57 | print("test closing of OdbObject:") 58 | odb_obj:free() 59 | dump_odb_obj(odb_obj) 60 | 61 | print() 62 | print("test reading OdbObjects from database:") 63 | local object_ids = { 64 | {'tree', "31f3d5703ce27f0b63c3eb0d829abdc95b51deae"}, 65 | {'commit', "d5a93c463d4cca0068750eb6af7b4b54eea8599b"}, 66 | {'blob', "f534deb63f967cddd4bd440d05d3f6f075e55fca"}, 67 | {'blob', "275a4019807c7bb7bc80c0ca8903bf84345e1bdf"}, 68 | } 69 | for _,obj in ipairs(object_ids) do 70 | local oid = git2.OID.hex(obj[2]) 71 | local odb_obj, err = db:read(oid) 72 | print() 73 | print(odb_obj, err) 74 | dump_odb_obj(odb_obj) 75 | end 76 | 77 | 78 | local commit_id = git2.OID.hex("d5a93c463d4cca0068750eb6af7b4b54eea8599b") 79 | print() 80 | print("test parsing a commit object: ", commit_id) 81 | local commit1, err = git2.Commit.lookup(rep, commit_id) 82 | print(commit1, err) 83 | print("dump Commit interface") 84 | --print(dbg_dump(commit1)) 85 | local function dump_signature(pre, sig) 86 | print(pre .. '.name = ', sig:name()) 87 | print(pre .. '.email = ', sig:email()) 88 | print(pre .. '.when = ', sig:when()) 89 | end 90 | local function dump_blob(blob) 91 | print("dump Blob interface") 92 | --print(dbg_dump(blob)) 93 | print('blob.rawcontent.size =', blob:rawsize()) 94 | print('blob.rawcontents =', blob:rawcontent()) 95 | end 96 | local function dump_tree_entry(entry) 97 | if entry == nil then 98 | return 99 | end 100 | print('tree_entry.id = ', entry:id()) 101 | print('tree_entry.name = ', entry:name()) 102 | print('tree_entry.attributes = ', string.format('0x%08X', entry:attributes())) 103 | local obj = entry:object(rep) 104 | print('tree_entry.object = ', obj) 105 | if obj:type() == 'blob' then 106 | dump_blob(obj) 107 | end 108 | end 109 | local function dump_tree(tree) 110 | if tree == nil then 111 | return 112 | end 113 | print('id = ', tree:id()) 114 | local cnt = tree:entrycount() 115 | print('entrycount = ', cnt) 116 | for i=0,cnt-1 do 117 | local entry = tree:entry_byindex(i) 118 | print('entry:', entry) 119 | dump_tree_entry(entry) 120 | end 121 | end 122 | local function dump_commit(commit) 123 | if commit == nil then 124 | return 125 | end 126 | print('message_encoding = ', commit:message_encoding()) 127 | print('message = ', commit:message()) 128 | print('time = ', commit:time()) 129 | print('tree = ', commit:tree()) 130 | dump_tree(commit:tree()) 131 | dump_signature('committer', commit:committer()) 132 | dump_signature('author', commit:author()) 133 | local cnt = commit:parentcount() 134 | print('parentcount = ', cnt) 135 | for i=0,cnt-1 do 136 | local parent = commit:parent(i) 137 | print('parent:', parent) 138 | dump_commit(parent) 139 | end 140 | end 141 | dump_commit(commit1) 142 | 143 | local index = rep:index() 144 | print("dump Index interface") 145 | --print(dbg_dump(index)) 146 | local function dump_index_entry(entry) 147 | if entry == nil then 148 | return 149 | end 150 | print(' idx.entry.ctime = ', entry:ctime()) 151 | print(' idx.entry.mtime = ', entry:mtime()) 152 | print(' idx.entry.dev = ', entry:dev()) 153 | print(' idx.entry.ino = ', entry:ino()) 154 | print(' idx.entry.mode = ', entry:mode()) 155 | print(' idx.entry.uid = ', entry:uid()) 156 | print(' idx.entry.gid = ', entry:gid()) 157 | print(' idx.entry.file_size = ', entry:file_size()) 158 | print(' idx.entry.oid = ', entry:oid()) 159 | print(' idx.entry.flags = ', string.format('0x%08X', entry:flags())) 160 | print(' idx.entry.flags_extended = ', string.format('0x%08X', entry:flags_extended())) 161 | print(' idx.entry.path = ', entry:path()) 162 | end 163 | local function dump_index(index) 164 | if index == nil then 165 | return 166 | end 167 | local cnt = index:entrycount() 168 | print('entrycount = ', cnt) 169 | for i=0,cnt-1 do 170 | local entry = index:get(i) 171 | print('entry:', entry) 172 | dump_index_entry(entry) 173 | end 174 | end 175 | print('index:read():', index:read()) 176 | dump_index(index) 177 | 178 | local revwalk = git2.RevWalk(rep) 179 | print("dump RevWalk interface") 180 | --print(dbg_dump(revwalk)) 181 | print('sorting:', revwalk:sorting(revwalk.SORT_TOPOLOGICAL + revwalk.SORT_REVERSE)) 182 | local head_id = git2.OID.hex("5c697d74eb692d650799ca1b0a10254d7130953d") 183 | local head = assert(git2.Commit.lookup(rep, head_id)) 184 | print('push:', revwalk:push(head_id)) 185 | assert(revwalk:repository() == rep) 186 | 187 | local commit_oid = revwalk:next() 188 | while (commit_oid ~= nil) do 189 | dump_commit(assert(git2.Commit.lookup(rep, commit_oid))) 190 | -- get next commit 191 | commit_oid = revwalk:next() 192 | end 193 | 194 | local tag_id = git2.OID.hex('82dfe36284d77b608ccc9d96e0ffa5782cb7c835') 195 | local tag = git2.Tag.lookup(rep, tag_id) 196 | print("dump Tag interface") 197 | --print(dbg_dump(tag)) 198 | local function dump_tag(tag) 199 | if tag == nil then 200 | return 201 | end 202 | print('name = ', tag:name()) 203 | dump_signature('tagger', tag:tagger()) 204 | print('message = ', tag:message()) 205 | local obj = tag:target() 206 | print('target = ', obj) 207 | end 208 | dump_tag(tag) 209 | 210 | 211 | revwalk = nil 212 | head = nil 213 | commit = nil 214 | commit1 = nil 215 | index = nil 216 | rep = nil 217 | db = nil 218 | 219 | collectgarbage"collect" 220 | collectgarbage"collect" 221 | collectgarbage"collect" 222 | 223 | 224 | print() 225 | print() 226 | print("finished") 227 | 228 | -------------------------------------------------------------------------------- /utils.lua: -------------------------------------------------------------------------------- 1 | -- Copyright (c) 2010 by Robert G. Jakabosky 2 | -- 3 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 4 | -- of this software and associated documentation files (the "Software"), to deal 5 | -- in the Software without restriction, including without limitation the rights 6 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | -- copies of the Software, and to permit persons to whom the Software is 8 | -- furnished to do so, subject to the following conditions: 9 | -- 10 | -- The above copyright notice and this permission notice shall be included in 11 | -- all copies or substantial portions of the Software. 12 | -- 13 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | -- THE SOFTWARE. 20 | 21 | function dump_meta_recur(seen, obj, depth, dbg) 22 | local meta = getmetatable(obj) 23 | if meta == nil then return '' end 24 | local out = ', mt: ' .. tostring(meta) .. ' ' 25 | -- check if this metatable has been seen already. 26 | if seen[meta] then 27 | return out .. tostring(meta) 28 | end 29 | return out .. dump_recur(seen, meta, depth, dbg) 30 | end 31 | 32 | function dump_recur(seen, obj, depth, dbg) 33 | local t = type(obj) 34 | -- if not a table just convert to string. 35 | if t ~= "table" then 36 | local out 37 | if t == "string" then 38 | out = '"' .. obj .. '"' 39 | else 40 | out = tostring(obj) 41 | if dbg == 1 then 42 | out = out .. dump_meta_recur(seen, obj, depth, dbg) 43 | end 44 | end 45 | return out 46 | end 47 | -- check if table has a __tostring metamethod. 48 | if dbg ~= 1 then 49 | local m = getmetatable(obj) 50 | if m then 51 | local tostr = m.__tostring 52 | if tostr then 53 | out = '"' .. tostr(obj) .. '"' 54 | return out 55 | end 56 | end 57 | end 58 | -- check if this table has been seen already. 59 | if seen[obj] then 60 | return "Already dumped " .. tostring(obj) 61 | end 62 | seen[obj] = true 63 | -- restrict max depth. 64 | if depth >= 10 then 65 | return "{... max depth reached ...}" 66 | end 67 | depth = depth + 1 68 | -- output table key/value pairs 69 | local tabs = string.rep(" ",depth) 70 | local out 71 | if dbg == 1 then 72 | out = tostring(obj) .. " {\n" 73 | else 74 | out = "{\n" 75 | end 76 | for k,v in pairs(obj) do 77 | if type(k) ~= "number" then 78 | out = out .. tabs .. '[' .. dump_recur(seen, k, depth, dbg) .. '] = ' .. 79 | dump_recur(seen, v, depth, dbg) .. ',\n' 80 | else 81 | out = out .. tabs .. '[' .. k .. '] = ' .. dump_recur(seen, v, depth, dbg) .. ',\n' 82 | end 83 | end 84 | out = out .. tabs:sub(1,-3) .. "}" 85 | if dbg == 1 then 86 | out = out .. dump_meta_recur(seen, obj, depth, dbg) 87 | end 88 | return out 89 | end 90 | 91 | function dbg_dump(obj) 92 | local seen = {} 93 | return dump_recur(seen, obj, 0, 1) 94 | end 95 | 96 | function dump(obj) 97 | local seen = {} 98 | return dump_recur(seen, obj, 0, 0) 99 | end 100 | 101 | local function sizeof2(size, test, ...) 102 | collectgarbage"collect" 103 | size= collectgarbage"count"*1024 - size 104 | print("used size: " .. size) 105 | return size, ... 106 | end 107 | 108 | function sizeof(test, ...) 109 | local size=0 110 | if type(test) == "string" then 111 | test=assert(loadstring(test)) 112 | end 113 | collectgarbage"collect" 114 | size=collectgarbage"count"*1024 115 | return sizeof2(size, test, test(...)) 116 | end 117 | 118 | --------------------------------------------------------------------------------