librelist archives

« back to archive

Change Tree|Custom backend

Change Tree|Custom backend

From:
Дмитрий Ковега
Date:
2011-04-04 @ 09:34
Hi,

I'm trying to work with bare repo. Using api I can find blob and it's 
parent tree, when i create new blob, but i can't find simple way of 
changing content of existing tree or creating tree. If I right 
understand, i should create buffer like this:
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    file1
100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file2
And when call git_odb_write?

Also i write redis backend and use sqlite backend as an example. Sqlite 
backend doesn't have wstream/rstream methods, but this methods are 
necessary(?) for normal work (e.g git_blob_create_frombuffer) and 
priority doesn't help in this case.

Please correct me. Thanks.

--
Dmitry Kovega

Re: [libgit2] Change Tree|Custom backend

From:
Vicent Marti
Date:
2011-04-04 @ 09:45
Hey Dmitry,

2011/4/4 Дмитрий Ковега <arhibot@yandex-team.ru>:
> I'm trying to work with bare repo. Using api I can find blob and it's
> parent tree, when i create new blob, but i can't find simple way of
> changing content of existing tree or creating tree. If I right
> understand, i should create buffer like this:
> 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    file1
> 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file2
> And when call git_odb_write?

No -- we had to drop support for writing trees when we overhauled the
external API to make it threadsafe, but it's coming back very soon
(read: this afternoon). I've just finished fixing up the support for
writing an index as a tree, and now I'm gonna start working on writing
custom trees from memory.

>
> Also i write redis backend and use sqlite backend as an example. Sqlite
> backend doesn't have wstream/rstream methods, but this methods are
> necessary(?) for normal work (e.g git_blob_create_frombuffer) and
> priority doesn't help in this case.

Right now, some of the object write methods rely on on a wstream to
write. This includes commit, tag and blob writing, so these will not
work if your backend doesn't support streaming writes. I'm going to
write to a generic `wstream` object that will build the stream in
memory and then write it directly to backends that don't support
streaming writes. I'll keep you up to date.

Cheers,
Vicent

Re: [libgit2] Change Tree|Custom backend

From:
Vicent Marti
Date:
2011-04-04 @ 10:15
Update:

https://github.com/libgit2/libgit2/commit/d69d0185d147a435e2851b1d9f38dddc838959f9

This should fix your issues with the redis backend; just implement a
normal `write` callback and libgit2 will take care of everything.
Cheers!

2011/4/4 Vicent Marti <vicent@github.com>:
> Hey Dmitry,
>
> 2011/4/4 Дмитрий Ковега <arhibot@yandex-team.ru>:
>> I'm trying to work with bare repo. Using api I can find blob and it's
>> parent tree, when i create new blob, but i can't find simple way of
>> changing content of existing tree or creating tree. If I right
>> understand, i should create buffer like this:
>> 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391    file1
>> 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5392    file2
>> And when call git_odb_write?
>
> No -- we had to drop support for writing trees when we overhauled the
> external API to make it threadsafe, but it's coming back very soon
> (read: this afternoon). I've just finished fixing up the support for
> writing an index as a tree, and now I'm gonna start working on writing
> custom trees from memory.
>
>>
>> Also i write redis backend and use sqlite backend as an example. Sqlite
>> backend doesn't have wstream/rstream methods, but this methods are
>> necessary(?) for normal work (e.g git_blob_create_frombuffer) and
>> priority doesn't help in this case.
>
> Right now, some of the object write methods rely on on a wstream to
> write. This includes commit, tag and blob writing, so these will not
> work if your backend doesn't support streaming writes. I'm going to
> write to a generic `wstream` object that will build the stream in
> memory and then write it directly to backends that don't support
> streaming writes. I'll keep you up to date.
>
> Cheers,
> Vicent
>