Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Refactor'n'Feature #48

Merged
merged 68 commits into from
Nov 10, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
ef90d94
Fix some includes
scunz Oct 30, 2013
e9bc790
Allow to set GitWrap specific errors
scunz Oct 30, 2013
186f99f
Convert ObjectType/git_otype additions
scunz Oct 30, 2013
82d4884
Fix part of the const-ness mess
scunz Oct 30, 2013
8ea16b5
Add internal helper to access a Object's git_object
scunz Oct 30, 2013
befbca5
Add setters to set the HEAD
scunz Oct 30, 2013
ed88799
Reference: Add isBranch()
scunz Oct 30, 2013
6549286
Reference: add peeling references
scunz Oct 30, 2013
ac3aee8
Reference: Set this reference as HEAD
scunz Oct 30, 2013
76a3624
git_strarray wrapper for external git_strarrays
scunz Oct 30, 2013
3b06607
Change use of StrArrayWrapper to StrArray where applicable
scunz Oct 30, 2013
b9c2c66
Use setAsHEAD() instead of updateHEAD()
scunz Oct 30, 2013
f6631d1
Deleted references cannot be used anymore
scunz Oct 30, 2013
78dea52
Fix return value of Reference::wasDeleted()
scunz Oct 30, 2013
eb354b0
Add Repository::reopen()
scunz Oct 30, 2013
a7b4a1e
Object/Reference: Add some nice template magic
scunz Oct 31, 2013
65b0da1
Lots of refactoring...
scunz Oct 31, 2013
6f032f4
Remove Object from class name of Blob, Commit, Tag and Tree
scunz Oct 31, 2013
2fb23e1
A bigger refactoring
scunz Nov 1, 2013
0657ff6
Implement checkout as suggested
scunz Nov 1, 2013
7cc84f6
Split CloneOperation into Base and Clone Operations
scunz Nov 2, 2013
0eef916
minor compile and indent fixes
antis81 Nov 2, 2013
403f467
Add FileInfo class
scunz Nov 2, 2013
6492884
TreeAttr => FileModes
scunz Nov 2, 2013
04a4187
Safer: Check for non-constness in d-ptr cast
scunz Nov 2, 2013
622fdf3
Get the constness somewhat correct...
scunz Nov 3, 2013
4a0a215
Checkout: Create a CheckoutOperation
scunz Nov 3, 2013
e56301c
Cleanup
scunz Nov 3, 2013
f1328a3
Make it compilable again.
scunz Nov 3, 2013
3607995
Fix linking
scunz Nov 3, 2013
3617c52
Create RefNamePrivate.hpp file
scunz Nov 3, 2013
6e9dc87
Unite RefName and Reference private data
scunz Nov 3, 2013
fec3c6a
Update RefName Data, if Reference changed too much
scunz Nov 3, 2013
b1e877a
Move Index' constructor operations to static methods
scunz Nov 3, 2013
e7830d8
redo IndexConflict's constructor as static method
scunz Nov 3, 2013
5caedc1
Replace construction completely with macro
scunz Nov 3, 2013
cb4cc3d
SMs: Adjust to rest of library
scunz Nov 4, 2013
c85f6f8
Repo: Add getter for sm-names and check sm existance
scunz Nov 4, 2013
2e8c1af
Remove requirement to open/close Sub-Repositories
scunz Nov 4, 2013
2ab0ccc
RefName: support refs/notes
scunz Nov 6, 2013
91e8dde
fixed extra semicolon warning
antis81 Nov 5, 2013
f7c4a0f
added empty class frames for TagRef, BranchRef and NoteRef
antis81 Nov 5, 2013
f747cbe
Basic implementation of Ref inheritance
scunz Nov 6, 2013
3af8645
RefName: Do normal analyze if custom matched
scunz Nov 6, 2013
c699d86
Implement Special-Ref construction
scunz Nov 6, 2013
4ff0d08
Implement Special-Refs factory
scunz Nov 6, 2013
e15e489
Privatify validiy check to static function
scunz Nov 6, 2013
aecb541
Use static/virtual validation checker
scunz Nov 6, 2013
adb8ff1
Deprecate methods using Results uselessly
scunz Nov 6, 2013
f4a76eb
Fix assert
scunz Nov 6, 2013
325fb5d
Fix Qt4 build
scunz Nov 6, 2013
a6f4498
Fix 1 testcase
scunz Nov 6, 2013
8494b29
Fix 1 testcase
scunz Nov 6, 2013
ad8e0f7
Readd *RefPrivate.hpp (Got removed in the merge)
scunz Nov 6, 2013
f6ed16c
ReferenceType and ReferenceKind
scunz Nov 6, 2013
789e72d
Reference casting
scunz Nov 6, 2013
eaa9a2a
Use Reference Object factory
scunz Nov 7, 2013
7377bc9
Base::operator!=
scunz Nov 7, 2013
4089c18
Don't force Repository::Private::Ptr everywhere
scunz Nov 7, 2013
a8a01a4
Deprecate Repository::lookupRef()
scunz Nov 7, 2013
6fd86f9
Lookup methods for BranchRef, TagRef and NoteRef
scunz Nov 7, 2013
90ff5bb
Initial copy code for CheckoutBranchOperation
scunz Nov 7, 2013
a81a44b
First part of getting this updateHEAD/setAsHEAD mess right
scunz Nov 7, 2013
ce94191
Repository::createRemote => Remote::create
scunz Nov 7, 2013
748a521
Allow "if (!foo)" where foo is a Git::Base object
scunz Nov 7, 2013
70be7aa
Repository::newWalker => RevisionWalker::create()
scunz Nov 7, 2013
9779fcd
Reference::setAsHEAD() => setAsDetachedHEAD()
scunz Nov 10, 2013
df58385
Make checkout work somewhat with some features omited
scunz Nov 10, 2013
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
)

