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

Re: [PATCH] object-name: fix reversed ordering with magic pathspecs

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 6, 2024, 11:57 UTC
Message-ID
<xmqqcyi5vxbj.fsf@gitster.g>
In-Reply-To
<9c7b9090-8cf2-4095-8e86-2c85b6fe407f@app.fastmail.com>
"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:
Show 12 quoted lines
> On Fri, Dec 6, 2024, at 10:51, Patrick Steinhardt wrote:
>> It was reported
>
> It would be nice with a hyperlink since this email is not part of the
> email thread for the report.
>
> https://lore.kernel.org/git/Z1LJSADiStlFicTL@pks.im/T/#mae906ec74d5657e702165e29b90927f730280c29
>
>> It was reported that magic pathspecs started to return results in
>
> I’m not used to this being called “magic pathspecs” as a user.
> gitglossary(7) talks about (magic) pathspecs as filepaths.

Thanks for catching the mistaken phrasing. It would have caused unnecessary confusion later to "git log" readers.

The syntax to say that the following path is from the top-level of the working tree even when you are running the command from a subdirectory, e.g.

    cd Documentation
    git log :/t
is described in gitglossary(7):
    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.
    The "magic signature" consists of ASCII symbols that are neither
    alphanumeric, glob, regex special characters nor colon.
    The optional colon that terminates the "magic signature" can be
    omitted if the pattern begins with a character that does not belong to
    "magic signature" symbol set and is not a colon.

and even though the word "magic" signature is used, there is no definition given for the entire construct, i.e. the pathspec that uses a special meaning introduced by the use of "colon followed by one or more magic signature letters". We probably should add a sentence to officially define it, if only to reduce the need for exchanges like this ;-)

    ... and is not a colon.  Such a pathspec that uses these "magic"
    meaning is called "magic pathspec".
But more importantly, the syntax that triggered this topic in
<CAKOEJdcPYn3O01p29rVa+xv=Qr504FQyKJeSB-Moze04ViCGGg@mail.gmail.com>

is *NOT* a magic pathspec at all. It is a revision syntax to name the first commit that is reachable from the current HEAD with a commit log message, that matches the given patterh, i.e.

    git show ":/my message"
which is a (rather lousy) short-hand for a more general
    git show "HEAD^{/my message}"

i.e. <startingRev>^{/<pattern>}. There is no specific name for this syntax.

I suspect that "filepath" you mentioned may be something some folks (but not me or any other long timers) would call yet another syntax, which is :<path>, that names the object sitting at <path> in the index. Because ":/myMessage" look so similar to ":myFile", yet they mean so different things, as I said, ":/myMessage" is a rather lousy short-hand for the more general "^{/<pattern>}" suffix that is less ambiguous.

Patrick, let's not use a wrong word. This is not about pathspec at all, and is a revision syntax. As there is no specific jargon for the syntax, here is what I would write, if I were explaining the problem being solved:

    Recently it was reported [*1*] that "look for the youngest
    reachable commit with log message that match the given pattern"
    syntax (e.g. :/myMessagePattern, or HEAD^{/myMessagePattern})
    started to show older commit.
    [Footnote]
    *1* <CAKOEJdcPYn3O01p29rVa+xv=Qr504FQyKJeSB-Moze04ViCGGg@mail.gmail.com>
Thanks.
Previous: Kristoffer HaugsbakkNext: Patrick Steinhardt
Message 3 of 16 in “object-name: fix reversed ordering with magic pathspecs”
  1. object-name: fix reversed ordering with magic pathspecsPatrick Steinhardt, Dec 6, 2024
  2. Kristoffer HaugsbakkDec 6, 2024
  3. Junio C HamanoDec 6, 2024
  4. Patrick SteinhardtDec 6, 2024
  5. Kristoffer HaugsbakkDec 6, 2024
  6. Junio C HamanoDec 6, 2024
  7. Patrick SteinhardtDec 6, 2024
  8. object-name: fix reversed ordering with ":/<PATTERN>" revisionsPatrick Steinhardt, Dec 6, 2024
  9. Kristoffer HaugsbakkDec 6, 2024
  10. Patrick SteinhardtDec 6, 2024
  11. Junio C HamanoDec 6, 2024
  12. Justin ToblerDec 7, 2024
  13. object-name: fix reversed ordering with ":/<PATTERN>" revisionsPatrick Steinhardt, Dec 6, 2024
  14. Kristoffer HaugsbakkDec 7, 2024
  15. Junio C HamanoDec 7, 2024
  16. René ScharfeDec 9, 2024

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.