]> git.ipfire.org Git - thirdparty/git.git/commitdiff
verify_filename(): flip order of checks
authorJeff King <peff@peff.net>
Fri, 26 May 2017 19:10:53 +0000 (15:10 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 May 2017 02:36:56 +0000 (11:36 +0900)
The looks_like_pathspec() check is much cheaper than
check_filename(), which actually stats the file. Since
either is sufficient for our return value, we should do the
cheaper one first, potentially short-circuiting the other.

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

diff --git a/setup.c b/setup.c
index 89fcc12ab764284ec0eaef37d9fe275f13b1894e..1de87ed842ad60449836736e6380cea50381aab6 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -229,7 +229,7 @@ void verify_filename(const char *prefix,
 {
        if (*arg == '-')
                die("bad flag '%s' used after filename", arg);
-       if (check_filename(prefix, arg) || looks_like_pathspec(arg))
+       if (looks_like_pathspec(arg) || check_filename(prefix, arg))
                return;
        die_verify_filename(prefix, arg, diagnose_misspelt_rev);
 }