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

Bug: `git stash push ':(attr:<somevalue>)' attr magic does not get parsed correctly

From
Joanna Wang <jojwang@google.com>
Date
Oct 11, 2023, 19:14 UTC
Message-ID
<CAMmZTi-0QKtj7Q=sbC5qhipGsQxJFOY-Qkk1jfkRYwfF5FcUVg@mail.gmail.com>

What did you do before the bug happened? (Steps to reproduce your issue) run the following with a debugger: `git stash push ':(attr:<somevalue>)'` check the resulting pathspec after parse_pathspec()

What did you expect to happen? (Expected behavior) the resulting pathspec should contain ':(attr:<somevalue>)'.

What happened instead? (Actual behavior) The resulting pathspec is ':(attr,prefix:0)' This is due to parse_pathspec in git-stash being called with PATHSPEC_PREFIX_ORIGIN as a flag.

':(attr:<somevalue>)' gets parsed into ':(attr,prefix:0)' because prefix_magic() https://github.com/git/git/blob/master/pathspec.c#L112 does not take into account that some magic can have values in addition to their magic names specified in the pathspec.

What's different between what you expected and what actually happened? Resulting pathspec is ':(attr,prefix:0)' when it should be ':(attr:<somevalue>,prefix:0)'

Anything else you want to add: attr pathspec magic is currently blocked for git stash by GUARD_PATHSPEC https://github.com/git/git/blob/master/dir.c#L2176 But, it looks like it can be unblocked, once prefix_magic() is fixed.

Also add-interactive also uses PATHSPEC_PREFIX_ORIGIN as a flag and the resulting pathspec from parse_pathspec shows the same bug. But `git add -i ':(attr:<somevalue>'` behaves as expected and I'm not sure why. It may be using different parts of the pathspec struct down the line to filter out files.

[Enabled Hooks] commit-msg pre-commit prepare-commit-msg

Message 1 of 1 in “Bug: `git stash push ':(attr:<somevalue>)' attr magic does not get parsed correctly”
  1. Joanna WangOct 11, 2023

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.