Skip to content

Commit 4515f64

Browse files
committed
Fix issue with ODB backend write method.
1 parent 9a9a025 commit 4515f64

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

src/odb_backend.nobj.lua

+4-11
Original file line numberDiff line numberDiff line change
@@ -154,27 +154,20 @@ static int odb_backend_write_cb(git_odb_backend *backend, const git_oid *oid, co
154154
{
155155
ODBBackend *lua_backend = (ODBBackend *)backend;
156156
lua_State *L = lua_backend->L;
157-
int err;
158157
159158
/* get Lua callback function. */
160159
lua_rawgeti(L, LUA_REGISTRYINDEX, lua_backend->write);
161160
161+
/* push oid */
162+
obj_type_OID_push(L, *((OID *)oid));
162163
/* push data onto stack. */
163164
lua_pushlstring(L, data, len);
164165
/* push otype */
165166
lua_pushstring(L, git_object_type2string(type));
166167
167168
/* call Lua function. */
168-
lua_call(L, 2, 2);
169-
// TODO: this is bork
170-
if(!lua_isnil(L, -2)) {
171-
//*oid = obj_type_OID_check(L,-2);
172-
err = GIT_OK;
173-
} else {
174-
err = lua_tointeger(L, -1);
175-
}
176-
177-
return err;
169+
lua_call(L, 3, 1);
170+
return lua_tointeger(L, -1);
178171
}
179172
180173
static int odb_backend_exists_cb(git_odb_backend *backend, const git_oid *oid)

tests/test_backend.lua

+2-3
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,8 @@ on_read_header = function(oid)
7070
end
7171
return obj.len, obj.otype
7272
end,
73-
on_write = function(data, otype)
74-
local oid = git2.ODB.hash(data, git2.Object.string2type(otype))
75-
print("------------------- write callback:", data, otype)
73+
on_write = function(oid, data, otype)
74+
print("------------------- write callback:", oid, data, otype)
7675
if not oid then
7776
return nil, -1
7877
end

0 commit comments

Comments
 (0)