summaryrefslogtreecommitdiff
path: root/remote-curl.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2009-10-30 17:47:29 -0700
committerJunio C Hamano <gitster@pobox.com>2009-10-30 19:20:54 -0700
commitef08ef9ea0a271e5be5844408d2496a946d6e8d9 (patch)
tree895858e10e8007ed8dab29f5eea1888c216a4a4f /remote-curl.c
parent292ce46b60e2c12450c5c21044acf9c41bd837df (diff)
downloadgit-ef08ef9ea0a271e5be5844408d2496a946d6e8d9.tar.gz
remote-helpers: Support custom transport options
Some transports, like the native pack transport implemented by fetch-pack, support useful features like depth or include tags. These should be exposed if the underlying helper knows how to use them. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> CC: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'remote-curl.c')
-rw-r--r--remote-curl.c74
1 files changed, 73 insertions, 1 deletions
diff --git a/remote-curl.c b/remote-curl.c
index 22cd5c5fd2..0951f11615 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -9,12 +9,61 @@ static struct remote *remote;
static const char *url;
static struct walker *walker;
+struct options {
+ int verbosity;
+ unsigned long depth;
+ unsigned progress : 1,
+ followtags : 1;
+};
+static struct options options;
+
static void init_walker(void)
{
if (!walker)
walker = get_http_walker(url, remote);
}
+static int set_option(const char *name, const char *value)
+{
+ if (!strcmp(name, "verbosity")) {
+ char *end;
+ int v = strtol(value, &end, 10);
+ if (value == end || *end)
+ return -1;
+ options.verbosity = v;
+ return 0;
+ }
+ else if (!strcmp(name, "progress")) {
+ if (!strcmp(value, "true"))
+ options.progress = 1;
+ else if (!strcmp(value, "false"))
+ options.progress = 0;
+ else
+ return -1;
+ return 1 /* TODO implement later */;
+ }
+ else if (!strcmp(name, "depth")) {
+ char *end;
+ unsigned long v = strtoul(value, &end, 10);
+ if (value == end || *end)
+ return -1;
+ options.depth = v;
+ return 1 /* TODO implement later */;
+ }
+ else if (!strcmp(name, "followtags")) {
+ if (!strcmp(value, "true"))
+ options.followtags = 1;
+ else if (!strcmp(value, "false"))
+ options.followtags = 0;
+ else
+ return -1;
+ return 1 /* TODO implement later */;
+ }
+ else {
+ return 1 /* unsupported */;
+ }
+}
+
static struct ref *get_refs(void)
{
struct strbuf buffer = STRBUF_INIT;
@@ -99,7 +148,7 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
walker->get_all = 1;
walker->get_tree = 1;
walker->get_history = 1;
- walker->get_verbosely = 0;
+ walker->get_verbosely = options.verbosity >= 3;
walker->get_recover = 0;
ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
@@ -173,6 +222,9 @@ int main(int argc, const char **argv)
return 1;
}
+ options.verbosity = 1;
+ options.progress = !!isatty(2);
+
remote = remote_get(argv[1]);
if (argc > 2) {
@@ -198,8 +250,28 @@ int main(int argc, const char **argv)
}
printf("\n");
fflush(stdout);
+ } else if (!prefixcmp(buf.buf, "option ")) {
+ char *name = buf.buf + strlen("option ");
+ char *value = strchr(name, ' ');
+ int result;
+
+ if (value)
+ *value++ = '\0';
+ else
+ value = "true";
+
+ result = set_option(name, value);
+ if (!result)
+ printf("ok\n");
+ else if (result < 0)
+ printf("error invalid value\n");
+ else
+ printf("unsupported\n");
+ fflush(stdout);
+
} else if (!strcmp(buf.buf, "capabilities")) {
printf("fetch\n");
+ printf("option\n");
printf("\n");
fflush(stdout);
} else {