summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 85682c1)
raw | patch | inline | side by side (parent: 85682c1)
author | Shawn O. Pearce <spearce@spearce.org> | |
Tue, 18 Sep 2007 08:54:57 +0000 (04:54 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 19 Sep 2007 10:22:31 +0000 (03:22 -0700) |
If a transport doesn't support an option we already are telling
the higher level application (fetch or push) that the option is not
valid by sending back a >0 return value from transport_set_option
so there's not a strong motivation to have the function perform the
output itself. Instead we should let the higher level application
do the output if it is necessary. This avoids always telling the
user that depth isn't supported on HTTP urls even when they did
not pass a --depth option to git-fetch.
If the user passes an option and the option value is invalid we now
properly die in git-fetch instead of just spitting out a message
and running anyway. This mimics prior behavior better where
incorrect/malformed options are not accepted by the process.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
the higher level application (fetch or push) that the option is not
valid by sending back a >0 return value from transport_set_option
so there's not a strong motivation to have the function perform the
output itself. Instead we should let the higher level application
do the output if it is necessary. This avoids always telling the
user that depth isn't supported on HTTP urls even when they did
not pass a --depth option to git-fetch.
If the user passes an option and the option value is invalid we now
properly die in git-fetch instead of just spitting out a message
and running anyway. This mimics prior behavior better where
incorrect/malformed options are not accepted by the process.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
builtin-fetch.c | patch | blob | history | |
transport.c | patch | blob | history |
diff --git a/builtin-fetch.c b/builtin-fetch.c
index 670af0b53f72e370368fddc1e911504a01979f6a..b9722e5fbd1c727c258d3efe07923d0c99c3f250 100644 (file)
--- a/builtin-fetch.c
+++ b/builtin-fetch.c
return 0;
}
+static void set_option(const char *name, const char *value)
+{
+ int r = transport_set_option(transport, name, value);
+ if (r < 0)
+ die("Option \"%s\" value \"%s\" is not valid for %s\n",
+ name, value, transport->url);
+ if (r > 0)
+ warning("Option \"%s\" is ignored for %s\n",
+ name, transport->url);
+}
+
int cmd_fetch(int argc, const char **argv, const char *prefix)
{
struct remote *remote;
if (quiet)
transport->verbose = 0;
if (upload_pack)
- transport_set_option(transport, TRANS_OPT_UPLOADPACK, upload_pack);
+ set_option(TRANS_OPT_UPLOADPACK, upload_pack);
if (keep)
- transport_set_option(transport, TRANS_OPT_KEEP, "yes");
- transport_set_option(transport, TRANS_OPT_DEPTH, depth);
+ set_option(TRANS_OPT_KEEP, "yes");
+ if (depth)
+ set_option(TRANS_OPT_DEPTH, depth);
if (!transport->url)
die("Where do you want to fetch from today?");
diff --git a/transport.c b/transport.c
index 7f94d30f95c26b8139fe7d63059633303f719d66..cc76e3f59ba47a5c76e375f53ff3ccf712322e59 100644 (file)
--- a/transport.c
+++ b/transport.c
int transport_set_option(struct transport *transport,
const char *name, const char *value)
{
- int ret = 1;
if (transport->ops->set_option)
- ret = transport->ops->set_option(transport, name, value);
- if (ret < 0)
- fprintf(stderr, "For '%s' option %s cannot be set to '%s'\n",
- transport->url, name, value);
- if (ret > 0)
- fprintf(stderr, "For '%s' option %s is ignored\n",
- transport->url, name);
- return ret;
+ return transport->ops->set_option(transport, name, value);
+ return 1;
}
int transport_push(struct transport *transport,