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

Re: [PATCH] show-ref: add --unresolved option

From
Jeff King <peff@peff.net>
Date
Mar 6, 2024, 00:41 UTC
Message-ID
<20240306004139.GB3797463@coredump.intra.peff.net>
In-Reply-To
<pull.1684.git.git.1709592718743.gitgitgadget@gmail.com>
On Mon, Mar 04, 2024 at 10:51:58PM +0000, John Cai via GitGitGadget wrote:
Show 8 quoted lines
> From: John Cai <johncai86@gmail.com>
> 
> For reftable development, it would be handy to have a tool to provide
> the direct value of any ref whether it be a symbolic ref or not.
> Currently there is git-symbolic-ref, which only works for symbolic refs,
> and git-rev-parse, which will resolve the ref. Let's add a --unresolved
> option that will only take one ref and return whatever it points to
> without dereferencing it.

What about "git rev-parse --symbolic-full-name"? I don't think that behaves quite the same as your patch here:

  - it is actually not a true no-deref; it resolves to the final name
    and then prints it (so the behavior is the same for a single-level
    symref, but I believe a multi-level symref chain like
    one->two->three will print "three" when resolving "one").
  - it always prints the resolved name, whereas your patch prints an oid
    for non-symrefs

I'm not sure if those are important or not, as I don't quite understand what you're trying to accomplish. I'd probably have just run:

  git symbolic-ref -q $name || git rev-parse --verify $name

I'm not opposed to making that more ergonomic, but I think we should avoid redundant plumbing options if we can (I'm not sure yet if this is redundant or not, but in general I find "show-ref" to be a weird mix of "rev-parse" and "for-each-ref" that I'd be just as happy if it did not exist).

-Peff
Previous: Junio C HamanoNext: Patrick Steinhardt
Message 9 of 28 in “show-ref: add --unresolved option”
  1. show-ref: add --unresolved optionJohn Cai via GitGitGadget, Mar 4, 2024
  2. Junio C HamanoMar 4, 2024
  3. John CaiMar 5, 2024
  4. Junio C HamanoMar 5, 2024
  5. Phillip WoodMar 5, 2024
  6. Kristoffer HaugsbakkMar 5, 2024
  7. Jeff KingMar 6, 2024
  8. Junio C HamanoMar 6, 2024
  9. Jeff KingMar 6, 2024
  10. Patrick SteinhardtMar 6, 2024
  11. Jeff KingMar 6, 2024
  12. Junio C HamanoMar 6, 2024
  13. Jean-Noël AvilaMar 6, 2024
  14. 0/3 show-ref: add --symbolic-name optionJohn Cai via GitGitGadget, Apr 8, 2024
  15. 2/3 refs: add referent to each_repo_ref_fnJohn Cai via GitGitGadget, Apr 8, 2024
  16. 1/3 refs: keep track of unresolved reference value in iteratorJohn Cai via GitGitGadget, Apr 8, 2024
  17. Junio C HamanoApr 8, 2024
  18. John CaiApr 9, 2024
  19. Patrick SteinhardtApr 10, 2024
  20. Junio C HamanoApr 10, 2024
  21. Patrick SteinhardtApr 11, 2024
  22. 3/3 show-ref: add --symbolic-name optionJohn Cai via GitGitGadget, Apr 8, 2024
  23. Phillip WoodApr 9, 2024
  24. John CaiApr 11, 2024
  25. phillip.wood123@gmail.comApr 12, 2024
  26. Patrick SteinhardtApr 10, 2024
  27. Junio C HamanoApr 10, 2024
  28. John CaiApr 12, 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.