From: Stefan Beller <sbeller@google.com>
To: dturner@twopensource.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCH 08/14] fetch-pack: factor out get_selected_capabilities_list
Date: Fri, 29 Apr 2016 16:34:41 -0700 [thread overview]
Message-ID: <1461972887-22100-9-git-send-email-sbeller@google.com> (raw)
In-Reply-To: <1461972887-22100-1-git-send-email-sbeller@google.com>
This will be used later by both versions of the transport protocol.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
fetch-pack.c | 51 ++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 11 deletions(-)
diff --git a/fetch-pack.c b/fetch-pack.c
index 53f6384..b43490f 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -257,6 +257,9 @@ static int next_flush(struct fetch_pack_args *args, int count)
return count;
}
+static void get_selected_capabilities_list(struct string_list *list,
+ struct fetch_pack_args *args);
+
static int find_common(struct fetch_pack_args *args,
int fd[2], unsigned char *result_sha1,
struct ref *refs)
@@ -302,18 +305,15 @@ static int find_common(struct fetch_pack_args *args,
remote_hex = sha1_to_hex(remote);
if (!fetching) {
+ struct string_list list = STRING_LIST_INIT_NODUP;
struct strbuf c = STRBUF_INIT;
- if (multi_ack == 2) strbuf_addstr(&c, " multi_ack_detailed");
- if (multi_ack == 1) strbuf_addstr(&c, " multi_ack");
- if (no_done) strbuf_addstr(&c, " no-done");
- if (use_sideband == 2) strbuf_addstr(&c, " side-band-64k");
- if (use_sideband == 1) strbuf_addstr(&c, " side-band");
- if (args->use_thin_pack) strbuf_addstr(&c, " thin-pack");
- if (args->no_progress) strbuf_addstr(&c, " no-progress");
- if (args->include_tag) strbuf_addstr(&c, " include-tag");
- if (prefer_ofs_delta) strbuf_addstr(&c, " ofs-delta");
- if (agent_supported) strbuf_addf(&c, " agent=%s",
- git_user_agent_sanitized());
+ struct string_list_item *item;
+ get_selected_capabilities_list(&list, args);
+ for_each_string_list_item(item, &list) {
+ strbuf_addstr(&c, " ");
+ strbuf_addstr(&c, item->string);
+ }
+
packet_buf_write(&req_buf, "want %s%s\n", remote_hex, c.buf);
strbuf_release(&c);
} else
@@ -859,6 +859,35 @@ static void select_capabilities(struct fetch_pack_args *args)
}
}
+static void get_selected_capabilities_list(struct string_list *list,
+ struct fetch_pack_args *args)
+{
+ if (multi_ack == 2)
+ string_list_append(list, "multi_ack_detailed");
+ if (multi_ack == 1)
+ string_list_append(list, "multi_ack");
+ if (no_done)
+ string_list_append(list, "no-done");
+ if (use_sideband == 2)
+ string_list_append(list, "side-band-64k");
+ if (use_sideband == 1)
+ string_list_append(list, "side-band");
+ if (args->use_thin_pack)
+ string_list_append(list, "thin-pack");
+ if (args->no_progress)
+ string_list_append(list, "no-progress");
+ if (args->include_tag)
+ string_list_append(list, "include-tag");
+ if (prefer_ofs_delta)
+ string_list_append(list, "ofs-delta");
+ if (agent_supported) {
+ struct strbuf buf = STRBUF_INIT;
+ strbuf_addf(&buf, "agent=%s", git_user_agent_sanitized());
+ string_list_append(list, buf.buf);
+ strbuf_release(&buf);
+ }
+}
+
static struct ref *do_fetch_pack(struct fetch_pack_args *args,
int fd[2],
const struct ref *orig_ref,
--
2.8.0.32.g71f8beb.dirty
next prev parent reply other threads:[~2016-04-29 23:35 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 23:34 [WIP PATCH 00/14] Protocol v2 patches Stefan Beller
2016-04-29 23:34 ` [PATCH 01/14] upload-pack: make client capability parsing code a separate function Stefan Beller
2016-04-29 23:34 ` [PATCH 02/14] upload-pack.c: Refactor capability advertising Stefan Beller
2016-04-30 1:04 ` David Turner
2016-05-04 20:05 ` Junio C Hamano
2016-04-29 23:34 ` [PATCH 03/14] upload-pack-2: Implement the version 2 of upload-pack Stefan Beller
2016-05-02 17:43 ` David Turner
2016-05-02 17:51 ` Stefan Beller
2016-05-02 18:56 ` David Turner
2016-05-03 0:31 ` Duy Nguyen
2016-05-04 20:11 ` Junio C Hamano
2016-04-29 23:34 ` [PATCH 04/14] connect: rewrite feature parsing to work on string_list Stefan Beller
2016-05-02 18:18 ` David Turner
2016-05-02 18:46 ` Stefan Beller
2016-05-04 20:13 ` Junio C Hamano
2016-05-17 22:23 ` David Turner
2016-04-29 23:34 ` [PATCH 05/14] transport: add infrastructure to support a protocol version number Stefan Beller
2016-04-29 23:34 ` [PATCH 06/14] remote.h: add get_remote_capabilities, request_capabilities Stefan Beller
2016-05-02 18:57 ` David Turner
2016-05-03 5:33 ` Jeff King
2016-05-03 21:21 ` David Turner
2016-05-04 16:44 ` Stefan Beller
2016-04-29 23:34 ` [PATCH 07/14] fetch-pack: move capability selection out of do_fetch_pack Stefan Beller
2016-04-29 23:34 ` Stefan Beller [this message]
2016-05-02 19:09 ` [PATCH 08/14] fetch-pack: factor out get_selected_capabilities_list David Turner
2016-04-29 23:34 ` [PATCH 09/14] fetch-pack: Add negotiate_capabilities Stefan Beller
2016-04-29 23:34 ` [PATCH 10/14] do_fetch_pack: select capabilities for transport version 1 only Stefan Beller
2016-04-29 23:34 ` [PATCH 11/14] builtin/fetch-pack: add argument for transport version Stefan Beller
2016-04-29 23:34 ` [PATCH 12/14] Add test for fetch-pack Stefan Beller
2016-05-02 19:45 ` David Turner
2016-04-29 23:34 ` [PATCH 13/14] WIP add test for git pull Stefan Beller
2016-04-29 23:34 ` [PATCH 14/14] WIP test git fetch Stefan Beller
2016-05-02 20:41 ` [WIP PATCH 00/14] Protocol v2 patches David Turner
2016-05-02 20:43 ` Stefan Beller
2016-05-24 22:46 ` David Turner
2016-05-24 23:03 ` Duy Nguyen
2016-05-25 16:45 ` David Turner
2016-05-25 16:23 ` Junio C Hamano
2016-05-25 19:31 ` David Turner
2016-05-25 21:29 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461972887-22100-9-git-send-email-sbeller@google.com \
--to=sbeller@google.com \
--cc=dturner@twopensource.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).