git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Olsson John <john.olsson@saabgroup.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Error handling when giving empty command line arguments
Date: Tue, 24 May 2022 15:51:52 -0700	[thread overview]
Message-ID: <xmqq35gyee7r.fsf@gitster.g> (raw)
In-Reply-To: dc08a8ee5ed64850872fd6529d1462e1@saabgroup.com

Olsson John <john.olsson@saabgroup.com> writes:

>   git fetch "${force}"
> ...
>   $ git fetch ""
>   fatal: no path specified; see 'git help pull' for valid url syntax
>   $
> ...
> That is, 'git fetch' does not check if the given string is an
> empty string before writing the error message. The empty string is
> completely unrelated to any path/URI and in this case it was not
> that helpful.

The user is not giving enough information to Git to allow it to tell
if "git fetch ''" it got came from any of these with unset variable:

	$ git fetch "$path"
	$ git fetch "$url"
	$ git fetch "$force"

because all Git sees is an empty string.

It is unfair to complain "is completely unrelated".  The user didn't
give enough information to even allow Git to tell if it is or is not
related.

The message _is_ complaining about a malformed URL.  You can fetch
from a local repository by specifying the path to the directory, or
you can fetch from a remote repository by specifying a URL.  Since
"" turns out to be neither a valid path or URL, the message hints
that it didn't see any path or valid url on the command line.  This
is coming from connect.c::parse_connect_url() that does not know
which end-user facing command ended up reaching there, so it is
understandable that it picked a command that ought to be more
familiar to users, i.e. "pull".  FWIW, 

	$ git ls-remote ""

would also give the same message that refers to "git help pull".

By the way, the "fatal" message talks about 'git help pull'; I
wonder if it should say "git help fetch" instead, although they will
refer to the same text included from Documentation/urls.txt.

Thanks.

  reply	other threads:[~2022-05-24 22:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-24 13:25 Error handling when giving empty command line arguments Olsson John
2022-05-24 22:51 ` Junio C Hamano [this message]
2022-05-25  7:32   ` [EXTERNAL] " Olsson John
2022-05-25 15:46     ` Junio C Hamano
2022-05-25  4:41 ` Kevin Daudt
2022-05-25  7:03   ` [EXTERNAL] " Olsson John

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=xmqq35gyee7r.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=john.olsson@saabgroup.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).