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

Re: How is the ^{sha256} peel syntax supposed to work?

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 29, 2018, 20:46 UTC
Message-ID
<20180829204623.GD7547@aiede.svl.corp.google.com>
In-Reply-To
<87y3cpc6bt.fsf@evledraar.gmail.com>
Hi,
Ævar Arnfjörð Bjarmason wrote:
> On Wed, Aug 29 2018, Jonathan Nieder wrote:
Show 6 quoted lines
>> In other words, I want the input format and output format completely
>> decoupled.  If I pass ^{sha1}, I am indicating the input format.  To
>> specify the output format, I'd use --output-format instead.
>
> This is also a reasonable thing to want, but I don't see how it can be
> sensibly squared with the existing peel syntax.

All the weight here is on the word "sensibly". Currently, ^{thing} means "act on the object" and @{thing} means "act on the ref". This ^{sha1} syntax is really a new kind of modifier, ~{thing}, meaning "act on the string".

That said, we can make it do anything we want. There is nothing forcing us to make it more similar to ^{commit} than to ^{/searchstring}, say.

In that context:
[...]
>> Ævar Arnfjörð Bjarmason wrote:
Show 11 quoted lines
>>> Similarly, I think it would be very useful if we just make this work:
>>>
>>>     git rev-parse $some_hash^{sha256}^{commit}
>>>
>>> And not care whether $some_hash is SHA-1 or SHA-256, if it's the former
>>> we'd consult the SHA-1 <-> SHA-256 lookup table and go from there, and
>>> always return a useful value.
>>
>> The opposite of this. :)
>
> Can you elaborate on that?

What I'm saying is, regardless of the syntax used, as a user I *need* a way to look up $some_hash as a sha256-name, with zero risk of Git trying to outsmart me and treating $some_hash as a sha1-name instead.

Any design without that capability is a non-starter.
[...]
Show 7 quoted lines
> I.e. if I'm using this in a script I'd need:
>
>     if x = git rev-parse $some_hash^{sha256}^{commit}
>         hash = x
>     elsif x = git rev-parse $some_hash^{sha1}^{commit}
>         hash = x
>     endif
Why wouldn't you use "git rev-parse $some_hash^{commit}" instead?

Thanks, Jonathan

Previous: Ævar Arnfjörð BjarmasonNext: Jeff King
Message 24 of 33 in “Questions about the hash function transition”
  1. Ævar Arnfjörð BjarmasonAug 23, 2018
  2. Junio C HamanoAug 23, 2018
  3. Ævar Arnfjörð BjarmasonAug 23, 2018
  4. Junio C HamanoAug 23, 2018
  5. brian m. carlsonAug 24, 2018
  6. Jonathan NiederAug 24, 2018
  7. brian m. carlsonAug 24, 2018
  8. Jonathan NiederAug 24, 2018
  9. Jonathan NiederAug 24, 2018
  10. Johannes SchindelinAug 28, 2018
  11. Derrick StoleeAug 28, 2018
  12. Jonathan NiederAug 28, 2018
  13. Jonathan NiederAug 28, 2018
  14. Johannes SchindelinAug 29, 2018
  15. Derrick StoleeAug 29, 2018
  16. Derrick StoleeAug 29, 2018
  17. How is the ^{sha256} peel syntax supposed to work?Ævar Arnfjörð Bjarmason, Aug 29, 2018
  18. Stefan BellerAug 29, 2018
  19. Jonathan NiederAug 29, 2018
  20. Stefan BellerAug 29, 2018
  21. Ævar Arnfjörð BjarmasonAug 29, 2018
  22. Jonathan NiederAug 29, 2018
  23. Ævar Arnfjörð BjarmasonAug 29, 2018
  24. Jonathan NiederAug 29, 2018
  25. Jeff KingAug 29, 2018
  26. Junio C HamanoAug 29, 2018
  27. Jonathan NiederAug 29, 2018
  28. Jonathan NiederAug 29, 2018
  29. Jonathan NiederAug 24, 2018
  30. Ævar Arnfjörð BjarmasonAug 28, 2018
  31. Edward ThomsonAug 28, 2018
  32. Ævar Arnfjörð BjarmasonAug 28, 2018
  33. Junio C HamanoAug 28, 2018

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.