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

Re: [PATCH] ref-filter: don't look for objects when outside of a repository

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Nov 16, 2018, 13:16 UTC
Message-ID
<20181116131644.GM30222@szeder.dev>
In-Reply-To
<xmqq36s1libw.fsf@gitster-ct.c.googlers.com>
On Fri, Nov 16, 2018 at 02:09:07PM +0900, Junio C Hamano wrote:
Show 28 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > On Thu, Nov 15, 2018 at 04:38:44AM -0500, Jeff King wrote:
> >
> >> Is SOURCE_NONE a complete match for what we want?
> >> 
> >> I see problems in both directions:
> >> 
> >>  - sorting by "objectname" works now, but it's marked with SOURCE_OBJ,
> >>    and would be forbidden with your patch.  I'm actually not sure if
> >>    SOURCE_OBJ is accurate; we shouldn't need to access the object to
> >>    show it (and we are probably wasting effort loading the full contents
> >>    for tools like for-each-ref).
> >> 
> >>    However, that's not the full story. For objectname:short, it _does_ call
> >>    find_unique_abbrev(). So we expect to have an object directory.
> >
> > Oops, I'm apparently bad at reading. It is in fact SOURCE_OTHER, which
> > makes sense (outside of this whole "--sort outside a repo thing").
> >
> > But we'd ideally distinguish between "objectname" (which should be OK
> > outside a repo) and "objectname:short" (which currently segfaults).
> 
> Arguably, use of ref-filter machinery in ls-remote, whether it is
> given from inside or outside a repo, was a mistake in 1fb20dfd
> ("ls-remote: create '--sort' option", 2018-04-09), as the whole
> point of "ls-remote" is to peek the list of refs and it is perfectly
> normal that the objects listed are not available.

I hope that one day 'git ls-remote' will learn to '--format=...' its output, and I think that (re)using the ref-filter machinery would be the right way to go to achive that. Sure, ref-filter supports a lot of format specifiers that don't at all make sense in the context of 'ls-remote' (perhaps we should have a dedicated set of valid_atoms for that), but I think it's perfectly reasonable to do something like:

  git ls-remote --format=%(refname:strip=2) remote

A concrete use case for that could be to eliminate the last remaining shell loops from refs completion.

Previous: Junio C Hamano
Message 15 of 15 in “Coredump on ls-remote + --sort”
  1. H.Merijn BrandSep 22, 2018
  2. Ævar Arnfjörð BjarmasonSep 22, 2018
  3. ref-filter: don't look for objects when outside of a repositorySZEDER Gábor, Sep 22, 2018
  4. Junio C HamanoSep 24, 2018
  5. Jeff KingSep 24, 2018
  6. SZEDER GáborSep 24, 2018
  7. Jeff KingSep 24, 2018
  8. Junio C HamanoSep 25, 2018
  9. ref-filter: don't look for objects when outside of a repositorySZEDER Gábor, Nov 14, 2018
  10. Jeff KingNov 15, 2018
  11. Jeff KingNov 15, 2018
  12. Junio C HamanoNov 16, 2018
  13. Jeff KingNov 16, 2018
  14. Junio C HamanoNov 16, 2018
  15. SZEDER GáborNov 16, 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.