Commit 37d98aaf by Edward Thomson

transport: transports can indicate support for fetch by oid

parent 7a00adcc
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#ifndef INCLUDE_sys_git_remote_h
#define INCLUDE_sys_git_remote_h
/**
* @file git2/sys/remote.h
* @brief Low-level remote functionality for custom transports
* @defgroup git_remote Low-level remote functionality
* @ingroup Git
* @{
*/
GIT_BEGIN_DECL
typedef enum {
/** Remote supports fetching an advertised object by ID. */
GIT_REMOTE_CAPABILITY_TIP_OID = (1 << 0),
/** Remote supports fetching an individual reachable object. */
GIT_REMOTE_CAPABILITY_REACHABLE_OID = (1 << 1),
} git_remote_capability_t;
/** @} */
GIT_END_DECL
#endif
......@@ -28,6 +28,7 @@
#include "git2/pack.h"
#include "git2/commit.h"
#include "git2/revparse.h"
#include "git2/sys/remote.h"
typedef struct {
git_transport parent;
......@@ -260,7 +261,8 @@ static int local_capabilities(unsigned int *capabilities, git_transport *transpo
{
GIT_UNUSED(transport);
*capabilities = 0;
*capabilities = GIT_REMOTE_CAPABILITY_TIP_OID |
GIT_REMOTE_CAPABILITY_REACHABLE_OID;
return 0;
}
......
......@@ -8,6 +8,7 @@
#include "smart.h"
#include "git2.h"
#include "git2/sys/remote.h"
#include "refs.h"
#include "refspec.h"
#include "proxy.h"
......@@ -228,9 +229,16 @@ static int git_smart__set_connect_opts(
static int git_smart__capabilities(unsigned int *capabilities, git_transport *transport)
{
GIT_UNUSED(transport);
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
*capabilities = 0;
if (t->caps.want_tip_sha1)
*capabilities |= GIT_REMOTE_CAPABILITY_TIP_OID;
if (t->caps.want_reachable_sha1)
*capabilities |= GIT_REMOTE_CAPABILITY_REACHABLE_OID;
return 0;
}
......
......@@ -30,6 +30,8 @@
#define GIT_CAP_REPORT_STATUS "report-status"
#define GIT_CAP_THIN_PACK "thin-pack"
#define GIT_CAP_SYMREF "symref"
#define GIT_CAP_WANT_TIP_SHA1 "allow-tip-sha1-in-want"
#define GIT_CAP_WANT_REACHABLE_SHA1 "allow-reachable-sha1-in-want"
extern bool git_smart__ofs_delta_enabled;
......@@ -128,7 +130,9 @@ typedef struct transport_smart_caps {
include_tag:1,
delete_refs:1,
report_status:1,
thin_pack:1;
thin_pack:1,
want_tip_sha1:1,
want_reachable_sha1:1;
} transport_smart_caps;
typedef int (*packetsize_cb)(size_t received, void *payload);
......
......@@ -205,6 +205,18 @@ int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vec
continue;
}
if (!git__prefixcmp(ptr, GIT_CAP_WANT_TIP_SHA1)) {
caps->common = caps->want_tip_sha1 = 1;
ptr += strlen(GIT_CAP_DELETE_REFS);
continue;
}
if (!git__prefixcmp(ptr, GIT_CAP_WANT_REACHABLE_SHA1)) {
caps->common = caps->want_reachable_sha1 = 1;
ptr += strlen(GIT_CAP_DELETE_REFS);
continue;
}
/* We don't know this capability, so skip it */
ptr = strchr(ptr, ' ');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment