// This is a generated file, modify: generate/templates/templates/class_header.h

#ifndef GITREMOTE_H
#define GITREMOTE_H
#include <nan.h>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <sstream>

#include "async_baton.h"
#include "async_worker.h"
#include "cleanup_handle.h"
#include "context.h"
#include "lock_master.h"
#include "nodegit_wrapper.h"
#include "promise_completion.h"
#include "reference_counter.h"
#include "worker_pool.h"

extern "C" {
#include <git2.h>
}

#include "../include/typedefs.h"

#include "../include/str_array_converter.h"
#include "../include/remote_head.h"
#include "../include/repository.h"
#include "../include/remote_callbacks.h"
#include "../include/proxy_options.h"
#include "../include/strarray.h"
#include "../include/remote_create_options.h"
#include "../include/buf.h"
#include "../include/fetch_options.h"
#include "../include/refspec.h"
#include "../include/push_options.h"
#include "../include/indexer_progress.h"
// Forward declaration.
struct git_remote {
};

using namespace node;
using namespace v8;

class GitRemote;
 
struct GitRemoteTraits {
  typedef GitRemote cppClass;
  typedef git_remote cType;
 
  static const bool isDuplicable = false;
  static void duplicate(git_remote **dest, git_remote *src) {
     Nan::ThrowError("duplicate called on GitRemote which cannot be duplicated");
   }

  static std::string className() { return "GitRemote"; };
  static const bool isSingleton = false;
  static const bool isFreeable = true;
  static void free(git_remote *raw) {
    unsigned long referenceCount = 0;
     if (referenceCount == 0) {
      ::git_remote_free(raw); // :: to avoid calling this free recursively
    }
   }
};

