diff --git a/test/unitTest/conversationRepository/conversationRepository.cpp b/test/unitTest/conversationRepository/conversationRepository.cpp
index ca696329c8b08074bef0db5313cf09c598961d01..0a3f74cc3f6d1900c12fdc285ad28d2177213713 100644
--- a/test/unitTest/conversationRepository/conversationRepository.cpp
+++ b/test/unitTest/conversationRepository/conversationRepository.cpp
@@ -294,7 +294,12 @@ ConversationRepositoryTest::addCommit(git_repository* repo,
     GitTree tree = {tree_ptr, git_tree_free};
 
     git_buf to_sign = {};
+#if( LIBGIT2_VER_MAJOR > 1 ) || ( LIBGIT2_VER_MAJOR == 1 && LIBGIT2_VER_MINOR >= 8 )
+    // For libgit2 version 1.8.0 and above
+    git_commit* const head_ref[1] = {head_commit.get()};
+#else
     const git_commit* head_ref[1] = {head_commit.get()};
+#endif
     if (git_commit_create_buffer(&to_sign,
                                  repo,
                                  sig.get(),