OSDN Git Service

checkout: reorder check_filename conditional
authorJeff King <peff@peff.net>
Wed, 10 Feb 2016 21:12:34 +0000 (16:12 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Feb 2016 21:53:18 +0000 (13:53 -0800)
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.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c

index 3e141fc..d34f58e 100644 (file)
@@ -965,7 +965,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 --"