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

Re: Excluding paths with wildcard not working with add -p

From
Junio C Hamano <gitster@pobox.com>
Date
May 29, 2022, 18:25 UTC
Message-ID
<xmqqh758yz4u.fsf@gitster.g>
In-Reply-To
<CAHd499D81VN=aGsM6kaNLF2ZMg-Zg10U=qU-j7gQ7uXnqqfdqg@mail.gmail.com>
Robert Dailey <rcdailey.lists@gmail.com> writes:
Show 18 quoted lines
> If I run the command:
>
>     git add -p -- ':^*.cs'
>
> I get an error:
>
> fatal: empty string is not a valid pathspec. please use . instead if
> you meant to match all paths
> Cannot close git diff-index --cached --numstat --summary HEAD --
> :(exclude,prefix:0)*.cs  () at C:/Program
> Files/Git/mingw64/libexec/git-core\git-add--interactive line 242.
>
> However, it works if I remove `-p`. Also observed this works too:
>
>     git add -p -- ':*.cs'
>
> So it looks like we have a corner case where I can't do a patch add
> while excluding files. Is this intentional?
I do not think so.
Does this command
    git add -p -- . ':^*.cs'
work as you expect?
Previous: Robert DaileyNext: Junio C Hamano
Message 2 of 7 in “Excluding paths with wildcard not working with add -p”
  1. Robert DaileyMay 29, 2022
  2. Junio C HamanoMay 29, 2022
  3. Junio C HamanoMay 29, 2022
  4. pathspec: correct an empty string used as a pathspec elementJunio C Hamano, May 29, 2022
  5. rsbecker@nexbridge.comMay 29, 2022
  6. Robert DaileyMay 29, 2022
  7. Junio C HamanoMay 30, 2022

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.