git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] submodule: explain first attempt failure clearly
Date: Wed, 13 Mar 2019 11:04:34 +0900	[thread overview]
Message-ID: <xmqqimwnfs25.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <20190312174522.89306-1-jonathantanmy@google.com> (Jonathan Tan's message of "Tue, 12 Mar 2019 10:45:22 -0700")

Jonathan Tan <jonathantanmy@google.com> writes:

> When cloning with --recurse-submodules a superproject with at least one
> submodule with HEAD pointing to an unborn branch, the clone goes
> something like this:
>
> 	Cloning into 'test'...
> 	<messages about cloning of superproject>
> 	Submodule '<name>' (<uri>) registered for path '<submodule path>'
> 	Cloning into '<submodule path>'...
> 	fatal: Couldn't find remote ref HEAD
> 	Unable to fetch in submodule path '<submodule path>'
> 	<messages about fetching with SHA-1>
> 	From <uri>
> 	 * branch            <hash> -> FETCH_HEAD
> 	Submodule path '<submodule path>': checked out '<hash>'
>
> In other words, first, a fetch is done with no hash arguments (that is,
> a fetch of HEAD) resulting in a "Couldn't find remote ref HEAD" error;
> then, a fetch is done given a hash, which succeeds.
>
> The fetch given a hash was added in fb43e31f2b ("submodule: try harder
> to fetch needed sha1 by direct fetching sha1", 2016-02-24), and the
> "Unable to fetch..." message was downgraded from a fatal error to a
> notice in e30d833671 ("git-submodule.sh: try harder to fetch a
> submodule", 2018-05-16).
>
> This commit improves the notice to be clearer that we are retrying the
> fetch, and that the previous messages do not necessarily indicate that
> the whole command fails. In other words:

"additional" is relative to something.  Is it additional to status-quo?
>
>  - If the HEAD-fetch succeeds and we then have the commit we want, no
>    extra messages are printed.
>  - If the HEAD-fetch succeeds and we do not have the commit we want, but
>    the hash-fetch succeeds, no additional messages are printed.

For example, the user would be helped to be told that we succeeded
doing a pointless fetch and we now are going to make a more specific
"give me that commit" fetch to see if it helps.  These may already
be given with the current code, or may not be (I don't know
offhand), but "no additional messages" does not help me in knowing
if the code with this patch would give such a hint to the users.

>  - If the HEAD-fetch succeeds and we do not have the commit we want, but
>    the hash-fetch fails, this is a fatal error.
>  - If the HEAD-fetch fails, we print the notice, and if the hash-fetch
>    succeeds, no additional messages are printed.
>  - If the HEAD-fetch fails, we print the notice, and if the hash-fetch
>    fails, this is a fatal error.
>
> It could be said that we should just eliminate the HEAD-fetch
> altogether, but that changes some behavior (in particular, some refs
> that were opportunistically updated would no longer be), so I have left
> that alone for now.

OK, that sounds good decision for this patch.

A more fundamental question is why these submodule repositories do
not have HEAD to recommend from which branch to fetch by default,
and if we can do something about it so that HEAD-fetch fails less
often for the users.

> diff --git a/git-submodule.sh b/git-submodule.sh
> index 514ede2596..2c0fb6d723 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -594,7 +594,7 @@ cmd_update()
>  				# is not reachable from a ref.
>  				is_tip_reachable "$sm_path" "$sha1" ||
>  				fetch_in_submodule "$sm_path" $depth ||
> -				say "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")"
> +				say "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'; trying to directly fetch \$sha1:")"
>  
>  				# Now we tried the usual fetch, but $sha1 may
>  				# not be reachable from any of the refs

Obviously good ;-)

Thanks.

> diff --git a/submodule.c b/submodule.c
> index 21cf50ca15..b16c0ecc95 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -1548,6 +1548,13 @@ static int fetch_finish(int retvalue, struct strbuf *err,
>  	struct oid_array *commits;
>  
>  	if (retvalue)
> +		/*
> +		 * NEEDSWORK: This indicates that the overall fetch
> +		 * failed, even though there may be a subsequent fetch
> +		 * by commit hash that might work. It may be a good
> +		 * idea to not indicate failure in this case, and only
> +		 * indicate failure if the subsequent fetch fails.
> +		 */
>  		spf->result = 1;
>  
>  	if (!task || !task->sub)

  reply	other threads:[~2019-03-13  2:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-12 17:45 [PATCH] submodule: explain first attempt failure clearly Jonathan Tan
2019-03-13  2:04 ` Junio C Hamano [this message]
2019-03-13 17:57 ` [PATCH v2] " Jonathan Tan
2019-03-13 23: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=xmqqimwnfs25.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    /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).