{"thread":{"id":"62976","subject":"Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form","startedAt":"2025-02-19T10:49:48Z","lastAt":"2025-02-24T14:16:43Z","messageCount":4,"participants":["Anselm Schüler","Lucas Oshiro","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"512660","messageId":"216a7288-b599-4333-ba62-10665d6a94d8@anselmschueler.com","threadId":"62976","inReplyTo":null,"subject":"Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form","fromName":"Anselm Schüler","fromEmail":"mail@anselmschueler.com","sentAt":"2025-02-19T10:49:39Z","receivedAt":"2025-02-19T10:49:48Z","isPatch":false,"sender":{"key":"mail@anselmschueler.com","avatar":"https://gravatar.com/avatar/fb911b2f7cf9596f7bbc61cd9799da5fe87733c0394d6ca79531e07368fd757f?d=mp&s=160"},"body":"﻿If you run git diff for a pathspec with an empty magic word/symbol list \nin short form (prefixed by ::) and in long form (prefixed by :():), you \nget different results.\n\nHere’s an example use of git that illustrates this:\n\n~☭ mkdir gittest\n~☭ y gittest/\n~/gittest☭ git init\nInitialized empty Git repository in /home/anselmschueler/gittest/.git/\n~/gittest (b0)☭ uuidgen >file\n~/gittest (b0)☭ git add file && git commit -m \"$(read)\"\nread> initial commit\n[b0 (root-commit) cd3bd43] initial commit\n  1 file changed, 1 insertion(+)\n  create mode 100644 file\n~/gittest (b0)☭ uuidgen >file\n~/gittest (b0)☭ git diff -- \"::file\"\n\nfile\n──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n───┐\n1: │\n───┘\n66d18ffa-1128-42a5-8d4e-f9d75eb86b92\n9acea2b5-50a6-4f87-ae1a-64019a93e55e\n~/gittest (b0)☭ git diff -- \":():file\"\n~/gittest (b0)☭\n\nIs there a reason for this? I couldn’t find it documented in the git \nglossary <https://git-scm.com/docs/gitglossary>.\n\nI’m running git 2.47.2, built with Nix (nixpkgs commit 2ff53fe) from the \nkernel.org source tarball.\n\n~Anselm Schüler ⚙️\n\n"},{"id":"512701","messageId":"6CE51CB5-4F14-4737-83EE-05B93500BDF1@gmail.com","threadId":"62976","inReplyTo":"216a7288-b599-4333-ba62-10665d6a94d8@anselmschueler.com","subject":"Re: Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form","fromName":"Lucas Oshiro","fromEmail":"lucasseikioshiro@gmail.com","sentAt":"2025-02-19T14:28:25Z","receivedAt":"2025-02-19T14:28:40Z","isPatch":false,"sender":{"key":"lucasseikioshiro@gmail.com","avatar":"https://avatars.githubusercontent.com/u/12701580?v=4"},"body":"\n> 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.\n> \n\nFrom the gitglossary, pathspec section:\n\n\"\"\"\nIn the short form, the leading colon `:` is followed by zero or more\n\"magic signature\" letters (which optionally is terminated by another colon\n:), and the remainder is the pattern to match against the path.\n\"\"\"\n\nand:\n\n\"\"\"\nIn the long form, the leading colon : is followed by an open\nparenthesis `(`, a comma-separated list of zero or more \"magic words\", and\na close parentheses `)` , and the remainder is the pattern to match against\nthe path. \n\"\"\"\n\nNote that the long form doesn't mention that a second colon has the same\nmeaning as in the short form. In the short form, the second colon is\noptionally used to separate the magic signatures from the file pattern. It\nwouldn't be necessary in the long form, as the close parentheses acts just\nlike that.\n\nThis way, \"::\" and \":():\" doesn't have the same meaning, just like, for\nexample, \":(exclude):\" doesn't mean \":!\" (but \":(exclude)\" does)."},{"id":"512721","messageId":"xmqqr03tg8q1.fsf@gitster.g","threadId":"62976","inReplyTo":"216a7288-b599-4333-ba62-10665d6a94d8@anselmschueler.com","subject":"Re: Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-02-19T17:11:50Z","receivedAt":"2025-02-19T17:11:53Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Anselm Schüler <mail@anselmschueler.com> writes:\n\n> ﻿If you run git diff for a pathspec with an empty magic word/symbol\n> list in short form (prefixed by ::) and in long form (prefixed by\n> :():), you get different results.\n\nThe short form is prefixed by a \":\" and optionally ends by a \":\",\nbut the optional termination may not be required when there is no\nambiguity (e.g. \":/!path\" is \"from the top, not matching \"path\", as\n\"p\" cannot be a magic signature; \":/:!path\" is \"from the top,\nmatching \"!path\", as the set of magic signatures ends with the\nsecond disambiguating colon).\n\nThe long form is prefixed by a \":(\" and ends by a \")\".\n\n\n> Here’s an example use of git that illustrates this:\n>\n> ~☭ mkdir gittest\n> ~☭ y gittest/\n> ~/gittest☭ git init\n> Initialized empty Git repository in /home/anselmschueler/gittest/.git/\n> ~/gittest (b0)☭ uuidgen >file\n> ~/gittest (b0)☭ git add file && git commit -m \"$(read)\"\n> read> initial commit\n> [b0 (root-commit) cd3bd43] initial commit\n>  1 file changed, 1 insertion(+)\n>  create mode 100644 file\n> ~/gittest (b0)☭ uuidgen >file\n> ~/gittest (b0)☭ git diff -- \"::file\"\n>\n> file\n> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n>\n> ───┐\n> 1: │\n> ───┘\n> 66d18ffa-1128-42a5-8d4e-f9d75eb86b92\n> 9acea2b5-50a6-4f87-ae1a-64019a93e55e\n> ~/gittest (b0)☭ git diff -- \":():file\"\n> ~/gittest (b0)☭\n\nDoesn't \":():file\" ask for a match for the pattern \":file\", with a\nleading colon?\n"},{"id":"512896","messageId":"5f312413-0b7d-4bcb-b180-57857afa3898@anselmschueler.com","threadId":"62976","inReplyTo":"xmqqr03tg8q1.fsf@gitster.g","subject":"Re: Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form","fromName":"Anselm Schüler","fromEmail":"mail@anselmschueler.com","sentAt":"2025-02-24T14:11:26Z","receivedAt":"2025-02-24T14:16:43Z","isPatch":false,"sender":{"key":"mail@anselmschueler.com","avatar":"https://gravatar.com/avatar/fb911b2f7cf9596f7bbc61cd9799da5fe87733c0394d6ca79531e07368fd757f?d=mp&s=160"},"body":"Thank you and Lucas Oshiro <lucasseikioshiro@gmail.com> for the \nclarification\n\nOn 19/02/2025 18:11, Junio C Hamano wrote:\n> Anselm Schüler <mail@anselmschueler.com> writes:\n>\n>> ﻿If you run git diff for a pathspec with an empty magic word/symbol\n>> list in short form (prefixed by ::) and in long form (prefixed by\n>> :():), you get different results.\n> The short form is prefixed by a \":\" and optionally ends by a \":\",\n> but the optional termination may not be required when there is no\n> ambiguity (e.g. \":/!path\" is \"from the top, not matching \"path\", as\n> \"p\" cannot be a magic signature; \":/:!path\" is \"from the top,\n> matching \"!path\", as the set of magic signatures ends with the\n> second disambiguating colon).\n>\n> The long form is prefixed by a \":(\" and ends by a \")\".\n>\n>\n>> Here’s an example use of git that illustrates this:\n>>\n>> ~☭ mkdir gittest\n>> ~☭ y gittest/\n>> ~/gittest☭ git init\n>> Initialized empty Git repository in /home/anselmschueler/gittest/.git/\n>> ~/gittest (b0)☭ uuidgen >file\n>> ~/gittest (b0)☭ git add file && git commit -m \"$(read)\"\n>> read> initial commit\n>> [b0 (root-commit) cd3bd43] initial commit\n>>   1 file changed, 1 insertion(+)\n>>   create mode 100644 file\n>> ~/gittest (b0)☭ uuidgen >file\n>> ~/gittest (b0)☭ git diff -- \"::file\"\n>>\n>> file\n>> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────\n>>\n>> ───┐\n>> 1: │\n>> ───┘\n>> 66d18ffa-1128-42a5-8d4e-f9d75eb86b92\n>> 9acea2b5-50a6-4f87-ae1a-64019a93e55e\n>> ~/gittest (b0)☭ git diff -- \":():file\"\n>> ~/gittest (b0)☭\n> Doesn't \":():file\" ask for a match for the pattern \":file\", with a\n> leading colon?\n"}]}