Re: [PATCH] ref-filter: don't look for objects when outside of a repository
- From
Jeff King <peff@peff.net>
- Date
- Nov 16, 2018, 08:56 UTC
- Message-ID
- <20181116085602.GB20828@sigill.intra.peff.net>
- 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 22 quoted lines
> >> 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 think it's conceptually reasonable to use the ref-filter machinery. It's just that it was underprepared to handle this out-of-repo case. I think we're not too far off, though.
Show 5 quoted lines
> "ls-remote --sort=authorname" that is run in a repository may not > segfault on a ref that points at a yet-to-be-fetched commit, but it > cannot be doing anything sensible. Is it still better to silently > produce a nonsense result than refusing to --sort no matter what the > sort keys are, whether we are inside or outside a repository?
I don't think we produce silent nonsense in the current code (or after any of the discussed solutions), either in a repo or out. We say "fatal: missing object ..." inside a repo if the request cannot be fulfilled. That's not incredibly illuminating, perhaps, but it means we fulfill whatever we _can_ on behalf of the user's request, and bail otherwise.
If you are arguing that even in a repo we should reject "authorname" early (just as we would outside of a repo), I could buy that. Technically we can make it work sometimes (if we happen to have fetched everything the other side has), but behaving consistently (and with a decent error message) may trump that.
-Peff