git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [WIP PATCH 0/5] support --exclude for diff/log commands

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Mar 23, 2011, 12:10 UTC
Message-ID
<AANLkTimeEWOvmNXQV9fJKe23Qe3sipT7q=qHVB2fLq0n@mail.gmail.com>
In-Reply-To
<7v7hbqk8ox.fsf@alter.siamese.dyndns.org>
On Wed, Mar 23, 2011 at 6:59 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 9 quoted lines
> Let's clarify by dumping my understanding of what we aim to achieve.
>
> ...
>
> Both the ":/<path>" proposal (or your ":<path>" proposal) changes only a
> very small part of the above, namely, "each prefixed with '<prefix>'" is
> changed to if the element in original pathspec has the magic colon prefix,
> the magic is stripped away, and the remainder becomes the element in the
> resulting pathspec array without additional <prefix> in front.
Correct.
> If Nguyen's proposal is to also match ":/<path>" (or ":<path>") literally,
> that part should be scrapped.  If somebody wants to match such an unusual
> path component, it can always be expressed by quoting it as a glob,
> i.e. "[:]/<path>" (or "[:]<path").
OK.
Show 5 quoted lines
> I am slightly in favor of ":<path>" syntax (than ":/<path>"), but I do not
> care too deeply.  Either has the same problem that it will be confusing
> with existing and well-established syntax (the former would conflict with
> "name of the blob in the index", the latter with "name of the commit that
> match the regexp).

How about ":<path>" for root pathspecs, but reserve ':[^0-9A-Za-z]*' for future use?

(on top of Michael's patch)
-- 8< --
diff --git a/setup.c b/setup.c
index ef55e5d..1ebe1d2 100644
--- a/setup.c
+++ b/setup.c
@@ -146,8 +146,13 @@ const char **get_pathspec(const char *prefix,
const char **pathspec)
 	while (*src) {
 		const char *p;

-		if ((*src)[0] == ':')
+		if ((*src)[0] == ':') {
+			const char *reserved = "~`!@#$%^&*()-_=+[{]}\\|;:'\",<.>/?";
+			if (strchr(reserved, (*src)[1]))
+				die("':%c' syntax is not supported. "
+				    "Quote it to match literally.", (*src)[1]);
 			p = prefix_path(NULL, 0, (*src)+1);
+		}
 		else
 			p = prefix_path(prefix, prefixlen, *src);
 		*(dst++) = p;
-- 8< --
-- 
Duy
Previous: Junio C HamanoNext: Nguyen Thai Ngoc Duy
Message 17 of 20 in “support --exclude for diff/log commands”
  1. 0/5 support --exclude for diff/log commandsNguyễn Thái Ngọc Duy, Mar 10, 2011
  2. 1/5 tree-walk: support negative pathspecNguyễn Thái Ngọc Duy, Mar 10, 2011
  3. 2/5 match_pathspec_depth: support negative pathspecNguyễn Thái Ngọc Duy, Mar 10, 2011
  4. 3/5 revision.c: get rid of struct rev_info.prune_dataNguyễn Thái Ngọc Duy, Mar 10, 2011
  5. Junio C HamanoMar 10, 2011
  6. Nguyen Thai Ngoc DuyMar 10, 2011
  7. 4/5 diff: refactor init/release APINguyễn Thái Ngọc Duy, Mar 10, 2011
  8. 5/5 diff: support --excludeNguyễn Thái Ngọc Duy, Mar 10, 2011
  9. Junio C HamanoMar 10, 2011
  10. Nguyen Thai Ngoc DuyMar 10, 2011
  11. Junio C HamanoMar 10, 2011
  12. Nguyen Thai Ngoc DuyMar 10, 2011
  13. Nguyen Thai Ngoc DuyMar 21, 2011
  14. Michael J GruberMar 21, 2011
  15. Nguyen Thai Ngoc DuyMar 21, 2011
  16. Junio C HamanoMar 22, 2011
  17. Nguyen Thai Ngoc DuyMar 23, 2011
  18. Nguyen Thai Ngoc DuyMar 23, 2011
  19. Michael J GruberMar 23, 2011
  20. Nguyen Thai Ngoc DuyMar 23, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.