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

Re: [PATCH] branch: return error when --list finds no matches

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 4, 2021, 01:27 UTC
Message-ID
<xmqqr1kvemid.fsf@gitster.c.googlers.com>
In-Reply-To
<pull.892.git.1614793491538.gitgitgadget@gmail.com>
"Josh Hunt via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> From: Josh Hunt <johunt@akamai.com>
>
> Currently git branch --list foo always returns an exit status of 0 even
> when the branch being searched for does not exist. Now an error is printed
> and returns a non-zero exit status.

Explaining what happens in the current code upfront is a good thing and is in line with the convention used in our project, which is good. But drop "currently" from there.

Strictly speaking, it is not "always". In a corrupt repository, it is likely to show a proper error message and die.

Also explaining what you want to happen before the end of the log message is good.

But the proposed log message lacks why it is a good idea to make such a change, which is the most important part.

If you ask me, I would say that the command was asked to show any branches, if exist, that match the given pattern, and did what it was asked to do without encountering any error---it just happened to have seen 0 branch that matched. So I think returning non-zero status would be a bug.

Thanks.
Previous: Josh Hunt via GitGitGadgetNext: Josh Hunt
Message 2 of 3 in “branch: return error when --list finds no matches”
  1. branch: return error when --list finds no matchesJosh Hunt via GitGitGadget, Mar 3, 2021
  2. Junio C HamanoMar 4, 2021
  3. Josh HuntMar 5, 2021

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.