All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Stef Bon <stefbon@gmail.com>
Cc: Git Users <git@vger.kernel.org>
Subject: Re: Exec upload-pack on remote with what parameters to get direntries.
Date: Mon, 30 Aug 2021 15:10:46 -0400	[thread overview]
Message-ID: <YS0tNoAa/0VQe1OW@coredump.intra.peff.net> (raw)
In-Reply-To: <CANXojcyWnFY60bXG6MDS9WAYkcFQHf+Oef0VREBkvgsuX9e=Kg@mail.gmail.com>

On Sat, Aug 28, 2021 at 02:56:17PM +0200, Stef Bon wrote:

> I've got a custom ssh library which I use to make a connection to a
> git server like www.github.com, user stefbon.
> 
> Now I want to get the direntries of a remote repo, and I know I have
> to use upload-pack for that, but with what parameters?
> 
> I want to use the outcome to make a fuse fs, user can browse the
> files. Possibly the user can also view the contents.

The protocol used by upload-pack is described in
Documentation/technical/pack-protocol.txt, but in short: I don't think
it will do what you want.

There is no operation to list the tree contents, for example, nor really
even a good way to fetch a single object. The protocol is geared around
efficiently transferring slices of history, so it is looking at sets of
reachable objects (what the client is asking for, and what it claims to
have).

You might be able to cobble something together with shallow and partial
fetches. E.g., something like:

  git clone --depth 1 --filter=blob:none --single-branch -b $branch

is basically asking to send only a single commit, plus all of its trees,
but no blobs. From there you could parse the tree objects to assemble a
directory listing. Possibly with a tree:depth filter you could even do
it iteratively.

Some hosts offer a separate API that would give you a much nicer
interface. E.g., GitHub has:

  https://docs.github.com/en/rest/reference/git#trees

But of course that won't work with GitLab, etc, and you'd have to
implement against the API for each hosting provider.

-Peff

  reply	other threads:[~2021-08-30 19:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 12:56 Exec upload-pack on remote with what parameters to get direntries Stef Bon
2021-08-30 19:10 ` Jeff King [this message]
2021-08-30 19:43   ` Junio C Hamano
2021-08-30 20:46     ` Jeff King
2021-08-30 21:21       ` Junio C Hamano
2021-08-31 14:23         ` Ævar Arnfjörð Bjarmason
2021-08-31 15:35           ` Bruno Albuquerque
2021-08-31 16:23             ` Junio C Hamano
2021-08-31  6:38   ` Stef Bon
2021-08-31  7:07     ` Jeff King
2021-08-31  9:44       ` Stef Bon
2021-08-31 14:01         ` Ævar Arnfjörð Bjarmason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YS0tNoAa/0VQe1OW@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=stefbon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.