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

fix and complete clone operation #60

Merged
merged 21 commits into from
Dec 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c0f9a8d
introduced the internal class CheckoutOptionsRef
antis81 Dec 8, 2014
c7c355f
fixed initialization of CloneOptions
antis81 Dec 8, 2014
15aa5c5
use our new CheckoutOptionsRef class to pass the checkout options to …
antis81 Dec 8, 2014
f70eda9
moved initialization of callbacks to constructor
antis81 Dec 8, 2014
478df25
cleanup
antis81 Dec 8, 2014
fb7cfac
introduced the ICheckoutEvents interface
antis81 Dec 9, 2014
e2e9d20
use CloneOperation as a provider for checkout events
antis81 Dec 9, 2014
8d4c047
cleanup
antis81 Dec 9, 2014
b1ccba1
renamed header file "IRemoteEvents.hpp" -> "IGitEvents.hpp" as it is …
antis81 Dec 24, 2014
3aea1e7
minor: fixed some copyright info
antis81 Dec 24, 2014
325cd8e
renamed cpp/hpp files RemoteCallbacks -> GitEventCallbacks as well an…
antis81 Dec 24, 2014
9a14858
added class DiffFile / DiffFilePrivate
antis81 Dec 24, 2014
4b77006
added class CheckoutNotify
antis81 Dec 24, 2014
712f835
implementation of event "checkoutNotify"
antis81 Dec 24, 2014
a3f4abe
prepare clone operation for "depths" and "remote-alias" parameters
antis81 Dec 25, 2014
25ce13a
CloneOperation: allow setting the reference to checkout
antis81 Dec 25, 2014
b3f8aed
added skeleton classes for remote operations fetch & push
antis81 Dec 28, 2014
fc55371
minor corrections
antis81 Dec 28, 2014
cd328b5
inherit CloneOperation from RemoteOperation
antis81 Dec 28, 2014
ebf8be5
completed implementation of FetchOperation
antis81 Dec 29, 2014
6b9e69f
Our PushOperation needs an update of libgit2.
antis81 Dec 29, 2014
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
11 changes: 7 additions & 4 deletions libGitWrap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,14 @@ SET( SRC_FILES
TreeBuilder.cpp
TreeEntry.cpp

Events/IRemoteEvents.cpp
Events/Private/RemoteCallbacks.cpp
Events/IGitEvents.cpp
Events/Private/GitEventCallbacks.cpp

Operations/BaseOperation.cpp
Operations/CheckoutOperation.cpp
Operations/CloneOperation.cpp
Operations/CommitOperation.cpp
Operations/RemoteOperations.cpp

Operations/Private/WorkerThread.cpp
)
Expand Down Expand Up @@ -209,8 +210,9 @@ SET( PUB_HDR_FILES
Operations/CloneOperation.hpp
Operations/CommitOperation.hpp
Operations/Providers.hpp
Operations/RemoteOperations.hpp

Events/IRemoteEvents.hpp
Events/IGitEvents.hpp
)

SET( PRI_HDR_FILES
Expand Down Expand Up @@ -242,11 +244,12 @@ SET( PRI_HDR_FILES
Private/TreeEntryPrivate.hpp
Private/TreePrivate.hpp

Events/Private/RemoteCallbacks.hpp
Events/Private/GitEventCallbacks.hpp

Operations/Private/BaseOperationPrivate.hpp
Operations/Private/CheckoutOperationPrivate.hpp
Operations/Private/CloneOperationPrivate.hpp
Operations/Private/RemoteOperationsPrivate.hpp
Operations/Private/WorkerThread.hpp
)

Expand Down
35 changes: 34 additions & 1 deletion libGitWrap/DiffList.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MacGitver
* Copyright (C) 2012-2013 Sascha Cunz <sascha@babbelbox.org>
* Copyright (C) 2014 Sascha Cunz <sascha@macgitver.org>
*
* 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.
Expand Down Expand Up @@ -52,6 +52,9 @@ namespace Git
return mChanges;
}


//-- DiffListPrivate -->8

