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.