Re: [PATCH 1/3] checkout: reorder check_filename conditional
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 10, 2016, 21:31 UTC
- Message-ID
- <xmqq8u2sz1yu.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160210211234.GA5799@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 5 quoted lines
> If we have a "--" flag, we should not be doing DWIM magic > based on whether arguments can be filenames. Reorder the > conditional to avoid the check_filename() call entirely in > this case. The outcome is the same, but the short-circuit > makes the dependency more clear.
It also allows check_filename() to die(), and lets the user to prevent it with "--"---"Don't check when we do not have to" is the right thing to do.
Thanks.
Show 18 quoted lines
> Signed-off-by: Jeff King <peff@peff.net> > --- > builtin/checkout.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/builtin/checkout.c b/builtin/checkout.c > index 5af84a3..f6a2809 100644 > --- a/builtin/checkout.c > +++ b/builtin/checkout.c > @@ -982,7 +982,7 @@ static int parse_branchname_arg(int argc, const char **argv, > */ > int recover_with_dwim = dwim_new_local_branch_ok; > > - if (check_filename(NULL, arg) && !has_dash_dash) > + if (!has_dash_dash && check_filename(NULL, arg)) > recover_with_dwim = 0; > /* > * Accept "git checkout foo" and "git checkout foo --"