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

Excluding paths with wildcard not working with add -p

From
RDRobert Dailey <rcdailey.lists@gmail.com>
Date
May 29, 2022, 17:27 UTC
Message-ID
<CAHd499D81VN=aGsM6kaNLF2ZMg-Zg10U=qU-j7gQ7uXnqqfdqg@mail.gmail.com>
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?

Next: Junio C Hamano
Message 1 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.