aboutsummaryrefslogtreecommitdiffstats
path: root/connect.c
diff options
context:
space:
mode:
authorBrandon Williams <bmwill@google.com>2018-03-15 10:31:29 -0700
committerJunio C Hamano <gitster@pobox.com>2018-03-15 12:01:09 -0700
commitf7e205010542dc9b712473d260058e43ca2b26f7 (patch)
tree503fc2d33b308537fcd04626278476c9ba591614 /connect.c
parent685fbd32916f3e94bc89aa14e8fdce835b06f801 (diff)
downloadgit-f7e205010542dc9b712473d260058e43ca2b26f7.tar.gz
fetch-pack: support shallow requests
Enable shallow clones and deepen requests using protocol version 2 if the server 'fetch' command supports the 'shallow' feature. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'connect.c')
-rw-r--r--connect.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/connect.c b/connect.c
index e42d779f71..5bb9d34844 100644
--- a/connect.c
+++ b/connect.c
@@ -82,6 +82,28 @@ int server_supports_v2(const char *c, int die_on_error)
return 0;
}
+int server_supports_feature(const char *c, const char *feature,
+ int die_on_error)
+{
+ int i;
+
+ for (i = 0; i < server_capabilities_v2.argc; i++) {
+ const char *out;
+ if (skip_prefix(server_capabilities_v2.argv[i], c, &out) &&
+ (!*out || *(out++) == '=')) {
+ if (parse_feature_request(out, feature))
+ return 1;
+ else
+ break;
+ }
+ }
+
+ if (die_on_error)
+ die("server doesn't support feature '%s'", feature);
+
+ return 0;
+}
+
static void process_capabilities_v2(struct packet_reader *reader)
{
while (packet_reader_read(reader) == PACKET_READ_NORMAL)