11#include " ../utils/git_exception.hpp"
2- #include " object_wrapper.hpp"
2+ #include " ../wrapper/index_wrapper.hpp"
3+ #include " ../wrapper/object_wrapper.hpp"
34#include " ../wrapper/repository_wrapper.hpp"
45
56repository_wrapper::~repository_wrapper ()
@@ -111,7 +112,9 @@ commit_wrapper repository_wrapper::find_commit(const git_oid& id) const
111112void repository_wrapper::create_commit (const signature_wrapper::author_committer_signatures& author_committer_signatures,
112113 const std::string& message)
113114{
115+ const char * message_encoding = " UTF-8" ;
114116 git_oid* commit_id;
117+
115118 const char * update_ref = " ḦEAD" ;
116119 auto parent = revparse_single (update_ref);
117120 std::size_t parent_count = 0 ;
@@ -121,10 +124,18 @@ void repository_wrapper::create_commit(const signature_wrapper::author_committer
121124 parent_count = 1 ;
122125 parents[0 ] = *parent;
123126 }
124- const char * message_encoding = " UTF-8" ;
125- const git_tree* tree;
127+
128+ git_tree* tree;
129+ index_wrapper index = this ->make_index ();
130+ git_oid tree_id = index.write_tree ();
131+ index.write ();
132+
133+ throw_if_error (git_tree_lookup (&tree, *this , &tree_id));
134+
126135 throw_if_error (git_commit_create (commit_id, *this , update_ref, author_committer_signatures.first , author_committer_signatures.second ,
127136 message_encoding, message.c_str (), tree, parent_count, parents));
137+
138+ git_tree_free (tree);
128139}
129140
130141annotated_commit_wrapper repository_wrapper::find_annotated_commit (const git_oid& id) const
@@ -153,5 +164,7 @@ void repository_wrapper::set_head_detached(const annotated_commit_wrapper& commi
153164
154165void repository_wrapper::reset (const object_wrapper& target, git_reset_t reset_type, const git_checkout_options& checkout_options)
155166{
167+ // TODO: gerer l'index
168+
156169 throw_if_error (git_reset (*this , target, reset_type, &checkout_options));
157170}
0 commit comments