[PATCH v3 04/31] parse_pathspec: save original pathspec for reporting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 cache.h | 1 +
 dir.c   | 1 +
 setup.c | 2 ++
 3 files changed, 4 insertions(+)

diff --git a/cache.h b/cache.h
index 759c62a..136e4c7 100644
--- a/cache.h
+++ b/cache.h
@@ -485,6 +485,7 @@ struct pathspec {
 	int max_depth;
 	struct pathspec_item {
 		const char *match;
+		const char *original;
 		unsigned magic;
 		int len;
 		int nowildcard_len;
diff --git a/dir.c b/dir.c
index 8454c13..beb7532 100644
--- a/dir.c
+++ b/dir.c
@@ -1538,6 +1538,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/setup.c b/setup.c
index 92adefc..a1ad012 100644
--- a/setup.c
+++ b/setup.c
@@ -249,6 +249,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);
 	item->flags = 0;
 	if (limit_pathspec_to_literal())
@@ -295,6 +296,7 @@ static 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;
-- 
1.8.0.rc2.23.g1fb49df

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]