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

Re: [PATCH] ref-filter: share bases and is_base_tips between formatting and sorting

From
Jeff King <peff@peff.net>
Date
Jan 13, 2025, 05:23 UTC
Message-ID
<20250113052313.GA768703@coredump.intra.peff.net>
In-Reply-To
<20250113051700.GA767856@coredump.intra.peff.net>
On Mon, Jan 13, 2025 at 12:17:01AM -0500, Jeff King wrote:
Show 10 quoted lines
> diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
> index 42f34e1236..ed38b82346 100644
> --- a/builtin/ls-remote.c
> +++ b/builtin/ls-remote.c
> @@ -61,6 +61,7 @@ int cmd_ls_remote(int argc,
>  	const struct ref *ref;
>  	struct ref_array ref_array;
>  	struct ref_sorting *sorting;
> +	struct ref_format format = REF_FORMAT_INIT;
>  	struct string_list sorting_options = STRING_LIST_INIT_DUP;

This caller in ls-remote is the only one that doesn't otherwise have a ref_format struct. I don't think it's a big deal to add one like this, and it might even be nice to support --format.

But I suspect there are other weird errors lurking (however we structure this code) because we may not actually have access to the objects! The ahead-behind atom seems to gloss over that, but others will barf. Interestingly we detect the out-of-repo case:

  $ git ls-remote --sort=authordate git.git
  fatal: not a git repository, but the field 'authordate' requires access to object data
but not if we have a repo:
  $ git init
  $ git ls-remote --sort=authordate git.git
  fatal: missing object 978601ccf7b27399aa349c535b29965e664046c4 for refs/heads/ci-config

I guess it would work _sometimes_ if you've fetched recently from the remote. So maybe it does not make sense to outlaw all object-inspecting atoms for ls-remote, and just say that the error above is the best we can do? It does get weird with ahead-behind, though, as you'll get a different sort order depending on whether you've actually fetched the object.

Anyway, all orthogonal to what you're fixing, but kind of gross none the less.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 4 of 19 in “Bug sorting git branch output by ahead-behind:HEAD”
  1. Ross GoldbergJan 5, 2025
  2. ref-filter: share bases and is_base_tips between formatting and sortingRené Scharfe, Jan 12, 2025
  3. Jeff KingJan 13, 2025
  4. Jeff KingJan 13, 2025
  5. Junio C HamanoJan 13, 2025
  6. René ScharfeJan 14, 2025
  7. Jeff KingJan 16, 2025
  8. Jeff KingJan 16, 2025
  9. Jeff KingJan 16, 2025
  10. Junio C HamanoJan 16, 2025
  11. René ScharfeJan 18, 2025
  12. René ScharfeJan 19, 2025
  13. René ScharfeJan 19, 2025
  14. René ScharfeJan 19, 2025
  15. Jeff KingJan 19, 2025
  16. René ScharfeJan 18, 2025
  17. 1/3 ref-filter: move ahead-behind bases into used_atomRené Scharfe, Jan 18, 2025
  18. 3/3 ref-filter: remove ref_format_clear()René Scharfe, Jan 18, 2025
  19. 2/3 ref-filter: move is-base tip to used_atomRené Scharfe, Jan 18, 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.