magic pathspec: futureproof shorthand form
[gitweb.git] / setup.c
diff --git a/setup.c b/setup.c
index 820ed05b27292dbb72ccce8cf8a1fb7f6b77a2e5..5048252d78638c2c6adcf8807442728ef4f37a5e 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -197,19 +197,26 @@ 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;
                     *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++;