From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 769F11F8C6 for ; Mon, 30 Aug 2021 19:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232831AbhH3TLl (ORCPT ); Mon, 30 Aug 2021 15:11:41 -0400 Received: from cloud.peff.net ([104.130.231.41]:34138 "EHLO cloud.peff.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232336AbhH3TLl (ORCPT ); Mon, 30 Aug 2021 15:11:41 -0400 Received: (qmail 710 invoked by uid 109); 30 Aug 2021 19:10:47 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Mon, 30 Aug 2021 19:10:47 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 9161 invoked by uid 111); 30 Aug 2021 19:10:47 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Mon, 30 Aug 2021 15:10:47 -0400 Authentication-Results: peff.net; auth=none Date: Mon, 30 Aug 2021 15:10:46 -0400 From: Jeff King To: Stef Bon Cc: Git Users Subject: Re: Exec upload-pack on remote with what parameters to get direntries. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 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