File indexing completed on 2024-04-28 16:01:31

0001 /******************************************************************************
0002  * This file is part of the libqgit2 library
0003  * Copyright (c) 2011 Laszlo Papp <djszapi@archlinux.us>
0004  * Copyright (C) 2013 Leonardo Giordani
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #include "qgitdatabase.h"
0022 
0023 #include "private/pathcodec.h"
0024 
0025 namespace LibQGit2
0026 {
0027 
0028 Database::Database(git_odb *odb)
0029     : m_database(odb)
0030 {
0031 }
0032 
0033 Database::Database( const Database& other )
0034 {
0035     m_database = other.m_database;
0036 }
0037 
0038 Database::~Database()
0039 {
0040 }
0041 
0042 int Database::open(const QString& objectsDir)
0043 {
0044     return git_odb_open(&m_database, PathCodec::toLibGit2(objectsDir));
0045 }
0046 
0047 void Database::close()
0048 {
0049     return git_odb_free(m_database);
0050 }
0051 
0052 int Database::addBackend(DatabaseBackend *backend, int priority)
0053 {
0054     return git_odb_add_backend(m_database, (git_odb_backend *)backend, priority);
0055 }
0056 
0057 int Database::addAlternate(DatabaseBackend *backend, int priority)
0058 {
0059     return git_odb_add_alternate(m_database, (git_odb_backend *)backend, priority);
0060 }
0061 
0062 int Database::exists(Database *db, const OId& id)
0063 {
0064     return git_odb_exists(db->data(), id.constData());
0065 }
0066 
0067 git_odb* Database::data() const
0068 {
0069     return m_database;
0070 }
0071 
0072 const git_odb* Database::constData() const
0073 {
0074     return m_database;
0075 }
0076 
0077 } // namespace LibQGit2