parse_pathspec: save original pathspec for reporting
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Sun, 14 Jul 2013 08:35:29 +0000 (15:35 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 15 Jul 2013 17:56:06 +0000 (10:56 -0700)
We usually use pathspec_item's match field for pathspec error
reporting. However "match" (or "raw") does not show the magic part,
which will play more important role later on. Preserve exact user
input for reporting.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
dir.c
pathspec.c
pathspec.h
diff --git a/dir.c b/dir.c
index 5f86e467c4ca46afe597934ae091a56597a60b0e..308028e5b16df77e22e87cf339a461676c7f4c1b 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -1599,6 +1599,7 @@ int init_pathspec(struct pathspec *pathspec, const char **paths)
                const char *path = paths[i];
 
                item->match = path;
+               item->original = path;
                item->len = strlen(path);
                item->flags = 0;
                if (limit_pathspec_to_literal()) {
index ce942dbccf20be71a6f1a86ec59e30f68e5d944e..f94beb6075ccc1de55c419d2b6182031fa625ff5 100644 (file)
@@ -203,6 +203,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
        else
                match = prefix_path(prefix, prefixlen, copyfrom);
        *raw = item->match = match;
+       item->original = elt;
        item->len = strlen(item->match);
        if (limit_pathspec_to_literal())
                item->nowildcard_len = item->len;
@@ -277,6 +278,7 @@ void parse_pathspec(struct pathspec *pathspec,
                pathspec->items = item = xmalloc(sizeof(*item));
                memset(item, 0, sizeof(*item));
                item->match = prefix;
+               item->original = prefix;
                item->nowildcard_len = item->len = strlen(prefix);
                raw[0] = prefix;
                raw[1] = NULL;
index 937ec91a0d28e885f9e113d8dcbfd0b3a7e98276..cc5841b77f8ca96510341f7763d19b932a85924e 100644 (file)
@@ -16,6 +16,7 @@ struct pathspec {
        int max_depth;
        struct pathspec_item {
                const char *match;
+               const char *original;
                unsigned magic;
                int len;
                int nowildcard_len;