From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH 4/8] upload-pack: new capability to pass --skip* to pack-objects
Date: Fri, 5 Feb 2016 15:57:53 +0700 [thread overview]
Message-ID: <1454662677-15137-5-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1454662677-15137-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/technical/pack-protocol.txt | 2 ++
Documentation/technical/protocol-capabilities.txt | 9 +++++++
upload-pack.c | 30 +++++++++++++++++++++--
3 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/Documentation/technical/pack-protocol.txt b/Documentation/technical/pack-protocol.txt
index c6977bb..5207d08 100644
--- a/Documentation/technical/pack-protocol.txt
+++ b/Documentation/technical/pack-protocol.txt
@@ -167,6 +167,7 @@ MUST peel the ref if it's an annotated tag.
----
advertised-refs = (no-refs / list-of-refs)
*shallow
+ skip
flush-pkt
no-refs = PKT-LINE(zero-id SP "capabilities^{}"
@@ -181,6 +182,7 @@ MUST peel the ref if it's an annotated tag.
other-peeled = obj-id SP refname "^{}"
shallow = PKT-LINE("shallow" SP obj-id)
+ skip = PKT-LINE("skip" SP obj-id SP 1*DIGIT)
capability-list = capability *(SP capability)
capability = 1*(LC_ALPHA / DIGIT / "-" / "_")
diff --git a/Documentation/technical/protocol-capabilities.txt b/Documentation/technical/protocol-capabilities.txt
index eaab6b4..0567970 100644
--- a/Documentation/technical/protocol-capabilities.txt
+++ b/Documentation/technical/protocol-capabilities.txt
@@ -275,3 +275,12 @@ to accept a signed push certificate, and asks the <nonce> to be
included in the push certificate. A send-pack client MUST NOT
send a push-cert packet unless the receive-pack server advertises
this capability.
+
+partial
+------
+
+This capability adds "skip" line to the protocol, which passes --skip
+and --skip-hash to pack-objects. When "skip" line is present, given
+the same set of input from the client (e.g. have, want and shallow
+lines, "skip" line excluded), the exact same pack must be produced.
+
diff --git a/upload-pack.c b/upload-pack.c
index b3f6653..5565afe 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -53,6 +53,9 @@ static int use_sideband;
static int advertise_refs;
static int stateless_rpc;
+static struct object_id skip_hash;
+static int skip_opt = -1;
+
static void reset_timeout(void)
{
alarm(timeout);
@@ -90,7 +93,7 @@ static void create_pack_file(void)
"corruption on the remote side.";
int buffered = -1;
ssize_t sz;
- const char *argv[13];
+ const char *argv[17];
int i, arg = 0;
FILE *pipe_fd;
@@ -112,6 +115,14 @@ static void create_pack_file(void)
argv[arg++] = "--delta-base-offset";
if (use_include_tag)
argv[arg++] = "--include-tag";
+ if (skip_opt >= 0) {
+ argv[arg++] = "--skip";
+ argv[arg++] = xstrfmt("%d", skip_opt);
+ if (skip_opt > 0) {
+ argv[arg++] = "--skip-hash";
+ argv[arg++] = xstrdup(oid_to_hex(&skip_hash));
+ }
+ }
argv[arg++] = NULL;
pack_objects.in = -1;
@@ -550,6 +561,8 @@ static void receive_needs(void)
const char *features;
unsigned char sha1_buf[20];
char *line = packet_read_line(0, NULL);
+ const char *arg;
+
reset_timeout();
if (!line)
break;
@@ -577,6 +590,19 @@ static void receive_needs(void)
die("Invalid deepen: %s", line);
continue;
}
+ if (skip_prefix(line, "skip ", &arg)) {
+ char *end = NULL;
+
+ if (get_oid_hex(arg, &skip_hash))
+ die("invalid skip line: %s", line);
+ arg += 40;
+ if (*arg++ != ' ')
+ die("invalid skip line: %s", line);
+ skip_opt = strtol(arg, &end, 0);
+ if (!end || *end || skip_opt < 0)
+ die("Invalid skip line: %s", line);
+ continue;
+ }
if (!starts_with(line, "want ") ||
get_sha1_hex(line+5, sha1_buf))
die("git upload-pack: protocol error, "
@@ -725,7 +751,7 @@ static int send_ref(const char *refname, const struct object_id *oid,
{
static const char *capabilities = "multi_ack thin-pack side-band"
" side-band-64k ofs-delta shallow no-progress"
- " include-tag multi_ack_detailed";
+ " include-tag multi_ack_detailed partial";
const char *refname_nons = strip_namespace(refname);
struct object_id peeled;
--
2.7.0.377.g4cd97dd
next prev parent reply other threads:[~2016-02-05 8:58 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-05 8:57 [PATCH 0/8] Resumable clone revisited, proof of concept Nguyễn Thái Ngọc Duy
2016-02-05 8:57 ` [PATCH 1/8] pack-objects: add --skip and --skip-hash Nguyễn Thái Ngọc Duy
2016-02-05 9:20 ` Johannes Schindelin
2016-02-05 8:57 ` [PATCH 2/8] pack-objects: produce a stable pack when --skip is given Nguyễn Thái Ngọc Duy
2016-02-05 18:43 ` Junio C Hamano
2016-02-05 23:25 ` Duy Nguyen
2016-02-06 0:48 ` Junio C Hamano
2016-02-08 5:23 ` Duy Nguyen
2016-02-05 8:57 ` [PATCH 3/8] index-pack: add --append-pack=<path> Nguyễn Thái Ngọc Duy
2016-02-05 8:57 ` Nguyễn Thái Ngọc Duy [this message]
2016-02-05 9:18 ` [PATCH 4/8] upload-pack: new capability to pass --skip* to pack-objects Johannes Schindelin
2016-02-05 8:57 ` [PATCH 5/8] fetch-pack.c: send "skip" line " Nguyễn Thái Ngọc Duy
2016-02-07 8:57 ` Eric Sunshine
2016-02-05 8:57 ` [PATCH 6/8] fetch: add --resume-pack=<path> Nguyễn Thái Ngọc Duy
2016-02-05 8:57 ` [PATCH 7/8] index-pack: --append-pack implies --strict Nguyễn Thái Ngọc Duy
2016-02-07 9:02 ` Eric Sunshine
2016-02-05 8:57 ` [PATCH 8/8] one ugly test to verify basic functionality Nguyễn Thái Ngọc Duy
2016-02-05 11:57 ` Elia Pinto
2016-02-05 13:02 ` Duy Nguyen
2016-02-05 13:33 ` Elia Pinto
2016-02-05 13:20 ` Johannes Schindelin
2016-02-05 13:38 ` Elia Pinto
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454662677-15137-5-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.