Re: Possible bug: Empty magic word list in pathspec is handled differently in short vs. long form
- From
Lucas Oshiro <lucasseikioshiro@gmail.com>
- Date
- Feb 19, 2025, 14:28 UTC
- Message-ID
- <6CE51CB5-4F14-4737-83EE-05B93500BDF1@gmail.com>
- In-Reply-To
- <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. >
From the gitglossary, pathspec section:
""" In the short form, the leading colon `:` is followed by zero or more "magic signature" letters (which optionally is terminated by another colon :), and the remainder is the pattern to match against the path. """
and:
""" In the long form, the leading colon : is followed by an open parenthesis `(`, a comma-separated list of zero or more "magic words", and a close parentheses `)` , and the remainder is the pattern to match against the path. """
Note that the long form doesn't mention that a second colon has the same meaning as in the short form. In the short form, the second colon is optionally used to separate the magic signatures from the file pattern. It wouldn't be necessary in the long form, as the close parentheses acts just like that.
This way, "::" and ":():" doesn't have the same meaning, just like, for example, ":(exclude):" doesn't mean ":!" (but ":(exclude)" does).