summaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2018-05-03 23:46:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-06 04:17:19 (GMT)
commitba95710a3bdcb2a80495b1d93a0e482dd69905e1 (patch)
tree8336ff3d7af8a17c68a144edf627700643a457a2 /upload-pack.c
parent5459268751941a71b32816902698376b7932cec5 (diff)
downloadgit-ba95710a3bdcb2a80495b1d93a0e482dd69905e1.zip
git-ba95710a3bdcb2a80495b1d93a0e482dd69905e1.tar.gz
git-ba95710a3bdcb2a80495b1d93a0e482dd69905e1.tar.bz2
{fetch,upload}-pack: support filter in protocol v2
The fetch-pack/upload-pack protocol v2 was developed independently of the filter parameter (used in partial fetches), thus it did not include support for it. Add support for the filter parameter. Like in the legacy protocol, the server advertises and supports "filter" only if uploadpack.allowfilter is configured. Like in the legacy protocol, the client continues with a warning if "--filter" is specified, but the server does not advertise it. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/upload-pack.c b/upload-pack.c
index 113edd3..82c16ca 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1205,6 +1205,7 @@ static void process_args(struct packet_reader *request,
{
while (packet_reader_read(request) != PACKET_READ_FLUSH) {
const char *arg = request->line;
+ const char *p;
/* process want */
if (parse_want(arg))
@@ -1251,6 +1252,11 @@ static void process_args(struct packet_reader *request,
continue;
}
+ if (allow_filter && skip_prefix(arg, "filter ", &p)) {
+ parse_list_objects_filter(&filter_options, p);
+ continue;
+ }
+
/* ignore unknown lines maybe? */
die("unexpected line: '%s'", arg);
}
@@ -1430,7 +1436,14 @@ int upload_pack_v2(struct repository *r, struct argv_array *keys,
int upload_pack_advertise(struct repository *r,
struct strbuf *value)
{
- if (value)
+ if (value) {
+ int allow_filter_value;
strbuf_addstr(value, "shallow");
+ if (!repo_config_get_bool(the_repository,
+ "uploadpack.allowfilter",
+ &allow_filter_value) &&
+ allow_filter_value)
+ strbuf_addstr(value, " filter");
+ }
return 1;
}