t3703: Skip tests using directory name ":" on Windows
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 51e354ca0760d8b6593fe50720b47c160dd8fe59..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);
@@ -136,12 +145,12 @@ void verify_non_filename(const char *prefix, const char *arg)
  * Possible future magic semantics include stuff like:
  *
  *     { PATHSPEC_NOGLOB, '!', "noglob" },
+ *     { PATHSPEC_ICASE, '\0', "icase" },
  *     { PATHSPEC_RECURSIVE, '*', "recursive" },
  *     { PATHSPEC_REGEXP, '\0', "regexp" },
  *
  */
 #define PATHSPEC_FROMTOP    (1<<0)
-#define PATHSPEC_ICASE      (1<<1)
 
 struct pathspec_magic {
        unsigned bit;
@@ -149,7 +158,6 @@ struct pathspec_magic {
        const char *name;
 } pathspec_magic[] = {
        { PATHSPEC_FROMTOP, '/', "top" },
-       { PATHSPEC_ICASE, '\0', "icase" },
 };
 
 /*
@@ -169,8 +177,7 @@ const char *prefix_pathspec(const char *prefix, int prefixlen, const char *elt)
 {
        unsigned magic = 0;
        const char *copyfrom = elt;
-       const char *retval;
-       int i, free_source = 0;
+       int i;
 
        if (elt[0] != ':') {
                ; /* nothing to do */
@@ -199,9 +206,6 @@ const char *prefix_pathspec(const char *prefix, int prefixlen, const char *elt)
                }
                if (*copyfrom == ')')
                        copyfrom++;
-       } else if (!elt[1]) {
-               /* Just ':' -- no element! */
-               return NULL;
        } else {
                /* shorthand */
                for (copyfrom = elt + 1;
@@ -224,31 +228,10 @@ const char *prefix_pathspec(const char *prefix, int prefixlen, const char *elt)
                        copyfrom++;
        }
 
-       if (magic & PATHSPEC_ICASE) {
-               struct strbuf sb = STRBUF_INIT;
-               for (i = 0; copyfrom[i]; i++) {
-                       int ch = copyfrom[i];
-                       if (('a' <= ch && ch <= 'z') ||
-                           ('A' <= ch && ch <= 'Z')) {
-                               strbuf_addf(&sb, "[%c%c]",
-                                           tolower(ch), toupper(ch));
-                       } else {
-                               strbuf_addch(&sb, ch);
-                       }
-               }
-               if (sb.len) {
-                       free_source = 1;
-                       copyfrom = strbuf_detach(&sb, NULL);
-               }
-       }
-
        if (magic & PATHSPEC_FROMTOP)
-               retval = xstrdup(copyfrom);
+               return xstrdup(copyfrom);
        else
-               retval = prefix_path(prefix, prefixlen, copyfrom);
-       if (free_source)
-               free((char *)copyfrom);
-       return retval;
+               return prefix_path(prefix, prefixlen, copyfrom);
 }
 
 const char **get_pathspec(const char *prefix, const char **pathspec)