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

Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form

From
Anselm Schüler <mail@anselmschueler.com>
Date
Feb 19, 2025, 10:49 UTC
Message-ID
<216a7288-b599-4333-ba62-10665d6a94d8@anselmschueler.com>
If you run git diff for a pathspec with an empty magic word/symbol list 
in short form (prefixed by ::) and in long form (prefixed by :():), you 
get different results.
Here’s an example use of git that illustrates this:
~☭ mkdir gittest
~☭ y gittest/
~/gittest☭ git init
Initialized empty Git repository in /home/anselmschueler/gittest/.git/
~/gittest (b0)☭ uuidgen >file
~/gittest (b0)☭ git add file && git commit -m "$(read)"
read> initial commit
[b0 (root-commit) cd3bd43] initial commit
  1 file changed, 1 insertion(+)
  create mode 100644 file
~/gittest (b0)☭ uuidgen >file
~/gittest (b0)☭ git diff -- "::file"

file ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

───┐ 1: │ ───┘ 66d18ffa-1128-42a5-8d4e-f9d75eb86b92 9acea2b5-50a6-4f87-ae1a-64019a93e55e ~/gittest (b0)☭ git diff -- ":():file" ~/gittest (b0)☭

Is there a reason for this? I couldn’t find it documented in the git glossary <https://git-scm.com/docs/gitglossary>.

I’m running git 2.47.2, built with Nix (nixpkgs commit 2ff53fe) from the kernel.org source tarball.

~Anselm Schüler ⚙️
Next: Lucas Oshiro
Message 1 of 4 in “Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form”
  1. Anselm SchülerFeb 19, 2025
  2. Lucas OshiroFeb 19, 2025
  3. Junio C HamanoFeb 19, 2025
  4. Anselm SchülerFeb 24, 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.