DiffListPrivate::DiffListPrivate(const RepositoryPrivate::Ptr& repo, git_diff* diff)
: RepoObjectPrivate(repo)
, mDiff(diff)
Expand All @@ -68,6 +71,28 @@ namespace Git
}
}


//-- DiffFilePrivate -->8

DiffFilePrivate::DiffFilePrivate(const RepositoryPrivate::Ptr& repo, const git_diff_file* diffFile)
: RepoObjectPrivate(repo)
, mDiffFile( diffFile )
{
}

DiffFilePrivate::DiffFilePrivate(RepositoryPrivate* repo, const git_diff_file* diffFile)
: RepoObjectPrivate( repo )
, mDiffFile( diffFile )
{
}

DiffFilePrivate::~DiffFilePrivate()
{
}


//-- internal callbacks -->8

static int patchFileCallBack( const git_diff_delta* delta, float, void* cb_data )
{
PatchConsumer* pc = (PatchConsumer*) cb_data;
Expand Down Expand Up @@ -176,6 +201,14 @@ namespace Git

}


//-- DiffFile -->8

GW_PRIVATE_IMPL( DiffFile, RepoObject )


//-- DiffList -->8

GW_PRIVATE_IMPL(DiffList, RepoObject)

void DiffList::mergeOnto(Result& result, const DiffList& onto) const
Expand Down
13 changes: 13 additions & 0 deletions libGitWrap/DiffList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,22 @@ namespace Git

namespace Internal
{
class DiffFilePrivate;
class DiffListPrivate;
}


/**
* @ingroup GitWrap
*
* @brief The DiffFile class
*/
class GITWRAP_API DiffFile : public RepoObject
{
GW_PRIVATE_DECL( DiffFile, RepoObject, public )
};


/**
* @ingroup GitWrap
* @brief List of differences between to objects
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MacGitver
* Copyright (C) 2012-2013 Sascha Cunz <sascha@babbelbox.org>
* Copyright (C) 2014 Sascha Cunz <sascha@macgitver.org>
*
* 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.
Expand All @@ -14,13 +14,22 @@
*
*/

#include "libGitWrap/Events/IRemoteEvents.hpp"
#include "libGitWrap/Events/IGitEvents.hpp"