class GitRemote : public
  NodeGitWrapper<GitRemoteTraits>
{
    // grant full access to base class
    friend class NodeGitWrapper<GitRemoteTraits>;
   public:
    GitRemote(const GitRemote &) = delete;
    GitRemote(GitRemote &&) = delete;
    GitRemote &operator=(const GitRemote &) = delete;
    GitRemote &operator=(GitRemote &&) = delete;

    static void InitializeComponent (v8::Local<v8::Object> target, nodegit::Context *nodegitContext);

                                                                                                                                                                               

  private:
    GitRemote()
      : NodeGitWrapper<GitRemoteTraits>(
           "A new GitRemote cannot be instantiated."
       )
    {}
    GitRemote(git_remote *raw, bool selfFreeing, v8::Local<v8::Object> owner = v8::Local<v8::Object>())
      : NodeGitWrapper<GitRemoteTraits>(raw, selfFreeing, owner)
    {}
    ~GitRemote();

    static NAN_METHOD(AddFetch);

    static NAN_METHOD(AddPush);

    static NAN_METHOD(Autotag);

    struct ConnectBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
      git_direction direction;
      const git_remote_callbacks * callbacks;
      const git_proxy_options * proxy_opts;
      const git_strarray * custom_headers;
     };
    class ConnectWorker : public nodegit::AsyncWorker {
      public:
        ConnectWorker(
            ConnectBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Connect", cleanupHandles)
          , baton(_baton) {};
        ConnectWorker(const ConnectWorker &) = delete;
        ConnectWorker(ConnectWorker &&) = delete;
        ConnectWorker &operator=(const ConnectWorker &) = delete;
        ConnectWorker &operator=(ConnectWorker &&) = delete;
        ~ConnectWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ConnectBaton *baton;
    };

    static NAN_METHOD(Connect);

    static NAN_METHOD(Connected);

    struct CreateBaton {
      int error_code;
      const git_error* error;
      git_remote * out;
      git_repository * repo;
      const char * name;
      const char * url;
     };
    class CreateWorker : public nodegit::AsyncWorker {
      public:
        CreateWorker(
            CreateBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Create", cleanupHandles)
          , baton(_baton) {};
        CreateWorker(const CreateWorker &) = delete;
        CreateWorker(CreateWorker &&) = delete;
        CreateWorker &operator=(const CreateWorker &) = delete;
        CreateWorker &operator=(CreateWorker &&) = delete;
        ~CreateWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateBaton *baton;
    };

    static NAN_METHOD(Create);

    struct CreateAnonymousBaton {
      int error_code;
      const git_error* error;
      git_remote * out;
      git_repository * repo;
      const char * url;
     };
    class CreateAnonymousWorker : public nodegit::AsyncWorker {
      public:
        CreateAnonymousWorker(
            CreateAnonymousBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:CreateAnonymous", cleanupHandles)
          , baton(_baton) {};
        CreateAnonymousWorker(const CreateAnonymousWorker &) = delete;
        CreateAnonymousWorker(CreateAnonymousWorker &&) = delete;
        CreateAnonymousWorker &operator=(const CreateAnonymousWorker &) = delete;
        CreateAnonymousWorker &operator=(CreateAnonymousWorker &&) = delete;
        ~CreateAnonymousWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateAnonymousBaton *baton;
    };

    static NAN_METHOD(CreateAnonymous);

    struct CreateDetachedBaton {
      int error_code;
      const git_error* error;
      git_remote * out;
      const char * url;
     };
    class CreateDetachedWorker : public nodegit::AsyncWorker {
      public:
        CreateDetachedWorker(
            CreateDetachedBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:CreateDetached", cleanupHandles)
          , baton(_baton) {};
        CreateDetachedWorker(const CreateDetachedWorker &) = delete;
        CreateDetachedWorker(CreateDetachedWorker &&) = delete;
        CreateDetachedWorker &operator=(const CreateDetachedWorker &) = delete;
        CreateDetachedWorker &operator=(CreateDetachedWorker &&) = delete;
        ~CreateDetachedWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateDetachedBaton *baton;
    };

    static NAN_METHOD(CreateDetached);

    struct CreateWithFetchspecBaton {
      int error_code;
      const git_error* error;
      git_remote * out;
      git_repository * repo;
      const char * name;
      const char * url;
      const char * fetch;
     };
    class CreateWithFetchspecWorker : public nodegit::AsyncWorker {
      public:
        CreateWithFetchspecWorker(
            CreateWithFetchspecBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:CreateWithFetchspec", cleanupHandles)
          , baton(_baton) {};
        CreateWithFetchspecWorker(const CreateWithFetchspecWorker &) = delete;
        CreateWithFetchspecWorker(CreateWithFetchspecWorker &&) = delete;
        CreateWithFetchspecWorker &operator=(const CreateWithFetchspecWorker &) = delete;
        CreateWithFetchspecWorker &operator=(CreateWithFetchspecWorker &&) = delete;
        ~CreateWithFetchspecWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateWithFetchspecBaton *baton;
    };

    static NAN_METHOD(CreateWithFetchspec);

    struct CreateWithOptsBaton {
      int error_code;
      const git_error* error;
      git_remote * out;
      const char * url;
      const git_remote_create_options * opts;
     };
    class CreateWithOptsWorker : public nodegit::AsyncWorker {
      public:
        CreateWithOptsWorker(
            CreateWithOptsBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:CreateWithOpts", cleanupHandles)
          , baton(_baton) {};
        CreateWithOptsWorker(const CreateWithOptsWorker &) = delete;
        CreateWithOptsWorker(CreateWithOptsWorker &&) = delete;
        CreateWithOptsWorker &operator=(const CreateWithOptsWorker &) = delete;
        CreateWithOptsWorker &operator=(CreateWithOptsWorker &&) = delete;
        ~CreateWithOptsWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        CreateWithOptsBaton *baton;
    };

    static NAN_METHOD(CreateWithOpts);

    struct DefaultBranchBaton {
      int error_code;
      const git_error* error;
      git_buf * out;
      git_remote * remote;
     };
    class DefaultBranchWorker : public nodegit::AsyncWorker {
      public:
        DefaultBranchWorker(
            DefaultBranchBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:DefaultBranch", cleanupHandles)
          , baton(_baton) {};
        DefaultBranchWorker(const DefaultBranchWorker &) = delete;
        DefaultBranchWorker(DefaultBranchWorker &&) = delete;
        DefaultBranchWorker &operator=(const DefaultBranchWorker &) = delete;
        DefaultBranchWorker &operator=(DefaultBranchWorker &&) = delete;
        ~DefaultBranchWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DefaultBranchBaton *baton;
    };

    static NAN_METHOD(DefaultBranch);

    struct DeleteBaton {
      int error_code;
      const git_error* error;
      git_repository * repo;
      const char * name;
     };
    class DeleteWorker : public nodegit::AsyncWorker {
      public:
        DeleteWorker(
            DeleteBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Delete", cleanupHandles)
          , baton(_baton) {};
        DeleteWorker(const DeleteWorker &) = delete;
        DeleteWorker(DeleteWorker &&) = delete;
        DeleteWorker &operator=(const DeleteWorker &) = delete;
        DeleteWorker &operator=(DeleteWorker &&) = delete;
        ~DeleteWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DeleteBaton *baton;
    };

    static NAN_METHOD(Delete);

    struct DisconnectBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
     };
    class DisconnectWorker : public nodegit::AsyncWorker {
      public:
        DisconnectWorker(
            DisconnectBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Disconnect", cleanupHandles)
          , baton(_baton) {};
        DisconnectWorker(const DisconnectWorker &) = delete;
        DisconnectWorker(DisconnectWorker &&) = delete;
        DisconnectWorker &operator=(const DisconnectWorker &) = delete;
        DisconnectWorker &operator=(DisconnectWorker &&) = delete;
        ~DisconnectWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DisconnectBaton *baton;
    };

    static NAN_METHOD(Disconnect);

    struct DownloadBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
      const git_strarray * refspecs;
      const git_fetch_options * opts;
     };
    class DownloadWorker : public nodegit::AsyncWorker {
      public:
        DownloadWorker(
            DownloadBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Download", cleanupHandles)
          , baton(_baton) {};
        DownloadWorker(const DownloadWorker &) = delete;
        DownloadWorker(DownloadWorker &&) = delete;
        DownloadWorker &operator=(const DownloadWorker &) = delete;
        DownloadWorker &operator=(DownloadWorker &&) = delete;
        ~DownloadWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DownloadBaton *baton;
    };

    static NAN_METHOD(Download);

    struct DupBaton {
      int error_code;
      const git_error* error;
      git_remote * dest;
      git_remote * source;
     };
    class DupWorker : public nodegit::AsyncWorker {
      public:
        DupWorker(
            DupBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Dup", cleanupHandles)
          , baton(_baton) {};
        DupWorker(const DupWorker &) = delete;
        DupWorker(DupWorker &&) = delete;
        DupWorker &operator=(const DupWorker &) = delete;
        DupWorker &operator=(DupWorker &&) = delete;
        ~DupWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        DupBaton *baton;
    };

    static NAN_METHOD(Dup);

    struct FetchBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
      const git_strarray * refspecs;
      const git_fetch_options * opts;
      const char * reflog_message;
     };
    class FetchWorker : public nodegit::AsyncWorker {
      public:
        FetchWorker(
            FetchBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Fetch", cleanupHandles)
          , baton(_baton) {};
        FetchWorker(const FetchWorker &) = delete;
        FetchWorker(FetchWorker &&) = delete;
        FetchWorker &operator=(const FetchWorker &) = delete;
        FetchWorker &operator=(FetchWorker &&) = delete;
        ~FetchWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        FetchBaton *baton;
    };

    static NAN_METHOD(Fetch);

    struct GetFetchRefspecsBaton {
      int error_code;
      const git_error* error;
      git_strarray * array;
      const git_remote * remote;
     };
    class GetFetchRefspecsWorker : public nodegit::AsyncWorker {
      public:
        GetFetchRefspecsWorker(
            GetFetchRefspecsBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:GetFetchRefspecs", cleanupHandles)
          , baton(_baton) {};
        GetFetchRefspecsWorker(const GetFetchRefspecsWorker &) = delete;
        GetFetchRefspecsWorker(GetFetchRefspecsWorker &&) = delete;
        GetFetchRefspecsWorker &operator=(const GetFetchRefspecsWorker &) = delete;
        GetFetchRefspecsWorker &operator=(GetFetchRefspecsWorker &&) = delete;
        ~GetFetchRefspecsWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        GetFetchRefspecsBaton *baton;
    };

    static NAN_METHOD(GetFetchRefspecs);

    struct GetPushRefspecsBaton {
      int error_code;
      const git_error* error;
      git_strarray * array;
      const git_remote * remote;
     };
    class GetPushRefspecsWorker : public nodegit::AsyncWorker {
      public:
        GetPushRefspecsWorker(
            GetPushRefspecsBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:GetPushRefspecs", cleanupHandles)
          , baton(_baton) {};
        GetPushRefspecsWorker(const GetPushRefspecsWorker &) = delete;
        GetPushRefspecsWorker(GetPushRefspecsWorker &&) = delete;
        GetPushRefspecsWorker &operator=(const GetPushRefspecsWorker &) = delete;
        GetPushRefspecsWorker &operator=(GetPushRefspecsWorker &&) = delete;
        ~GetPushRefspecsWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        GetPushRefspecsBaton *baton;
    };

    static NAN_METHOD(GetPushRefspecs);

    static NAN_METHOD(GetRefspec);

    static NAN_METHOD(IsValidName);

    struct ListBaton {
      int error_code;
      const git_error* error;
      git_strarray * out;
      git_repository * repo;
     };
    class ListWorker : public nodegit::AsyncWorker {
      public:
        ListWorker(
            ListBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:List", cleanupHandles)
          , baton(_baton) {};
        ListWorker(const ListWorker &) = delete;
        ListWorker(ListWorker &&) = delete;
        ListWorker &operator=(const ListWorker &) = delete;
        ListWorker &operator=(ListWorker &&) = delete;
        ~ListWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ListBaton *baton;
    };

    static NAN_METHOD(List);

    struct LookupBaton {
      int error_code;
      const git_error* error;
      git_remote * out;
      git_repository * repo;
      const char * name;
     };
    class LookupWorker : public nodegit::AsyncWorker {
      public:
        LookupWorker(
            LookupBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Lookup", cleanupHandles)
          , baton(_baton) {};
        LookupWorker(const LookupWorker &) = delete;
        LookupWorker(LookupWorker &&) = delete;
        LookupWorker &operator=(const LookupWorker &) = delete;
        LookupWorker &operator=(LookupWorker &&) = delete;
        ~LookupWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        LookupBaton *baton;
    };

    static NAN_METHOD(Lookup);

    static NAN_METHOD(Name);

    static NAN_METHOD(NameIsValid);

    static NAN_METHOD(Owner);

    struct PruneBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
      const git_remote_callbacks * callbacks;
     };
    class PruneWorker : public nodegit::AsyncWorker {
      public:
        PruneWorker(
            PruneBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Prune", cleanupHandles)
          , baton(_baton) {};
        PruneWorker(const PruneWorker &) = delete;
        PruneWorker(PruneWorker &&) = delete;
        PruneWorker &operator=(const PruneWorker &) = delete;
        PruneWorker &operator=(PruneWorker &&) = delete;
        ~PruneWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        PruneBaton *baton;
    };

    static NAN_METHOD(Prune);

    static NAN_METHOD(PruneRefs);

    struct PushBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
      const git_strarray * refspecs;
      const git_push_options * opts;
     };
    class PushWorker : public nodegit::AsyncWorker {
      public:
        PushWorker(
            PushBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Push", cleanupHandles)
          , baton(_baton) {};
        PushWorker(const PushWorker &) = delete;
        PushWorker(PushWorker &&) = delete;
        PushWorker &operator=(const PushWorker &) = delete;
        PushWorker &operator=(PushWorker &&) = delete;
        ~PushWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        PushBaton *baton;
    };

    static NAN_METHOD(Push);

    static NAN_METHOD(Pushurl);

    static NAN_METHOD(RefspecCount);

    struct RenameBaton {
      int error_code;
      const git_error* error;
      git_strarray * problems;
      git_repository * repo;
      const char * name;
      const char * new_name;
     };
    class RenameWorker : public nodegit::AsyncWorker {
      public:
        RenameWorker(
            RenameBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Rename", cleanupHandles)
          , baton(_baton) {};
        RenameWorker(const RenameWorker &) = delete;
        RenameWorker(RenameWorker &&) = delete;
        RenameWorker &operator=(const RenameWorker &) = delete;
        RenameWorker &operator=(RenameWorker &&) = delete;
        ~RenameWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        RenameBaton *baton;
    };

    static NAN_METHOD(Rename);

    static NAN_METHOD(SetAutotag);

    static NAN_METHOD(SetPushurl);

    static NAN_METHOD(SetUrl);

    static NAN_METHOD(Stats);

    static NAN_METHOD(Stop);

    struct UpdateTipsBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
      const git_remote_callbacks * callbacks;
      int update_fetchhead;
      git_remote_autotag_option_t download_tags;
      const char * reflog_message;
     };
    class UpdateTipsWorker : public nodegit::AsyncWorker {
      public:
        UpdateTipsWorker(
            UpdateTipsBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:UpdateTips", cleanupHandles)
          , baton(_baton) {};
        UpdateTipsWorker(const UpdateTipsWorker &) = delete;
        UpdateTipsWorker(UpdateTipsWorker &&) = delete;
        UpdateTipsWorker &operator=(const UpdateTipsWorker &) = delete;
        UpdateTipsWorker &operator=(UpdateTipsWorker &&) = delete;
        ~UpdateTipsWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        UpdateTipsBaton *baton;
    };

    static NAN_METHOD(UpdateTips);

    struct UploadBaton {
      int error_code;
      const git_error* error;
      git_remote * remote;
      const git_strarray * refspecs;
      const git_push_options * opts;
     };
    class UploadWorker : public nodegit::AsyncWorker {
      public:
        UploadWorker(
            UploadBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:Upload", cleanupHandles)
          , baton(_baton) {};
        UploadWorker(const UploadWorker &) = delete;
        UploadWorker(UploadWorker &&) = delete;
        UploadWorker &operator=(const UploadWorker &) = delete;
        UploadWorker &operator=(UploadWorker &&) = delete;
        ~UploadWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        UploadBaton *baton;
    };

    static NAN_METHOD(Upload);

    static NAN_METHOD(Url);

    struct ReferenceListBaton {
      int error_code;
      const git_error* error;
      std::vector<git_remote_head*> * out;
      git_remote * remote;
     };
    class ReferenceListWorker : public nodegit::AsyncWorker {
      public:
        ReferenceListWorker(
            ReferenceListBaton *_baton,
            Nan::Callback *callback,
            std::map<std::string, std::shared_ptr<nodegit::CleanupHandle>> &cleanupHandles
        ) : nodegit::AsyncWorker(callback, "nodegit:AsyncWorker:GitRemote:ReferenceList", cleanupHandles)
          , baton(_baton) {};
        ReferenceListWorker(const ReferenceListWorker &) = delete;
        ReferenceListWorker(ReferenceListWorker &&) = delete;
        ReferenceListWorker &operator=(const ReferenceListWorker &) = delete;
        ReferenceListWorker &operator=(ReferenceListWorker &&) = delete;
        ~ReferenceListWorker() {};
        void Execute();
        void HandleErrorCallback();
        void HandleOKCallback();
        nodegit::LockMaster AcquireLocks();

      private:
        ReferenceListBaton *baton;
    };

    static NAN_METHOD(ReferenceList);
};

#endif
