Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libGitWrap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ SET( SRC_FILES
Object.cpp
ObjectId.cpp
PatchConsumer.cpp
RefLog.cpp
RefName.cpp
RefSpec.cpp
Reference.cpp
Expand Down Expand Up @@ -186,6 +187,7 @@ SET( PUB_HDR_FILES
ObjectTag.hpp
ObjectTree.hpp
PatchConsumer.hpp
RefLog.hpp
RefName.hpp
RefSpec.hpp
Reference.hpp
Expand Down Expand Up @@ -226,6 +228,8 @@ SET( PRI_HDR_FILES
Private/ObjectPrivate.hpp
Private/NoteRefPrivate.hpp
Private/ReferencePrivate.hpp
Private/RefLogPrivate.hpp
Private/RefLogEntryPrivate.hpp
Private/RefNamePrivate.hpp
Private/RemotePrivate.hpp
Private/RepoObjectPrivate.hpp
Expand Down
3 changes: 3 additions & 0 deletions libGitWrap/GitWrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ namespace Git
class Tree;
class PatchConsumer;
class RefName;
class RefLog;
class RefLogEntry;
class RefSpec;
class Reference;
class Remote;
class Repository;
class RevisionWalker;
class Signature;
class Submodule;
class TreeBuilder;
class TreeEntry;
Expand Down
48 changes: 48 additions & 0 deletions libGitWrap/Private/RefLogEntryPrivate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* MacGitver
* Copyright (C) 2014 The MacGitver-Developers <[email protected]>
*
* (C) Nils Fenner <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License (Version 2) as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef GITWRAP_REFLOGENTRY_HPP
#define GITWRAP_REFLOGENTRY_HPP

#include "libGitWrap/Private/BasePrivate.hpp"

namespace Git
{
namespace Internal
{

/**
* @internal
* @ingroup GitWrap
*
* @brief Internal wrapper for git_reflog_entry from libgit2.
*/
class RefLogEntryPrivate : public BasePrivate
{
public:
explicit RefLogEntryPrivate(const git_reflog_entry *entry);
~RefLogEntryPrivate();

public:
const git_reflog_entry * mEntry;
};
}
}

#endif // REFLOGENTRY_HPP

46 changes: 46 additions & 0 deletions libGitWrap/Private/RefLogPrivate.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* libGitWrap - A Qt wrapper library for libgit2
* Copyright (C) 2012-2013 The MacGitver-Developers <[email protected]>
*
* (C) Sascha Cunz <[email protected]>
* (C) Cunz RaD Ltd.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License (Version 2) as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef GIT_REF_LOG_PRIVATE_HPP
#define GIT_REF_LOG_PRIVATE_HPP

#include "libGitWrap/Private/RepoObjectPrivate.hpp"

namespace Git
{

namespace Internal
{

class RefLogPrivate : public RepoObjectPrivate
{
public:
RefLogPrivate( RepositoryPrivate* repo, git_reflog* _reflog );
RefLogPrivate( const RepositoryPrivate::Ptr& repo, git_reflog* _reflog );
~RefLogPrivate();

public:
git_reflog* reflog;
};

}

}

#endif
2 changes: 0 additions & 2 deletions libGitWrap/Private/RepoObjectPrivate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
#ifndef GIT_REPO_OBJECT_H
#define GIT_REPO_OBJECT_H

#include "libGitWrap/Base.hpp"

#include "libGitWrap/Private/BasePrivate.hpp"
#include "libGitWrap/Private/RepositoryPrivate.hpp"

Expand Down
138 changes: 138 additions & 0 deletions libGitWrap/RefLog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*
* libGitWrap - A Qt wrapper library for libgit2
* Copyright (C) 2012-2013 The MacGitver-Developers <[email protected]>
*
* (C) Sascha Cunz <[email protected]>
* (C) Cunz RaD Ltd.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License (Version 2) as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, see <http://www.gnu.org/licenses/>.
*
*/

#include "libGitWrap/RefLog.hpp"

#include "libGitWrap/Private/GitWrapPrivate.hpp"
#include "libGitWrap/Private/RefLogPrivate.hpp"
#include "libGitWrap/Private/RefLogEntryPrivate.hpp"

namespace Git
{

namespace Internal
{

//-- RefLogEntryPrivate -->8

RefLogEntryPrivate::RefLogEntryPrivate(const git_reflog_entry* entry)
: mEntry( entry )
{
}

RefLogEntryPrivate::~RefLogEntryPrivate()
{
}


//-- RefLogPrivate -->8

RefLogPrivate::RefLogPrivate( RepositoryPrivate *repo, git_reflog *_reflog )
: RepoObjectPrivate( repo )
, reflog( _reflog )
{
}

RefLogPrivate::RefLogPrivate( const RepositoryPrivate::Ptr& repo, git_reflog* _reflog )
: RepoObjectPrivate(repo)
, reflog( _reflog )
{
}

RefLogPrivate::~RefLogPrivate()
{
git_reflog_free(reflog);
}

}


//-- RefLogEntry -->8

GW_PRIVATE_IMPL(RefLogEntry, Base)

Signature RefLogEntry::committer() const
{
GW_CD(RefLogEntry);
const git_signature * sig = git_reflog_entry_committer( d->mEntry );
return Internal::git2Signature( sig );
}

QString RefLogEntry::message() const
{
GW_CD(RefLogEntry);
return GW_StringToQt( git_reflog_entry_message( d->mEntry ) );
}

ObjectId RefLogEntry::oidOld() const
{
GW_CD(RefLogEntry);
const git_oid *id = git_reflog_entry_id_old( d->mEntry );
return id ? ObjectId::fromRaw( id->id ) : ObjectId();
}

ObjectId RefLogEntry::oidNew() const
{
GW_CD(RefLogEntry);
const git_oid *id = git_reflog_entry_id_new( d->mEntry );
return id ? ObjectId::fromRaw( id->id ) : ObjectId();
}


//-- RefLog -->8

GW_PRIVATE_IMPL(RefLog, RepoObject)

int RefLog::count()
{
GW_CD(RefLog);
return git_reflog_entrycount( d->reflog );
}

RefLogEntry RefLog::at(int index) const
{
GW_CD( RefLog );

const git_reflog_entry *entry = git_reflog_entry_byindex( d->reflog, index);
Q_ASSERT( entry );

return new RefLogEntry::Private(entry);
}

void RefLog::write(Git::Result& result) const
{
GW_CD_CHECKED(RefLog, void(), result);

result = git_reflog_write( d->reflog );
}

RefLog RefLog::read( Result &result, const Repository& repo, const QString& refName )
{
GW_CHECK_RESULT(result, RefLog());

Repository::Private* rp = Private::dataOf<Repository>(repo);

git_reflog *out = NULL;
result = git_reflog_read( &out, rp->mRepo, GW_StringFromQt(refName) );
GW_CHECK_RESULT( result, RefLog() );

return new RefLog::Private( rp, out );
}

}
65 changes: 65 additions & 0 deletions libGitWrap/RefLog.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* libGitWrap - A Qt wrapper library for libgit2
* Copyright (C) 2012-2013 The MacGitver-Developers <[email protected]>
*
* (C) Sascha Cunz <[email protected]>
* (C) Cunz RaD Ltd.
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License (Version 2) as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, see <http://www.gnu.org/licenses/>.
*
*/

#ifndef GIT_REFLOG_HPP
#define GIT_REFLOG_HPP

#include "libGitWrap/Base.hpp"
#include "libGitWrap/Signature.hpp"
#include "libGitWrap/ObjectId.hpp"
#include "libGitWrap/RepoObject.hpp"

namespace Git
{

namespace Internal
{
class RefLogPrivate;
class RefLogEntryPrivate;
}

class GITWRAP_API RefLogEntry : public Base
{
GW_PRIVATE_DECL(RefLogEntry, Base, public)

public:
Signature committer() const;
QString message() const;
ObjectId oidOld() const;
ObjectId oidNew() const;
};

class GITWRAP_API RefLog : public RepoObject
{
GW_PRIVATE_DECL( RefLog, RepoObject, public )

public:
int count();
RefLogEntry at(int index) const;

public:
void write(Result &result) const;

public:
static RefLog read(Result& result, const Repository& repo, const QString& refName);
};

}

#endif
2 changes: 2 additions & 0 deletions libGitWrap/Signature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace Git

Signature git2Signature( const git_signature* gitsig )
{
Q_ASSERT( gitsig );

QDateTime dt = QDateTime::fromTime_t( gitsig->when.time );
dt.setUtcOffset( gitsig->when.offset * 60 );

Expand Down