{"thread":{"id":"42380","subject":"[PATCH 0/2] git-prime-clone","startedAt":"2016-05-19T05:07:28Z","lastAt":"2016-05-19T05:07:30Z","messageCount":3,"participants":["Kevin Wern"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"286961","messageId":"1463634450-28265-1-git-send-email-kevin.m.wern@gmail.com","threadId":"42380","inReplyTo":null,"subject":"[PATCH 0/2] git-prime-clone","fromName":"Kevin Wern","fromEmail":"kevin.m.wern@gmail.com","sentAt":"2016-05-19T05:07:28Z","receivedAt":"2016-05-19T05:07:28Z","isPatch":true,"sender":{"key":"kevin.m.wern@gmail.com","avatar":null},"body":"Hey, all,\n\nI asked about writing a portion of resumable clone about two months ago,\nand decided to write the prime-clone program. I got bogged down by work\nin the time since and have just gotten started working on the feature maybe\na week or two ago.\n\nAnyway, I sent along a very rough version of prime-clone, with endpoints added\nfor http-backend and daemon. My hope is to use this as a jumping-off point to\ncreate the prime_clone method for the client transport for .pack files only,\nbut I wanted to get some feedback about the configuration as I move along, as\nI'm sure there are a lot of design considerations I missed, and I want to keep\nthis as easily extensible to the other types as possible.\n\nApologies for not keeping everyone in the loop. I should be working on this\nmore actively from this point onwards.\n\n-Kevin Wern\n\n--\n\n[PATCH 1/2] Resumable clone: create git-prime-clone (Draft)\n[PATCH 2/2] Resumable clone: add endpoints for prime clone (Draft)\n"},{"id":"286962","messageId":"1463634450-28265-2-git-send-email-kevin.m.wern@gmail.com","threadId":"42380","inReplyTo":"1463634450-28265-1-git-send-email-kevin.m.wern@gmail.com","subject":"[PATCH 1/2] Resumable clone: create git-prime-clone (Draft)","fromName":"Kevin Wern","fromEmail":"kevin.m.wern@gmail.com","sentAt":"2016-05-19T05:07:29Z","receivedAt":"2016-05-19T05:07:29Z","isPatch":true,"sender":{"key":"kevin.m.wern@gmail.com","avatar":null},"body":"Create a bare-bones version of git-prime-clone, which returns the\nlocation of an alternate resource specified by the server that the\nclient should fetch and build before returning to perform an incremental\nfetch.\n\nAt this point, no validation is performed of the file's existence, the\nfile's validity as a fully connected archive, or its correspondence\nto the specified resource type in .git/config.\n---\n Makefile      |  1 +\n prime-clone.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 88 insertions(+)\n create mode 100644 prime-clone.c\n\ndiff --git a/Makefile b/Makefile\nindex 3f03366..34febdc 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -579,6 +579,7 @@ PROGRAM_OBJS += sh-i18n--envsubst.o\n PROGRAM_OBJS += shell.o\n PROGRAM_OBJS += show-index.o\n PROGRAM_OBJS += upload-pack.o\n+PROGRAM_OBJS += prime-clone.o\n PROGRAM_OBJS += remote-testsvn.o\n \n # Binary suffix, set to .exe for Windows builds\ndiff --git a/prime-clone.c b/prime-clone.c\nnew file mode 100644\nindex 0000000..74fd8d4\n--- /dev/null\n+++ b/prime-clone.c\n@@ -0,0 +1,87 @@\n+#include \"cache.h\"\n+#include \"refs.h\"\n+\n+#define PRIME_CLONE_ENABLED 1\n+\n+static const char prime_clone_usage[] = \"git prime-clone [--strict] <dir>\";\n+\n+static unsigned int enabled;\n+static const char *url = \"\\0\";\n+static const char *filetype = \"\\0\";\n+\n+static void prime_clone(void)\n+{\n+\tif (enabled)\n+\t{\n+\t\tif (strlen(url) != 0 && strlen(filetype) != 0) {\n+\t\t\tpacket_write(1, \"url %s\\n\", url);\n+\t\t\tpacket_write(1, \"filetype %s\\n\", filetype);\n+\t\t}\n+\t\telse {\n+\t\t\tpacket_write(1, \"prime-clone not properly configured\\n\");\n+\t\t}\n+\t}\n+\telse {\n+\t\tpacket_write(1, \"prime-clone not enabled\\n\");\n+\t}\n+\tpacket_flush(1);\n+}\n+\n+static int prime_clone_config(const char *var, const char *value, void *unused)\n+{\n+\tif (!strcmp(\"primeclone.url\",var)) {\n+\t\treturn git_config_pathname(&url, var, value);\n+\t}\n+\tif (!strcmp(\"primeclone.enabled\",var)) {\n+\t\tif (git_config_bool(var, value))\n+\t\t\tenabled = PRIME_CLONE_ENABLED;\n+\t\telse\n+\t\t\tenabled = ~PRIME_CLONE_ENABLED;\n+\t}\n+\tif (!strcmp(\"primeclone.filetype\",var)) {\n+\t\treturn git_config_string(&filetype, var, value);\n+\t}\n+\treturn parse_hide_refs_config(var, value, \"primeclone\");\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\tchar *dir;\n+\tint i;\n+\tint strict = 0;\n+\n+\tgit_setup_gettext();\n+\n+\tpacket_trace_identity(\"prime-clone\");\n+\tgit_extract_argv0_path(argv[0]);\n+\tcheck_replace_refs = 0;\n+\n+\tfor (i = 1; i < argc; i++) {\n+\t\tchar *arg = argv[i];\n+\n+\t\tif (arg[0] != '-')\n+\t\t\tbreak;\n+\t\tif (!strcmp(arg, \"--strict\")) {\n+\t\t\tstrict = 1;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tif (!strcmp(arg, \"--\")) {\n+\t\t\ti++;\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+\n+\tif (i != argc-1)\n+\t\tusage(prime_clone_usage);\n+\n+\tsetup_path();\n+\n+\tdir = argv[i];\n+\n+\tif (!enter_repo(dir, strict))\n+\t\tdie(\"'%s' does not appear to be a git repository\", dir);\n+\n+\tgit_config(prime_clone_config, NULL);\n+\tprime_clone();\n+\treturn 0;\n+}\n-- \n1.9.1\n"},{"id":"286963","messageId":"1463634450-28265-3-git-send-email-kevin.m.wern@gmail.com","threadId":"42380","inReplyTo":"1463634450-28265-1-git-send-email-kevin.m.wern@gmail.com","subject":"[PATCH 2/2] Resumable clone: add endpoints for prime clone (Draft)","fromName":"Kevin Wern","fromEmail":"kevin.m.wern@gmail.com","sentAt":"2016-05-19T05:07:30Z","receivedAt":"2016-05-19T05:07:30Z","isPatch":true,"sender":{"key":"kevin.m.wern@gmail.com","avatar":null},"body":"Add endpoints for prime-clone in http service and git daemon\n---\n daemon.c       | 7 +++++++\n http-backend.c | 1 +\n 2 files changed, 8 insertions(+)\n\ndiff --git a/daemon.c b/daemon.c\nindex 8d45c33..2ddc7f7 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -475,10 +475,17 @@ static int receive_pack(void)\n \treturn run_service_command(argv);\n }\n \n+static int prime_clone(void)\n+{\n+\tstatic const char *argv[] = { \"prime-clone\", \".\", NULL };\n+\treturn run_service_command(argv);\n+}\n+\n static struct daemon_service daemon_service[] = {\n \t{ \"upload-archive\", \"uploadarch\", upload_archive, 0, 1 },\n \t{ \"upload-pack\", \"uploadpack\", upload_pack, 1, 1 },\n \t{ \"receive-pack\", \"receivepack\", receive_pack, 0, 1 },\n+\t{ \"prime-clone\", \"primeclone\", prime_clone, 0, 1 },\n };\n \n static void enable_service(const char *name, int ena)\ndiff --git a/http-backend.c b/http-backend.c\nindex 2148814..a338e2a 100644\n--- a/http-backend.c\n+++ b/http-backend.c\n@@ -27,6 +27,7 @@ struct rpc_service {\n static struct rpc_service rpc_service[] = {\n \t{ \"upload-pack\", \"uploadpack\", 1, 1 },\n \t{ \"receive-pack\", \"receivepack\", 0, -1 },\n+\t{ \"prime-clone\", \"primeclone\", 0, -1 },\n };\n \n static struct string_list *get_parameters(void)\n-- \n1.9.1\n"}]}