else
match = prefix_path(prefix, prefixlen, copyfrom);
*raw = item->match = match;
- item->original = elt;
+ /*
+ * Prefix the pathspec (keep all magic) and assign to
+ * original. Useful for passing to another command.
+ */
+ if (flags & PATHSPEC_PREFIX_ORIGIN) {
+ struct strbuf sb = STRBUF_INIT;
+ strbuf_add(&sb, elt, copyfrom - elt);
+ strbuf_addstr(&sb, match);
+ item->original = strbuf_detach(&sb, NULL);
+ } else
+ item->original = elt;
item->len = strlen(item->match);
if ((flags & PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP) &&
* safer than _SLASH_CHEAP and also more expensive.
*/
#define PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE (1<<5)
+#define PATHSPEC_PREFIX_ORIGIN (1<<6)
extern int init_pathspec(struct pathspec *, const char **);
extern void parse_pathspec(struct pathspec *pathspec,