#ADD_DEFINITIONS(-DGW_NO_DEPRECATION)

ADD_SUBDIRECTORY(libGitWrap)
ADD_SUBDIRECTORY(testGitWrap)

Expand Down
75 changes: 69 additions & 6 deletions libGitWrap/Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
*
*/

#include "Base.hpp"
#include "libGitWrap/Base.hpp"
#include "libGitWrap/Object.hpp"

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

namespace Git
{
Expand All @@ -35,9 +37,65 @@ namespace Git
{
}

const git_oid* BasePrivate::sha(const ObjectId& id)
git_object* BasePrivate::objectOf(const Object& o)
{
return reinterpret_cast<const git_oid*>(id.raw());
Object::Private* op = dataOf<Object>(o);

if (!op) {
return NULL;
}

return op->o();
}

/**
* @internal
* @brief Static private validity checker
*
* This is a private validity checker. It is used from the GW_D macro. Implementing it as a
* private static method, allows a lot of code reduction (resulting in isValid() being in
* the CPU cache and thus much less cache misses on code that uses GitWrap a lot).
*
* Also, this allows us to transparently delegate to the virtual method isValidObject(),
* which gives the object itself an opportunitiy to tell whether it is valid or not and also
* set a custom result.
*
* This is esp. useful since Reference objects can become invalid (when destroy() is used)
* and we cannot warrant that this will be checked in all methods of Reference derivates.
*
* @param[in,out] r A Result that will be set to invalid if @a d is `NULL` and can be
* set to anything, if @a d is not `NULL`.
*
* @param[in] d The BasePrivate to check.
*
* @return `true`, if this object can be treated as vaild.
*
*/
bool BasePrivate::isValid(Result& r, const BasePrivate* d)
{
if (Q_LIKELY(d)) {
return d->isValidObject(r);
}
r.setInvalidObject();
return false;
}

/**
* @internal
* @brief Check for validity
*
* @param[in,out] r A Result that can be used to tell the user about any problems with
* the object at hand.
*
* @return `true`, if this object is valid - `false` otherwise. Note, that by
* convention, the object is invalid if the Result @a r contains an error
* on input, thus this method should `return r;` whenever it wants to
* return `true` actually.
*
*/
bool BasePrivate::isValidObject(Result& r) const
{
return r;
}

}
Expand All @@ -46,8 +104,8 @@ namespace Git
{
}

Base::Base(Internal::BasePrivate &_d)
: mData(&_d)
Base::Base(const PrivatePtr& _d)
: mData(_d)
{
}

Expand All @@ -71,6 +129,11 @@ namespace Git
return mData == other.mData;
}

bool Base::operator!=(const Base& other) const
{
return mData != other.mData;
}

