strbuf: remove prefixcmp() and suffixcmp()
[gitweb.git] / pathspec.c
index 4b32cc32cb5b0be495ac941c5e96d8aee8fd8ff9..4a7893e0724bde995a64457a239381783edd945a 100644 (file)
@@ -128,7 +128,11 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
                die(_("global 'literal' pathspec setting is incompatible "
                      "with all other global pathspec settings"));
 
-       if (elt[0] != ':' || literal_global) {
+       if (flags & PATHSPEC_LITERAL_PATH)
+               global_magic = 0;
+
+       if (elt[0] != ':' || literal_global ||
+           (flags & PATHSPEC_LITERAL_PATH)) {
                ; /* nothing to do */
        } else if (elt[1] == '(') {
                /* longhand */
@@ -150,7 +154,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
                                        magic |= pathspec_magic[i].bit;
                                        break;
                                }
-                               if (!prefixcmp(copyfrom, "prefix:")) {
+                               if (starts_with(copyfrom, "prefix:")) {
                                        char *endptr;
                                        pathspec_prefix = strtol(copyfrom + 7,
                                                                 &endptr, 10);
@@ -231,7 +235,9 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
                const char *start = elt;
                if (prefixlen && !literal_global) {
                        /* Preserve the actual prefix length of each pattern */
-                       if (long_magic_end) {
+                       if (short_magic)
+                               die("BUG: prefixing on short magic is not supported");
+                       else if (long_magic_end) {
                                strbuf_add(&sb, start, long_magic_end - start);
                                strbuf_addf(&sb, ",prefix:%d", prefixlen);
                                start = long_magic_end;
@@ -403,6 +409,9 @@ void parse_pathspec(struct pathspec *pathspec,
                item[i].magic = prefix_pathspec(item + i, &short_magic,
                                                argv + i, flags,
                                                prefix, prefixlen, entry);
+               if ((flags & PATHSPEC_LITERAL_PATH) &&
+                   !(magic_mask & PATHSPEC_LITERAL))
+                       item[i].magic |= PATHSPEC_LITERAL;
                if (item[i].magic & magic_mask)
                        unsupported_magic(entry,
                                          item[i].magic & magic_mask,