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

Re: [BUG] "git --literal-pathspecs blame" broken in master

From
Duy Nguyen <pclouds@gmail.com>
Date
Oct 25, 2013, 04:16 UTC
Message-ID
<CACsJy8Aw9KyeWqgC5KQmqPrzD7J4Gga1ibDTvfNQFaVN303U9g@mail.gmail.com>
In-Reply-To
<20131025040436.GA11810@sigill.intra.peff.net>
On Fri, Oct 25, 2013 at 11:04 AM, Jeff King <peff@peff.net> wrote:
Show 41 quoted lines
> On Thu, Oct 24, 2013 at 11:49:47PM -0400, Jeff King wrote:
>
>> We get another change with a16bf9d (pathspec: make --literal-pathspecs
>> disable pathspec magic, 2013-07-14), which I would think would fix
>> things, but doesn't.
>>
>>   $ git blame ':(foo)bar'
>>   fatal: Invalid pathspec magic 'foo' in ':(foo)bar'
>>   $ git --literal-pathspecs blame ':(foo)bar'
>>   fatal: :(foo)bar: pathspec magic not supported by this command: 'literal'
>>
>> The first one remains good, but the second one is still broken. I
>> haven't dug further yet, but I thought it might be a bit more obvious to
>> you.
>
> Hmm. Is the fix as simple as:
>
> diff --git a/builtin/blame.c b/builtin/blame.c
> index 56e3d6b..1c2b303 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -408,7 +408,7 @@ static struct origin *find_origin(struct scoreboard *sb,
>         paths[0] = origin->path;
>         paths[1] = NULL;
>
> -       parse_pathspec(&diff_opts.pathspec, PATHSPEC_ALL_MAGIC, 0, "", paths);
> +       parse_pathspec(&diff_opts.pathspec, PATHSPEC_ALL_MAGIC & ~PATHSPEC_LITERAL, 0, "", paths);
>         diff_setup_done(&diff_opts);
>
>         if (is_null_sha1(origin->commit->object.sha1))
>
> All of the GUARD_PATHSPEC calls indicate that everybody understands
> PATHSPEC_LITERAL. It is not technically true that git-blame understands
> the literal pathspec magic:
>
>   $ git blame -- ':(literal)revision.c'
>   fatal: no such path ':(literal)revision.c' in HEAD
>
> but that is a separate bug (that blame considers the argument as a path
> first before feeding it to the pathspec machinery). The patch above does
> not fix that, but AFAICT it does not make anything worse.

I did consider this change but dropped it because there are more parse_pathspec() calls with PATHSPEC_ALL_MAGIC as mask. Thanks for bringing up ":(literal)". I guess we need to change prefix_pathspec() to set PATHSPEC_LITERAL only when :(literal) is present, not when --literal-pathspecs is used.

-- 
Duy
Previous: Jeff KingNext: Jeff King
Message 3 of 8 in “[BUG] "git --literal-pathspecs blame" broken in master”
  1. Jeff KingOct 25, 2013
  2. Jeff KingOct 25, 2013
  3. Duy NguyenOct 25, 2013
  4. Jeff KingOct 25, 2013
  5. Duy NguyenOct 25, 2013
  6. pathspec: stop --*-pathspecs impact on internal parse_pathspec() usesNguyễn Thái Ngọc Duy, Oct 26, 2013
  7. Jeff KingOct 26, 2013
  8. pathspec: stop --*-pathspecs impact on internal parse_pathspec() usesNguyễn Thái Ngọc Duy, Oct 26, 2013

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.