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

[BUG]: Non-matching exclude pathspec causes an error in empty repository when the flag "--update" is present

From
Piotr Siupa <piotrsiupa@gmail.com>
Date
May 27, 2025, 08:14 UTC
Message-ID
<CAPM0=yCcOAGsUE8tX-o8ioihr+oWrORD6Tz=WH1OnmhpO+uqrA@mail.gmail.com>

I found a regression in version 2.45.0. (It's still present in the current next - 2.49.0.1266.g31b7d2e469; earlier versions work fine.)

When you run "git add --update" with an exclude pathspec on an empty repository, the command fails, showing an error about not being able to find the specified files. This happens only if the repository contains no files. Adding any files (even with "git add -N") or making a non-empty commit fixes the issue, regardless of whether the added files match the exclude pathspec or not.

Way to reproduce: git init git add --update -- ':(exclude)foo'

This results in: error: pathspec ':(exclude)foo' did not match any file(s) known to git error: pathspec '.' did not match any file(s) known to git

Next: Phillip Wood
Message 1 of 5 in “[BUG]: Non-matching exclude pathspec causes an error in empty repository when the flag "--update" is present”
  1. Piotr SiupaMay 27, 2025
  2. Phillip WoodJun 2, 2025
  3. Junio C HamanoJun 2, 2025
  4. Piotr SiupaJun 10, 2025
  5. Piotr SiupaJun 10, 2025

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.