parse_pathspec: save original pathspec for reporting
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>
This commit is contained in:
parent
87323bdace
commit
d2ce133195
1
dir.c
1
dir.c
@ -1599,6 +1599,7 @@ int init_pathspec(struct pathspec *pathspec, const char **paths)
|
|||||||
const char *path = paths[i];
|
const char *path = paths[i];
|
||||||
|
|
||||||
item->match = path;
|
item->match = path;
|
||||||
|
item->original = path;
|
||||||
item->len = strlen(path);
|
item->len = strlen(path);
|
||||||
item->flags = 0;
|
item->flags = 0;
|
||||||
if (limit_pathspec_to_literal()) {
|
if (limit_pathspec_to_literal()) {
|
||||||
|
@ -203,6 +203,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
|
|||||||
else
|
else
|
||||||
match = prefix_path(prefix, prefixlen, copyfrom);
|
match = prefix_path(prefix, prefixlen, copyfrom);
|
||||||
*raw = item->match = match;
|
*raw = item->match = match;
|
||||||
|
item->original = elt;
|
||||||
item->len = strlen(item->match);
|
item->len = strlen(item->match);
|
||||||
if (limit_pathspec_to_literal())
|
if (limit_pathspec_to_literal())
|
||||||
item->nowildcard_len = item->len;
|
item->nowildcard_len = item->len;
|
||||||
@ -277,6 +278,7 @@ void parse_pathspec(struct pathspec *pathspec,
|
|||||||
pathspec->items = item = xmalloc(sizeof(*item));
|
pathspec->items = item = xmalloc(sizeof(*item));
|
||||||
memset(item, 0, sizeof(*item));
|
memset(item, 0, sizeof(*item));
|
||||||
item->match = prefix;
|
item->match = prefix;
|
||||||
|
item->original = prefix;
|
||||||
item->nowildcard_len = item->len = strlen(prefix);
|
item->nowildcard_len = item->len = strlen(prefix);
|
||||||
raw[0] = prefix;
|
raw[0] = prefix;
|
||||||
raw[1] = NULL;
|
raw[1] = NULL;
|
||||||
|
@ -16,6 +16,7 @@ struct pathspec {
|
|||||||
int max_depth;
|
int max_depth;
|
||||||
struct pathspec_item {
|
struct pathspec_item {
|
||||||
const char *match;
|
const char *match;
|
||||||
|
const char *original;
|
||||||
unsigned magic;
|
unsigned magic;
|
||||||
int len;
|
int len;
|
||||||
int nowildcard_len;
|
int nowildcard_len;
|
||||||
|
Loading…
Reference in New Issue
Block a user