namespace Git
{

// -- IRemoteEvents ->8

IRemoteEvents::~IRemoteEvents()
{
}


// -- ICheckoutEvents ->8

ICheckoutEvents::~ICheckoutEvents()
{
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MacGitver
* Copyright (C) 2012-2013 Sascha Cunz <sascha@babbelbox.org>
* Copyright (C) 2014 Sascha Cunz <sascha@macgitver.org>
*
* 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.
Expand All @@ -14,17 +14,18 @@
*
*/

#ifndef GITWRAP_IREMOTE_EVENTS_HPP
#define GITWRAP_IREMOTE_EVENTS_HPP
#ifndef GITWRAP_IGIT_EVENTS_HPP
#define GITWRAP_IGIT_EVENTS_HPP
#pragma once

#include "libGitWrap/GitWrap.hpp"
#include "libGitWrap/ObjectId.hpp"

namespace Git
{

class CheckoutNotify;
class CredentialRequest;
class DiffFile;

class GITWRAP_API IRemoteEvents
{
Expand All @@ -46,6 +47,21 @@ namespace Git
const Git::ObjectId& to ) = 0;
};

class GITWRAP_API ICheckoutEvents
{
public:
virtual ~ICheckoutEvents();

public:
virtual void checkoutNotify( const CheckoutNotify& why,
const QString& path,
const DiffFile& baseline,
const DiffFile& target,
const DiffFile& workdir ) = 0;
virtual void checkoutProgress( const QString& path,
quint32 total,
quint32 completed ) = 0;
};
}

#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* MacGitver
* Copyright (C) 2012-2013 Sascha Cunz <sascha@babbelbox.org>
* Copyright (C) 2014 Sascha Cunz <sascha@macgitver.org>
*
* 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.
Expand All @@ -14,9 +14,12 @@
*
*/

#include "libGitWrap/Events/IRemoteEvents.hpp"
#include "libGitWrap/Events/IGitEvents.hpp"

#include "libGitWrap/Events/Private/RemoteCallbacks.hpp"
#include "libGitWrap/DiffList.hpp"

#include "libGitWrap/Events/Private/GitEventCallbacks.hpp"
#include "libGitWrap/Private/DiffListPrivate.hpp"

#if 0
#define debugEvents qDebug
Expand All @@ -28,6 +31,30 @@ namespace Git
{
class CredentialRequest{}; // temporary dummy

class CheckoutNotify
{
public:
enum Notify {
NotifyNone = GIT_CHECKOUT_NOTIFY_NONE ,
NotifyConflict = GIT_CHECKOUT_NOTIFY_CONFLICT ,
NotifyDirty = GIT_CHECKOUT_NOTIFY_DIRTY ,
NotifyUpdated = GIT_CHECKOUT_NOTIFY_UPDATED ,
NotifyUntracked = GIT_CHECKOUT_NOTIFY_UNTRACKED ,
NotifyIgnored = GIT_CHECKOUT_NOTIFY_IGNORED ,

NotifyAll = GIT_CHECKOUT_NOTIFY_ALL
};

public:
explicit CheckoutNotify( git_checkout_notify_t why )
: mWhy( static_cast<Notify>( why ) )
{
}

private:
Notify mWhy;
};

namespace Internal
{

Expand All @@ -52,7 +79,7 @@ namespace Git
{
IRemoteEvents* events = static_cast< IRemoteEvents* >(payload);

debugEvents("fetchProgress: %u %u %u %lu",
debugEvents("fetch progress: %u %u %u %lu",
stats->total_objects,
stats->received_objects,
stats->indexed_objects,
Expand Down Expand Up @@ -114,7 +141,7 @@ namespace Git
{
IRemoteEvents* events = static_cast< IRemoteEvents* >( payload );

debugEvents( "Remote Progress: %s", QByteArray( str, len ).constData() );
debugEvents( "remote progress: %s", QByteArray( str, len ).constData() );

if (events) {
events->remoteMessage(GW_StringToQt(str, len));
Expand All @@ -131,7 +158,7 @@ namespace Git
Git::ObjectId oidFrom = Git::ObjectId::fromRaw(a->id);
Git::ObjectId oidTo = Git::ObjectId::fromRaw(b->id);

debugEvents("Remote Update Tips: %s [%s->%s]",
debugEvents("remote update tips: %s [%s->%s]",
refname,
oidFrom.toAscii().constData(),
oidTo.toAscii().constData());
Expand Down Expand Up @@ -159,6 +186,51 @@ namespace Git
cb.payload = receiver;
}


// -- CheckoutCallbacks ->8

int CheckoutCallbacks::notify( git_checkout_notify_t why,
const char* path,
const git_diff_file* baseline,
const git_diff_file* target,
const git_diff_file* workdir,
void* payload )
{
ICheckoutEvents* events = static_cast< ICheckoutEvents* >( payload );

if ( events ) {
events->checkoutNotify( CheckoutNotify( why ),
GW_StringToQt( path ),
new DiffFilePrivate( RepositoryPrivate::Ptr(), baseline ),
new DiffFilePrivate( RepositoryPrivate::Ptr(), target ),
new DiffFilePrivate( RepositoryPrivate::Ptr(), workdir )
);
}

return GITERR_NONE;
}

void CheckoutCallbacks::checkoutProgress(const char* path, size_t completed_steps, size_t total_steps, void* payload)
{
ICheckoutEvents* events = static_cast< ICheckoutEvents* >( payload );

qreal progress = 100 / total_steps * completed_steps;
debugEvents( "checkout progress: %.2f", progress );

if (events) {
events->checkoutProgress( GW_StringToQt(path), total_steps, completed_steps );
}
}

void CheckoutCallbacks::initCallbacks(git_checkout_options& opts, ICheckoutEvents* receiver)
{
opts.notify_cb = &CheckoutCallbacks::notify;
opts.notify_payload = receiver;

opts.progress_cb = &CheckoutCallbacks::checkoutProgress;
opts.progress_payload = receiver;
}

}

}
Loading