bool Base::isValid() const
{
return mData;
Expand Down
19 changes: 16 additions & 3 deletions libGitWrap/Base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,25 @@ namespace Git
Base(const Base& other);
virtual ~Base();
Base& operator=(const Base& other);
bool isValid() const;
bool operator==(const Base& other) const;
bool operator!=(const Base& other) const;

public:
bool isValid() const;

protected:
typedef QExplicitlySharedDataPointer<Internal::BasePrivate> PrivatePtr;
Base(const PrivatePtr& _d);
PrivatePtr mData;

protected:
Base(Internal::BasePrivate& _d);
QExplicitlySharedDataPointer<Internal::BasePrivate> mData;
inline void ensureThisIsNotConst()
{
// This method is invoked from the GW_D macro. Its only purpose is to error out at
// compile time, if we casted from a const outer object. This is actually neccessary
// because QExplicitlySharedDataPointer seems to give a shit about const
// correctness.
}
};

}
Expand Down
54 changes: 54 additions & 0 deletions libGitWrap/Blob.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* MacGitver
* Copyright (C) 2012-2013 Sascha Cunz <[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/>.
*
*/

#include "libGitWrap/Blob.hpp"

#include "libGitWrap/Private/GitWrapPrivate.hpp"
#include "libGitWrap/Private/BlobPrivate.hpp"

namespace Git
{

namespace Internal {

BlobPrivate::BlobPrivate(const RepositoryPrivate::Ptr& repo, git_blob* o)
: ObjectPrivate(repo, reinterpret_cast<git_object*>(o))
{
Q_ASSERT(o);
}

BlobPrivate::BlobPrivate(const RepositoryPrivate::Ptr& repo, git_object* o)
: ObjectPrivate(repo, o)
{
Q_ASSERT(o);
Q_ASSERT(git_object_type(o) == GIT_OBJ_BLOB);
}

git_otype BlobPrivate::otype() const
{
return GIT_OBJ_BLOB;
}

ObjectType BlobPrivate::objectType() const
{
return otBlob;
}

}

GW_PRIVATE_IMPL(Blob, Object)

}
37 changes: 26 additions & 11 deletions libGitWrap/ObjectBlob.cpp → libGitWrap/Blob.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,43 @@
*
*/

#include "ObjectBlob.hpp"
#ifndef GIT_OBJECT_BLOB_H
#define GIT_OBJECT_BLOB_H

#include "Private/GitWrapPrivate.hpp"
#include "libGitWrap/GitWrap.hpp"
#include "libGitWrap/ObjectId.hpp"
#include "libGitWrap/Object.hpp"

namespace Git
{

ObjectBlob::ObjectBlob()
namespace Internal
{

class BlobPrivate;

}

ObjectBlob::ObjectBlob(Internal::ObjectPrivate& _d)
: Object(_d)
/**
* @ingroup GitWrap
* @brief Provides access to git BLOB (Binary Large Object) objects
*
*/
class GITWRAP_API Blob : public Object
{
Result r;
Q_UNUSED( r );
Q_ASSERT( type(r) == otBlob );
}
public:
GW_PRIVATE_DECL(Blob, Object, public);
enum { ObjectTypeId = otBlob };
};

ObjectBlob::ObjectBlob(const ObjectBlob& o)
: Object(o)
template<>
inline Blob Object::as() const
{
return asBlob();
}

}

Q_DECLARE_METATYPE(Git::Blob)

#endif
55 changes: 55 additions & 0 deletions libGitWrap/BranchRef.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* MacGitver
* Copyright (C) 2012-2013 The MacGitver-Developers <[email protected]>
*
* (C) Sascha Cunz <[email protected]>
* (C) Nils Fenner <[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/BranchRef.hpp"
#include "libGitWrap/Private/BranchRefPrivate.hpp"

namespace Git
{

namespace Internal
{

BranchRefPrivate::BranchRefPrivate(const RepositoryPrivate::Ptr& repo,
git_reference* reference)
: ReferencePrivate(repo, reference)
{
#ifdef QT_DEBUG
// We want this constructor to analyze only for the assert...
ensureAnalyzed();
Q_ASSERT(isBranch);
#endif
}

BranchRefPrivate::BranchRefPrivate(git_reference* reference, const RefNamePrivate* refName)
: ReferencePrivate(reference, refName)
{
}

ReferenceKinds BranchRefPrivate::kind() const
{
return BranchReference;
}

}

GW_PRIVATE_IMPL(BranchRef, Reference)

}
53 changes: 53 additions & 0 deletions libGitWrap/BranchRef.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* MacGitver
* Copyright (C) 2012-2013 The MacGitver-Developers <[email protected]>
*
* (C) Sascha Cunz <[email protected]>
* (C) Nils Fenner <[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 GITWRAP_BRANCH_REF_HPP
#define GITWRAP_BRANCH_REF_HPP
#pragma once

#include "libGitWrap/Reference.hpp"

namespace Git
{

namespace Internal
{

class BranchRefPrivate;

}

class GITWRAP_API BranchRef : public Reference
{
GW_PRIVATE_DECL(BranchRef, Reference, public)

public:
};

template<>
inline BranchRef Reference::as() const {
return asBranch();
}

}

Q_DECLARE_METATYPE(Git::BranchRef)

#endif
Loading