t3703: Skip tests using directory name ":" on Windows
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 820ed05b27292dbb72ccce8cf8a1fb7f6b77a2e5..fd4ce59f28a275448ac4d34aeadd6f9875cc5911 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -85,8 +85,17 @@ static void NORETURN die_verify_filename(const char *prefix, const char *arg)
 {
        unsigned char sha1[20];
        unsigned mode;
-       /* try a detailed diagnostic ... */
-       get_sha1_with_mode_1(arg, sha1, &mode, 0, prefix);
+
+       /*
+        * Saying "'(icase)foo' does not exist in the index" when the
+        * user gave us ":(icase)foo" is just stupid.  A magic pathspec
+        * begins with a colon and is followed by a non-alnum; do not
+        * let get_sha1_with_mode_1(only_to_die=1) to even trigger.
+        */
+       if (!(arg[0] == ':' && !isalnum(arg[1])))
+               /* try a detailed diagnostic ... */
+               get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);
+
        /* ... or fall back the most general message. */
        die("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
            "Use '--' to separate paths from revisions", arg);
@@ -203,13 +212,17 @@ const char *prefix_pathspec(const char *prefix, int prefixlen, const char *elt)
                     *copyfrom && *copyfrom != ':';
                     copyfrom++) {
                        char ch = *copyfrom;
+
+                       if (!is_pathspec_magic(ch))
+                               break;
                        for (i = 0; i < ARRAY_SIZE(pathspec_magic); i++)
                                if (pathspec_magic[i].mnemonic == ch) {
                                        magic |= pathspec_magic[i].bit;
                                        break;
                                }
                        if (ARRAY_SIZE(pathspec_magic) <= i)
-                               break;
+                               die("Unimplemented pathspec magic '%c' in '%s'",
+                                   ch, elt);
                }
                if (*copyfrom == ':')
                        copyfrom++;