How to get gix::objs::Tree
from repo.head_commit()
?
#795
-
Hi, thank you for your awesome work! I'm trying to write a git server with gitoxide, and I'd like to allow user upload a file in web page. I learned your example here and wrote code like this: use gix::{
objs::{tree, Tree},
ThreadSafeRepository,
};
...
let mut repo = self.repo.to_thread_local();
let blob_id = repo.write_blob(data)?.into();
let entry = tree::Entry {
mode: tree::EntryMode::Blob,
oid: blob_id,
filename: filename.as_ref().to_owned().into(),
};
let tree = repo.head_commit()?.tree()?; // <- this `tree` is gix::Tree, which is not same as gix::objs::Tree.
//tree.entries.push(entry);
//let new_tree_id = repo.write_object(tree);
//repo.commit(...) I'm trying to find something to convert two different What should I do to implement this? Thanks for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thanks for making me aware. Creating trees for commits indeed is a very manual process right now, and would you are trying to do should definitely be supported. That said, in I hope that helps. |
Beta Was this translation helpful? Give feedback.
Thanks for making me aware. Creating trees for commits indeed is a very manual process right now, and would you are trying to do should definitely be supported.
That said, in
main
you will now find 7c2e5c8d08e4dd1ec115ae06f20f9c8f93d6d616 which makes it possible to turn agix::Tree
into agix::objs::Tree
withtree.try_into()
.I hope that helps.