Thread (66 messages) flat view 66 messages, 4 authors, 2016-06-15
STALE3723d

[PATCH v1 07/45] parse_pathspec: save original pathspec for reporting

From: Nguyễn Thái Ngọc Duy <hidden>
Date: 2016-06-15 22:56:24
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 dir.c      | 1 +
 pathspec.c | 2 ++
 pathspec.h | 1 +
 3 files changed, 4 insertions(+)
diff --git a/dir.c b/dir.c
index a442467..8541ea7 100644
--- a/dir.c
+++ b/dir.c
@@ -1649,6 +1649,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()) {
diff --git a/pathspec.c b/pathspec.c
index bc9d9ac..2bda633 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -202,6 +202,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;
@@ -275,6 +276,7 @@ void parse_pathspec(struct pathspec *pathspec,
 
 		pathspec->items = item = xmalloc(sizeof(*item));
 		item->match = prefix;
+		item->original = prefix;
 		item->nowildcard_len = item->len = strlen(prefix);
 		raw[0] = prefix;
 		raw[1] = NULL;
diff --git a/pathspec.h b/pathspec.h
index 937ec91..cc5841b 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -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;
-- 
1.8.0.rc0.19.g7bbb31d
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help