git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [EXTERNAL] Re: Error handling when giving empty command line arguments

From
OJOlsson John <john.olsson@saabgroup.com>
Date
May 25, 2022, 07:32 UTC
Message-ID
<8767dbe0c22540a4ab3e18684aa7e030@saabgroup.com>
In-Reply-To
<xmqq35gyee7r.fsf@gitster.g>
Show 9 quoted lines
> 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.
That is exactly my point! I was thinking along the lines that perhaps the Git command(s) could complain about that it got an empty string as an argument since that is probably a mistake by the user due to that an empty string is neither a path, a URL/URI, or an option. It is thus an error case of its own.
The git checkout command actually complains about the case when you give it an empty string

$ git checkout "" feature/foobar fatal: empty string is not a valid pathspec. please use . instead if you want to match all paths

When it comes to git fetch it could assume that the given empty string is either a path or a URL/URI and write a similar error message. For instance

$ git fetch "" fatal: empty string is not a valid pathspec or URL; see 'git help fetch' for valid syntax

For me there is an important distinction between "no path specified" and "empty string". The former says that an argument is missing and the latter says that an argument is indeed given but it is an empty string.
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “Error handling when giving empty command line arguments”
  1. Olsson JohnMay 24, 2022
  2. Junio C HamanoMay 24, 2022
  3. Olsson JohnMay 25, 2022
  4. Junio C HamanoMay 25, 2022
  5. Kevin DaudtMay 25, 2022
  6. Olsson JohnMay 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.