Signed-off-by: Nguyễn Thái Ngọc Duy <pclo...@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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to