On Mon, Nov 06, 2023 at 10:54:03AM -0500, Joanna Wang wrote: > What did you do before the bug happened? (Steps to reproduce your issue) > > What did you expect to happen? (Expected behavior) > `git stash push -- :file` where `:` is part of the filename, should search > for files named ":file" > > What happened instead? (Actual behavior) > The match string used to find files is "file" without the ":". > > What's different between what you expected and what actually happened? > file named ":file" is not found. > > Anything else you want to add: > I believe this is due to parse_short_magic() not handling the case where > ":" is part of the file name rather than a prefix for pathspec magic. > > I could not find any documentation that says ":" is a reserved > character to indicate pathspec magic symbols MUST follow or that > ":file" is not a valid file name. I think this is the correct behavior according to the documentation. >From "git help glossary", the entry on "pathspec" says: A pathspec that begins with a colon : has special meaning. 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. So ":file" just has zero magic signature letters. I think you want: :::file which of course is rather ugly, but then so is your filename. ;) Although longer, probably this is more readable: :(literal):file And if you're working with a lot of such files (or you are scripting and know you have a set of filenames), then your best bet is probably turning on literal mode, like: git --literal-pathspecs ls-files -- :file -Peff PS It took me a while to figure out where we document pathspec syntax. I wonder if a "gitpathspecs" manpage would make sense, like we have "gitrevisions".