From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org, spearce@spearce.org
Subject: Re: [PATCH 1/2] clone, fetch: remove redundant transport check
Date: Thu, 14 Dec 2017 14:12:53 -0800 [thread overview]
Message-ID: <xmqqmv2lrmai.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <d1fd27a5a102129aa16ecf6e6c19014f7b60b543.1513287544.git.jonathantanmy@google.com> (Jonathan Tan's message of "Thu, 14 Dec 2017 13:44:44 -0800")
Jonathan Tan <jonathantanmy@google.com> writes:
> Prior to commit a2d725b7bdf7 ("Use an external program to implement
> fetching with curl", 2009-08-05), if Git was compiled with NO_CURL, the
> get_refs_list and fetch methods in struct transport might not be
> populated, hence the checks in clone and fetch. After that commit, all
> transports populate get_refs_list and fetch, making the checks in clone
> and fetch redundant. Remove those checks.
I do not agree with the above justification. We could view these
checks as serving to future-proof the callers for (initially buggy)
transports that we have not seen, so the current set of transports
not triggering is not a good enough reason to remove them.
But I do agree with the removal of these checks for another reason.
A call into transport_get_remote_refs() or transport_fetch_refs()
would segfault if these necessary fields are not filled in a buggy
transport under development anyway.
And more importantly, if it is desirable to have a check that is
more friendly than merely segfaulting, such a check must be added to
the implementation of transport API that knows the implementation
details like "fetching would require get_refs_list and fetch
fields"; the consumers of the API is a wrong place to do so.
Thanks.
> Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
> ---
> builtin/clone.c | 3 ---
> builtin/fetch.c | 3 ---
> 2 files changed, 6 deletions(-)
>
> diff --git a/builtin/clone.c b/builtin/clone.c
> index dbddd98f8..979af0383 100644
> --- a/builtin/clone.c
> +++ b/builtin/clone.c
> @@ -1083,9 +1083,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
> warning(_("--local is ignored"));
> transport->cloning = 1;
>
> - if (!transport->get_refs_list || (!is_local && !transport->fetch))
> - die(_("Don't know how to clone %s"), transport->url);
> -
> transport_set_option(transport, TRANS_OPT_KEEP, "yes");
>
> if (option_depth)
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 225c73492..09eb1fc17 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -1094,9 +1094,6 @@ static int do_fetch(struct transport *transport,
> tags = TAGS_UNSET;
> }
>
> - if (!transport->get_refs_list || !transport->fetch)
> - die(_("Don't know how to fetch from %s"), transport->url);
> -
> /* if not appending, truncate FETCH_HEAD */
> if (!append && !dry_run) {
> retcode = truncate_fetch_head();
next prev parent reply other threads:[~2017-12-14 22:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-14 21:44 [PATCH 0/2] More transport API improvements Jonathan Tan
2017-12-14 21:44 ` [PATCH 1/2] clone, fetch: remove redundant transport check Jonathan Tan
2017-12-14 22:12 ` Junio C Hamano [this message]
2017-12-14 21:44 ` [PATCH 2/2] transport: make transport vtable more private Jonathan Tan
2017-12-14 22:13 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqmv2lrmai.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=jonathantanmy@google.com \
--cc=spearce@spearce.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).