Re: [PATCH v2] builtin/branch.c: remove useless branch_get
- From
Jeff King <peff@peff.net>
- Date
- Oct 17, 2018, 08:39 UTC
- Message-ID
- <20181017083906.GC31932@sigill.intra.peff.net>
- In-Reply-To
- <20181016145428.2901-1-taoqy@ls-a.me>
On Tue, Oct 16, 2018 at 10:54:28PM +0800, Tao Qingyun wrote:
Show 18 quoted lines
> branch_get sometimes returns current_branch, which can be NULL (e.g., if > you're on a detached HEAD). Try: > > $ git branch HEAD > fatal: no such branch 'HEAD' > > $ git branch '' > fatal: no such branch '' > > However, it seems weird that we'd check those cases here (and provide > such lousy messages). And indeed, dropping that and letting us > eventually hit create_branch() gives a much better message: > > $ git branch HEAD > fatal: 'HEAD' is not a valid branch name. > > $ git branch '' > fatal: '' is not a valid branch name.
This explanation is perfect, of course. ;)
I still wondered if you had another motivation hinted at in your original mail, though (some weirdness with running branch_get early). It's OK if there isn't one, but I just want to make sure we capture all of the details.
Other than that question, the patch looks good to me.
-Peff