* [PATCH 0/2] git-prime-clone
@ 2016-05-19 5:07 Kevin Wern
2016-05-19 5:07 ` [PATCH 1/2] Resumable clone: create git-prime-clone (Draft) Kevin Wern
2016-05-19 5:07 ` [PATCH 2/2] Resumable clone: add endpoints for prime clone (Draft) Kevin Wern
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wern @ 2016-05-19 5:07 UTC (permalink / raw)
To: git
Hey, all,
I asked about writing a portion of resumable clone about two months ago,
and decided to write the prime-clone program. I got bogged down by work
in the time since and have just gotten started working on the feature maybe
a week or two ago.
Anyway, I sent along a very rough version of prime-clone, with endpoints added
for http-backend and daemon. My hope is to use this as a jumping-off point to
create the prime_clone method for the client transport for .pack files only,
but I wanted to get some feedback about the configuration as I move along, as
I'm sure there are a lot of design considerations I missed, and I want to keep
this as easily extensible to the other types as possible.
Apologies for not keeping everyone in the loop. I should be working on this
more actively from this point onwards.
-Kevin Wern
--
[PATCH 1/2] Resumable clone: create git-prime-clone (Draft)
[PATCH 2/2] Resumable clone: add endpoints for prime clone (Draft)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] Resumable clone: create git-prime-clone (Draft)
2016-05-19 5:07 [PATCH 0/2] git-prime-clone Kevin Wern
@ 2016-05-19 5:07 ` Kevin Wern
2016-05-19 5:07 ` [PATCH 2/2] Resumable clone: add endpoints for prime clone (Draft) Kevin Wern
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wern @ 2016-05-19 5:07 UTC (permalink / raw)
To: git; +Cc: Kevin Wern
Create a bare-bones version of git-prime-clone, which returns the
location of an alternate resource specified by the server that the
client should fetch and build before returning to perform an incremental
fetch.
At this point, no validation is performed of the file's existence, the
file's validity as a fully connected archive, or its correspondence
to the specified resource type in .git/config.
---
Makefile | 1 +
prime-clone.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+)
create mode 100644 prime-clone.c
diff --git a/Makefile b/Makefile
index 3f03366..34febdc 100644
--- a/Makefile
+++ b/Makefile
@@ -579,6 +579,7 @@ PROGRAM_OBJS += sh-i18n--envsubst.o
PROGRAM_OBJS += shell.o
PROGRAM_OBJS += show-index.o
PROGRAM_OBJS += upload-pack.o
+PROGRAM_OBJS += prime-clone.o
PROGRAM_OBJS += remote-testsvn.o
# Binary suffix, set to .exe for Windows builds
diff --git a/prime-clone.c b/prime-clone.c
new file mode 100644
index 0000000..74fd8d4
--- /dev/null
+++ b/prime-clone.c
@@ -0,0 +1,87 @@
+#include "cache.h"
+#include "refs.h"
+
+#define PRIME_CLONE_ENABLED 1
+
+static const char prime_clone_usage[] = "git prime-clone [--strict] <dir>";
+
+static unsigned int enabled;
+static const char *url = "\0";
+static const char *filetype = "\0";
+
+static void prime_clone(void)
+{
+ if (enabled)
+ {
+ if (strlen(url) != 0 && strlen(filetype) != 0) {
+ packet_write(1, "url %s\n", url);
+ packet_write(1, "filetype %s\n", filetype);
+ }
+ else {
+ packet_write(1, "prime-clone not properly configured\n");
+ }
+ }
+ else {
+ packet_write(1, "prime-clone not enabled\n");
+ }
+ packet_flush(1);
+}
+
+static int prime_clone_config(const char *var, const char *value, void *unused)
+{
+ if (!strcmp("primeclone.url",var)) {
+ return git_config_pathname(&url, var, value);
+ }
+ if (!strcmp("primeclone.enabled",var)) {
+ if (git_config_bool(var, value))
+ enabled = PRIME_CLONE_ENABLED;
+ else
+ enabled = ~PRIME_CLONE_ENABLED;
+ }
+ if (!strcmp("primeclone.filetype",var)) {
+ return git_config_string(&filetype, var, value);
+ }
+ return parse_hide_refs_config(var, value, "primeclone");
+}
+
+int main(int argc, char **argv)
+{
+ char *dir;
+ int i;
+ int strict = 0;
+
+ git_setup_gettext();
+
+ packet_trace_identity("prime-clone");
+ git_extract_argv0_path(argv[0]);
+ check_replace_refs = 0;
+
+ for (i = 1; i < argc; i++) {
+ char *arg = argv[i];
+
+ if (arg[0] != '-')
+ break;
+ if (!strcmp(arg, "--strict")) {
+ strict = 1;
+ continue;
+ }
+ if (!strcmp(arg, "--")) {
+ i++;
+ break;
+ }
+ }
+
+ if (i != argc-1)
+ usage(prime_clone_usage);
+
+ setup_path();
+
+ dir = argv[i];
+
+ if (!enter_repo(dir, strict))
+ die("'%s' does not appear to be a git repository", dir);
+
+ git_config(prime_clone_config, NULL);
+ prime_clone();
+ return 0;
+}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] Resumable clone: add endpoints for prime clone (Draft)
2016-05-19 5:07 [PATCH 0/2] git-prime-clone Kevin Wern
2016-05-19 5:07 ` [PATCH 1/2] Resumable clone: create git-prime-clone (Draft) Kevin Wern
@ 2016-05-19 5:07 ` Kevin Wern
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wern @ 2016-05-19 5:07 UTC (permalink / raw)
To: git; +Cc: Kevin Wern
Add endpoints for prime-clone in http service and git daemon
---
daemon.c | 7 +++++++
http-backend.c | 1 +
2 files changed, 8 insertions(+)
diff --git a/daemon.c b/daemon.c
index 8d45c33..2ddc7f7 100644
--- a/daemon.c
+++ b/daemon.c
@@ -475,10 +475,17 @@ static int receive_pack(void)
return run_service_command(argv);
}
+static int prime_clone(void)
+{
+ static const char *argv[] = { "prime-clone", ".", NULL };
+ return run_service_command(argv);
+}
+
static struct daemon_service daemon_service[] = {
{ "upload-archive", "uploadarch", upload_archive, 0, 1 },
{ "upload-pack", "uploadpack", upload_pack, 1, 1 },
{ "receive-pack", "receivepack", receive_pack, 0, 1 },
+ { "prime-clone", "primeclone", prime_clone, 0, 1 },
};
static void enable_service(const char *name, int ena)
diff --git a/http-backend.c b/http-backend.c
index 2148814..a338e2a 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -27,6 +27,7 @@ struct rpc_service {
static struct rpc_service rpc_service[] = {
{ "upload-pack", "uploadpack", 1, 1 },
{ "receive-pack", "receivepack", 0, -1 },
+ { "prime-clone", "primeclone", 0, -1 },
};
static struct string_list *get_parameters(void)
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-05-19 5:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-19 5:07 [PATCH 0/2] git-prime-clone Kevin Wern
2016-05-19 5:07 ` [PATCH 1/2] Resumable clone: create git-prime-clone (Draft) Kevin Wern
2016-05-19 5:07 ` [PATCH 2/2] Resumable clone: add endpoints for prime clone (Draft) Kevin Wern
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 NNTP newsgroup(s).