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

Re: [RFC] The design of new pathspec features

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 29, 2013, 06:13 UTC
Message-ID
<CACsJy8DsKFfGoPUt5b=3MuSmZ2z2Z5vJ20D_kqEowAUc8QTryA@mail.gmail.com>
In-Reply-To
<7vd2wotuxm.fsf@alter.siamese.dyndns.org>
On Tue, Jan 29, 2013 at 12:33 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Have you considered if it may be helpful to have a :(literal) magic
> (or any magic in general) that applies only to the first N
> characters of the pathspec pattern?

Not user-driven. But the prefix part is :(literal)-applied. :(glob) is currently implemented this way, using nowildcard_len as you mentioned. :(icase) is more complicated and does not follow yet.

Show 15 quoted lines
> I personally think we do not need to support something like this:
>
>         prefix=$(git rev-parse --show-prefix)
>         n=${#prefix}
>         pathspec=":(literal-$n)$prefix$1"
>
> but other aspiring Porcelain script writers may disagree and would
> want to have it.  We can always solve it by giving them an easy and
> uniform way to get the glob-quoted version of prefix to solve this
> particular issue, i.e.
>
>         prefixq=$(git rev-parse --show-prefix-glob-quoted)
>         pathspec="$prefixq$1"
>
> but magic that applies only to a substring may have other uses.

Yeah, that simplifies things. Supporting applying magic over just parts of the pathspec pattern sounds complex. Just a small modification. That rev-parse needs to look at "$1" as well. If :(literal) is already specified, glob quoting will backfire. The user script can deal with that, but it's harder (e.g. parsing magic from scripts and deal with magic combination) than letting rev-parse does it.

I've done some form of this already, for supporting add--interactive. git-add prefixes the pathspec but keeps all the magic in place, before passing pathspec to add--interactive. But I missed the quoting point you mentioned above. I probably need de-quoting the prefix as well. Many optimizations stop short at the sign of any glob symbols, including backslash. This could be a new task for wildmatch.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 10 in “[RFC] The design of new pathspec features”
  1. Duy NguyenJan 29, 2013
  2. Junio C HamanoJan 29, 2013
  3. Duy NguyenJan 29, 2013
  4. Junio C HamanoJan 29, 2013
  5. Junio C HamanoJan 29, 2013
  6. Duy NguyenJan 29, 2013
  7. Junio C HamanoJan 29, 2013
  8. Duy NguyenJan 29, 2013
  9. Junio C HamanoJan 29, 2013
  10. Junio C HamanoJan 29, 2013

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.