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

Re: [PATCH/RFC] get_oid: new extended SHA-1 syntax to control resolution process

From
Duy Nguyen <pclouds@gmail.com>
Date
Jul 1, 2019, 00:30 UTC
Message-ID
<CACsJy8AQ=kiG4jH5WSujefoCQ2yCG4=dV7UUdVh-Gextoa_T7A@mail.gmail.com>
In-Reply-To
<86a7dz4e06.fsf@gmail.com>
On Sun, Jun 30, 2019 at 4:30 PM Jakub Narebski <jnareb@gmail.com> wrote:
Show 35 quoted lines
>
> Bikeshed painting ahead.
>
> Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> [...]
> > The problem is we try every possible way to resolve a rev. Let's have
> > some annotation to express that we only want to resolve a rev in a
> > certain way:
> >
> > - <hash>@{hash} only accepts a full hash or a short hash. If it's a
> >   short hash, it cannot be ambiguous.
> >
> > - <ref>@{literal} only accepts full ref. No turning "master" into
> >   "refs/heads/master".
> >
> > - <output>@{describe} interprets <output> as git-describe output
> >   only, not an object name or a reference.
> >
> > This gives scripts much better control over get_oid(), which
> > translates to rev-parse and a bunch other commands.
> >
> > PS. The new syntax can stack with existing ones. E.g. you could write
> > refs/heads/master@{literal}@{yesterday} or <hash>@{hash}^{tree}.
> > Perhaps I should allow these tags at the end too, so you can enforce a
> > variable like "$REV"@{literal} where $REV could be even HEAD~123
>
> I think it would be better to use <hash>^{hash} instead of
> <hash>@{hash}.
>
> The <ref-ish>@{<something>} is used currently for information that is
> outside the DAG, like @{<date>}, @{<n>}, @{-<n>} uses information from
> reflog, and @{upstream} and @{push} uses information from the config.
>
> On the other hand ^{<type>}, ^{/<search text>}, and the future
> ^{<hashalgo>} all use DAG-only information.

I wasn't aware of ^{<hashalgo>}. hash-function-transition.txt is a bit light on the exact behavior, but maybe we can just define it like <hash>@{hash} in this thread (then we don't even need to introduce @{hash})?

That is, if <hash>^{<hashalgo>} fails to find a matching object, the get_oid() result is "not found", there will be no further attempt to interpret the given revision in a different way (e.g. try to see if the same ref exists...). It also means <hash>^{<hashalgo>} will remain supported even after the sha-512 transition period.

@{describe} might go the same way as @{hash} (that is, becoming ^{describe}). I think it's just a slightly different way to write hashes.

> Though one could argue that refs information _is_ outside the DAG...

Refs info is outside DAG. But that's mostly for <ref>@{literal} and it allows something like <ref>@{literal}@{upstream}. But hash (or object name) is already used inside DAG (to link between commits, trees and blobs). Though one might still argue that's only true for full hash, not short ones.

-- 
Duy
Previous: Jakub Narebski
Message 11 of 11 in “specifying revision - how to enforce matching a tag/branch-name or revision only”
  1. Boettger, HeikoJun 20, 2019
  2. Kyle MeyerJun 20, 2019
  3. Junio C HamanoJun 21, 2019
  4. Duy NguyenJun 25, 2019
  5. AW: specifying revision - how to enforce matching a tag/branch-name or revision onlyBoettger, Heiko, Jun 25, 2019
  6. get_oid: new extended SHA-1 syntax to control resolution processNguyễn Thái Ngọc Duy, Jun 26, 2019
  7. Junio C HamanoJun 26, 2019
  8. Duy NguyenJun 27, 2019
  9. Junio C HamanoJun 27, 2019
  10. Jakub NarebskiJun 30, 2019
  11. Duy NguyenJul 1, 2019

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.