Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
37d98aaf
Commit
37d98aaf
authored
Feb 06, 2022
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transport: transports can indicate support for fetch by oid
parent
7a00adcc
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
3 deletions
+60
-3
include/git2/sys/remote.h
+31
-0
src/transports/local.c
+3
-1
src/transports/smart.c
+9
-1
src/transports/smart.h
+5
-1
src/transports/smart_protocol.c
+12
-0
No files found.
include/git2/sys/remote.h
0 → 100644
View file @
37d98aaf
/*
* 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
src/transports/local.c
View file @
37d98aaf
...
...
@@ -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
;
}
...
...
src/transports/smart.c
View file @
37d98aaf
...
...
@@ -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
(
transpor
t
);
transport_smart
*
t
=
GIT_CONTAINER_OF
(
transport
,
transport_smart
,
paren
t
);
*
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
;
}
...
...
src/transports/smart.h
View file @
37d98aaf
...
...
@@ -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
);
...
...
src/transports/smart_protocol.c
View file @
37d98aaf
...
...
@@ -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
,
' '
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment