Skip to content

Commit d2ce133

Browse files
pcloudsgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87323bd commit d2ce133

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,7 @@ int init_pathspec(struct pathspec *pathspec, const char **paths)
15991599
const char *path = paths[i];
16001600

16011601
item->match = path;
1602+
item->original = path;
16021603
item->len = strlen(path);
16031604
item->flags = 0;
16041605
if (limit_pathspec_to_literal()) {

pathspec.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ static unsigned prefix_pathspec(struct pathspec_item *item,
203203
else
204204
match = prefix_path(prefix, prefixlen, copyfrom);
205205
*raw = item->match = match;
206+
item->original = elt;
206207
item->len = strlen(item->match);
207208
if (limit_pathspec_to_literal())
208209
item->nowildcard_len = item->len;
@@ -277,6 +278,7 @@ void parse_pathspec(struct pathspec *pathspec,
277278
pathspec->items = item = xmalloc(sizeof(*item));
278279
memset(item, 0, sizeof(*item));
279280
item->match = prefix;
281+
item->original = prefix;
280282
item->nowildcard_len = item->len = strlen(prefix);
281283
raw[0] = prefix;
282284
raw[1] = NULL;

pathspec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct pathspec {
1616
int max_depth;
1717
struct pathspec_item {
1818
const char *match;
19+
const char *original;
1920
unsigned magic;
2021
int len;
2122
int nowildcard_len;

0 commit comments

Comments
 (0)