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

Re: [GSoC][PATCH] builtin/refs: add 'get' subcommand

From
Ben Knoble <ben.knoble@gmail.com>
Date
Sep 23, 2025, 16:57 UTC
Message-ID
<ABB734D1-EAB4-429C-9A36-C00E114E4207@gmail.com>
In-Reply-To
<20250923104533.21165-1-meetsoni3017@gmail.com>
With apologies if I cover well-trodden ground, as I haven’t been closely following this effort.
Show 5 quoted lines
> Le 23 sept. 2025 à 06:47, Meet Soni <meetsoni3017@gmail.com> a écrit :
> 
> While `git-rev-parse(1)` and `git-show-ref(1)` can be used to read
> reference values, they have drawbacks for scripting and discoverability.
> `rev-parse` performs DWIM expansion which is unpredictable for scripts,
[snip]
Show 5 quoted lines
> To address this, introduce a new plumbing command, `git refs get <ref>`.
> This new command provides three key advantages:
> 
>  - It requires an exact refname and does not perform expansion, making
>    it safer and more predictable for scripting.
What are the disadvantages of rev-parse’s DWIMmery in scripts? I would think it makes handling user input easier (e.g., my custom script can take a local branch name without writing « refs/heads/ » on the command-line). OTOH, a script that wants to precisely identify a ref can do so already, no?
Since rev-parse presumably won’t go away, it might be ok to have 2 ways of parsing (one with magic and one without), but that might be back to the same boat of not having a unified interface 😅
Perhaps later we can add a « --dwim » flag for looser parsing, giving scripteds flexibility but strictness by default?
Previous: Meet SoniNext: Patrick Steinhardt
Message 2 of 11 in “builtin/refs: add 'get' subcommand”
  1. Meet SoniSep 23, 2025
  2. Ben KnobleSep 23, 2025
  3. Patrick SteinhardtSep 24, 2025
  4. Junio C HamanoSep 23, 2025
  5. Patrick SteinhardtSep 24, 2025
  6. Ben KnobleSep 24, 2025
  7. Junio C HamanoSep 24, 2025
  8. Patrick SteinhardtSep 25, 2025
  9. D. Ben KnobleSep 25, 2025
  10. Junio C HamanoSep 25, 2025
  11. Patrick SteinhardtSep 24, 2025

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.